method
install_default_bundler_gem
Ruby latest stable (v2_5_5)
-
0 notes -
Class: SetupCommand
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
install_default_bundler_gem()
public
Hide source
# File lib/rubygems/commands/setup_command.rb, line 350 def install_default_bundler_gem return unless Gem::USE_BUNDLER_FOR_GEMDEPS specs_dir = Gem::Specification.default_specifications_dir specs_dir = File.join(options[:destdir], specs_dir) unless Gem.win_platform? mkdir_p specs_dir # Workaround for non-git environment. gemspec = File.open('bundler/bundler.gemspec', 'rb'){|f| f.read.gsub(/`git ls-files -z`/, "''") } File.open('bundler/bundler.gemspec', 'w'){|f| f.write gemspec } bundler_spec = Gem::Specification.load("bundler/bundler.gemspec") bundler_spec.files = Dir.chdir("bundler") { Dir["{*.md,{lib,exe,man}/**/*}"] } bundler_spec.executables -= ]bundler bundle_ruby] # Remove bundler-*.gemspec in default specification directory. Dir.entries(specs_dir). select {|gs| gs.start_with?("bundler-") }. each {|gs| File.delete(File.join(specs_dir, gs)) } default_spec_path = File.join(specs_dir, "#{bundler_spec.full_name}.gemspec") Gem.write_binary(default_spec_path, bundler_spec.to_ruby) bundler_spec = Gem::Specification.load(default_spec_path) # Remove gemspec that was same version of vendored bundler. normal_gemspec = File.join(Gem.default_dir, "specifications", "bundler-#{bundler_spec.version}.gemspec") if File.file? normal_gemspec File.delete normal_gemspec end # Remove gem files that were same version of vendored bundler. if File.directory? bundler_spec.gems_dir Dir.entries(bundler_spec.gems_dir). select {|default_gem| File.basename(default_gem) == "bundler-#{bundler_spec.version}" }. each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } end bundler_bin_dir = File.join(Gem.default_dir, 'gems', bundler_spec.full_name, bundler_spec.bindir) bundler_bin_dir = File.join(options[:destdir], bundler_bin_dir) unless Gem.win_platform? mkdir_p bundler_bin_dir bundler_spec.executables.each do |e| cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e) end if Gem.win_platform? require 'rubygems/installer' installer = Gem::Installer.for_spec bundler_spec bundler_spec.executables.each do |e| installer.generate_windows_script e, bundler_spec.bin_dir end end say "Bundler #{bundler_spec.version} installed" end