Class Index [+]

Quicksearch

Bundler::SharedHelpers

Attributes

gem_loaded[RW]

Public Instance Methods

default_gemfile() click to toggle source
    # File lib/bundler/shared_helpers.rb, line 19
19:     def default_gemfile
20:       gemfile = find_gemfile
21:       raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
22:       Pathname.new(gemfile)
23:     end
default_lockfile() click to toggle source
    # File lib/bundler/shared_helpers.rb, line 25
25:     def default_lockfile
26:       Pathname.new("#{default_gemfile}.lock")
27:     end
in_bundle?() click to toggle source
    # File lib/bundler/shared_helpers.rb, line 29
29:     def in_bundle?
30:       find_gemfile
31:     end

Private Instance Methods

clean_load_path() click to toggle source
    # File lib/bundler/shared_helpers.rb, line 55
55:     def clean_load_path
56:       # handle 1.9 where system gems are always on the load path
57:       if defined?(::Gem)
58:         me = File.expand_path("../../", __FILE__)
59:         $LOAD_PATH.reject! do |p|
60:           next if File.expand_path(p) =~ /^#{me}/
61:           p != File.dirname(__FILE__) &&
62:             Gem.path.any?{|gp| p =~ /^#{gp}/ }
63:         end
64:         $LOAD_PATH.uniq!
65:       end
66:     end
cripple_rubygems(specs) click to toggle source
     # File lib/bundler/shared_helpers.rb, line 80
 80:     def cripple_rubygems(specs)
 81:       reverse_rubygems_kernel_mixin
 82: 
 83:       executables = specs.map { |s| s.executables }.flatten
 84:       Gem.source_index # ensure RubyGems is fully loaded
 85: 
 86:       ::Kernel.send(:define_method, :gem) do |dep, *reqs|
 87:         if executables.include? File.basename(caller.first.split(':').first)
 88:           return
 89:         end
 90:         opts = reqs.last.is_a?(Hash) ? reqs.pop : {}
 91: 
 92:         unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
 93:           dep = Gem::Dependency.new(dep, reqs)
 94:         end
 95: 
 96:         spec = specs.find  { |s| s.name == dep.name }
 97: 
 98:         if spec.nil?
 99:           e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
100:           e.name = dep.name
101:           e.version_requirement = dep.requirement
102:           raise e
103:         elsif dep !~ spec
104:           e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. "                                   "Make sure all dependencies are added to Gemfile."
105:           e.name = dep.name
106:           e.version_requirement = dep.requirement
107:           raise e
108:         end
109: 
110:         true
111:       end
112: 
113:       # === Following hacks are to improve on the generated bin wrappers ===
114: 
115:       # Yeah, talk about a hack
116:       source_index_class = (class << Gem::SourceIndex ; self ; end)
117:       source_index_class.send(:remove_method, :from_gems_in)
118:       source_index_class.send(:define_method, :from_gems_in) do |*args|
119:         source_index = Gem::SourceIndex.new
120:         source_index.spec_dirs = *args
121:         source_index.add_specs(*specs)
122:         source_index
123:       end
124: 
125:       # OMG more hacks
126:       gem_class = (class << Gem ; self ; end)
127:       gem_class.send(:remove_method, :refresh)
128:       gem_class.send(:define_method, :refresh) { }
129:       gem_class.send(:remove_method, :bin_path)
130:       gem_class.send(:define_method, :bin_path) do |name, *args|
131:         exec_name, *reqs = args
132: 
133:         if exec_name == 'bundle'
134:           return ENV['BUNDLE_BIN_PATH']
135:         end
136: 
137:         spec = nil
138: 
139:         if exec_name
140:           spec = specs.find { |s| s.executables.include?(exec_name) }
141:           spec or raise Gem::Exception, "can't find executable #{exec_name}"
142:         else
143:           spec = specs.find  { |s| s.name == name }
144:           exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
145:         end
146: 
147:         gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
148:         gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
149:         File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
150:       end
151: 
152:       Gem.clear_paths
153:     end
find_gemfile() click to toggle source
    # File lib/bundler/shared_helpers.rb, line 35
35:     def find_gemfile
36:       given = ENV['BUNDLE_GEMFILE']
37:       return given if given && !given.empty?
38: 
39:       previous = nil
40:       current  = File.expand_path(Dir.pwd)
41: 
42:       until !File.directory?(current) || current == previous
43:         if ENV['BUNDLE_SPEC_RUN']
44:           # avoid stepping above the tmp directory when testing
45:           return nil if File.file?(File.join(current, 'bundler.gemspec'))
46:         end
47: 
48:         # otherwise return the Gemfile if it's there
49:         filename = File.join(current, 'Gemfile')
50:         return filename if File.file?(filename)
51:         current, previous = File.expand_path("..", current), current
52:       end
53:     end
reverse_rubygems_kernel_mixin() click to toggle source
    # File lib/bundler/shared_helpers.rb, line 68
68:     def reverse_rubygems_kernel_mixin
69:       # Disable rubygems' gem activation system
70:       ::Kernel.class_eval do
71:         if private_method_defined?(:gem_original_require)
72:           alias rubygems_require require
73:           alias require gem_original_require
74:         end
75: 
76:         undef gem
77:       end
78:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.