Object
# File lib/bundler/rubygems_integration.rb, line 72 72: def bin_path(gem, bin, ver) 73: Gem.bin_path(gem, bin, ver) 74: end
# File lib/bundler/rubygems_integration.rb, line 68 68: def clear_paths 69: Gem.clear_paths 70: end
# File lib/bundler/rubygems_integration.rb, line 24 24: def configuration 25: Gem.configuration 26: end
# File lib/bundler/rubygems_integration.rb, line 103 103: def download_gem(spec, uri, path) 104: Gem::RemoteFetcher.fetcher.download(spec, uri, path) 105: end
# File lib/bundler/rubygems_integration.rb, line 85 85: def fetch_specs(all, pre, &blk) 86: Gem::SpecFetcher.new.list(all, pre).each(&blk) 87: end
# File lib/bundler/rubygems_integration.rb, line 52 52: def gem_bindir 53: Gem.bindir 54: end
# File lib/bundler/rubygems_integration.rb, line 48 48: def gem_dir 49: Gem.dir 50: end
# File lib/bundler/rubygems_integration.rb, line 60 60: def gem_path 61: Gem.path 62: end
# File lib/bundler/rubygems_integration.rb, line 36 36: def inflate(obj) 37: Gem.inflate(obj) 38: end
# File lib/bundler/rubygems_integration.rb, line 8 8: def loaded_specs(name) 9: Gem.loaded_specs[name] 10: end
# File lib/bundler/rubygems_integration.rb, line 12 12: def mark_loaded(spec) 13: Gem.loaded_specs[spec.name] = spec 14: end
# File lib/bundler/rubygems_integration.rb, line 64 64: def marshal_spec_dir 65: Gem::MARSHAL_SPEC_DIR 66: end
# File lib/bundler/rubygems_integration.rb, line 16 16: def path(obj) 17: obj.to_s 18: end
# File lib/bundler/rubygems_integration.rb, line 20 20: def platforms 21: Gem.platforms 22: end
# File lib/bundler/rubygems_integration.rb, line 76 76: def preserve_paths 77: # this is a no-op outside of Rubygems 1.8 78: yield 79: end
# File lib/bundler/rubygems_integration.rb, line 32 32: def read_binary(path) 33: Gem.read_binary(path) 34: end
Used to make bin stubs that are not created by bundler work under bundler. The new Gem.bin_path only considers gems in specs
# File lib/bundler/rubygems_integration.rb, line 204 204: def replace_bin_path(specs) 205: gem_class = (class << Gem ; self ; end) 206: gem_class.send(:remove_method, :bin_path) 207: gem_class.send(:define_method, :bin_path) do |name, *args| 208: exec_name, *reqs = args 209: 210: if exec_name == 'bundle' 211: return ENV['BUNDLE_BIN_PATH'] 212: end 213: 214: spec = nil 215: 216: if exec_name 217: spec = specs.find { |s| s.executables.include?(exec_name) } 218: spec or raise Gem::Exception, "can't find executable #{exec_name}" 219: else 220: spec = specs.find { |s| s.name == name } 221: exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}" 222: end 223: 224: gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name) 225: gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name) 226: File.exist?(gem_bin) ? gem_bin : gem_from_path_bin 227: end 228: end
Replace or hook into Rubygems to provide a bundlerized view of the world.
# File lib/bundler/rubygems_integration.rb, line 240 240: def replace_entrypoints(specs) 241: reverse_rubygems_kernel_mixin 242: 243: replace_gem(specs) 244: 245: stub_rubygems(specs) 246: 247: replace_bin_path(specs) 248: replace_refresh 249: 250: Gem.clear_paths 251: end
# File lib/bundler/rubygems_integration.rb, line 119 119: def replace_gem(specs) 120: executables = specs.map { |s| s.executables }.flatten 121: 122: ::Kernel.send(:define_method, :gem) do |dep, *reqs| 123: if executables.include? File.basename(caller.first.split(':').first) 124: return 125: end 126: opts = reqs.last.is_a?(Hash) ? reqs.pop : {} 127: 128: unless dep.respond_to?(:name) && dep.respond_to?(:requirement) 129: dep = Gem::Dependency.new(dep, reqs) 130: end 131: 132: spec = specs.find { |s| s.name == dep.name } 133: 134: if spec.nil? 135: 136: e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile." 137: e.name = dep.name 138: if e.respond_to?(:requirement=) 139: e.requirement = dep.requirement 140: else 141: e.version_requirement = dep.requirement 142: end 143: raise e 144: elsif dep !~ spec 145: e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " "Make sure all dependencies are added to Gemfile." 146: e.name = dep.name 147: if e.respond_to?(:requirement=) 148: e.requirement = dep.requirement 149: else 150: e.version_requirement = dep.requirement 151: end 152: raise e 153: end 154: 155: true 156: end 157: end
Because Bundler has a static view of what specs are available, we don’t reflesh, so stub it out.
# File lib/bundler/rubygems_integration.rb, line 232 232: def replace_refresh 233: gem_class = (class << Gem ; self ; end) 234: gem_class.send(:remove_method, :refresh) 235: gem_class.send(:define_method, :refresh) { } 236: end
# File lib/bundler/rubygems_integration.rb, line 107 107: def reverse_rubygems_kernel_mixin 108: # Disable rubygems' gem activation system 109: ::Kernel.class_eval do 110: if private_method_defined?(:gem_original_require) 111: alias rubygems_require require 112: alias require gem_original_require 113: end 114: 115: undef gem 116: end 117: end
# File lib/bundler/rubygems_integration.rb, line 28 28: def ruby_engine 29: Gem.ruby_engine 30: end
# File lib/bundler/rubygems_integration.rb, line 44 44: def sources 45: Gem.sources 46: end
# File lib/bundler/rubygems_integration.rb, line 40 40: def sources=(val) 41: Gem.sources = val 42: end
# File lib/bundler/rubygems_integration.rb, line 99 99: def spec_from_gem(path) 100: Gem::Format.from_file_by_path(path).spec 101: end
# File lib/bundler/rubygems_integration.rb, line 170 170: def stub_source_index137(specs) 171: # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in 172: source_index_class = (class << Gem::SourceIndex ; self ; end) 173: source_index_class.send(:remove_method, :from_gems_in) 174: source_index_class.send(:define_method, :from_gems_in) do |*args| 175: source_index = Gem::SourceIndex.new 176: source_index.spec_dirs = *args 177: source_index.add_specs(*specs) 178: source_index 179: end 180: end
# File lib/bundler/rubygems_integration.rb, line 182 182: def stub_source_index170(specs) 183: Gem::SourceIndex.send(:define_method, :initialize) do |*args| 184: @gems = {} 185: # You're looking at this thinking: Oh! This is how I make those 186: # rubygems deprecations go away! 187: # 188: # You'd be correct BUT using of this method in production code 189: # must be approved by the rubygems team itself! 190: # 191: # This is your warning. If you use this and don't have approval 192: # we can't protect you. 193: # 194: Deprecate.skip_during do 195: self.spec_dirs = *args 196: add_specs(*specs) 197: end 198: end 199: end
# File lib/bundler/rubygems_integration.rb, line 81 81: def ui=(obj) 82: Gem::DefaultUserInteraction.ui = obj 83: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.