diff options
Diffstat (limited to 'lib/rubygems/commands/setup_command.rb')
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 93a46d4350..5d1414d102 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -82,11 +82,7 @@ class Gem::Commands::SetupCommand < Gem::Command add_option '--[no-]regenerate-binstubs', 'Regenerate gem binstubs' do |value, options| - if value then - options[:regenerate_binstubs] = true - else - options.delete(:regenerate_binstubs) - end + options[:regenerate_binstubs] = value end @verbose = nil @@ -156,7 +152,7 @@ By default, this RubyGems will install gem as: say "RubyGems #{Gem::VERSION} installed" - regenerate_binstubs + regenerate_binstubs if options[:regenerate_binstubs] uninstall_old_gemcutter @@ -357,7 +353,7 @@ By default, this RubyGems will install gem as: mkdir_p Gem::Specification.default_specifications_dir # Workaround for non-git environment. - gemspec = File.read('bundler/bundler.gemspec').gsub(/`git ls-files -z`/, "''") + 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") @@ -372,13 +368,24 @@ By default, this RubyGems will install gem as: bundler_spec = Gem::Specification.load(default_spec_path) - Dir.entries(bundler_spec.gems_dir). - select {|default_gem| default_gem.start_with?("bundler-") }. - each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } + if File.directory? bundler_spec.gems_dir + Dir.entries(bundler_spec.gems_dir). + select {|default_gem| File.basename(default_gem).match(/^bundler-#{Gem::Version::VERSION_PATTERN}$/) }. + each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } + end mkdir_p bundler_spec.bin_dir bundler_spec.executables.each {|e| cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_spec.bin_dir, e) } + 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 @@ -442,7 +449,7 @@ By default, this RubyGems will install gem as: # for installation of bundler as default gems def template_files Dir.chdir "bundler/lib" do - (Dir[File.join('bundler', 'templates', '**', '*')] + Dir[File.join('bundler', 'templates', '**', '.*')]). + (Dir[File.join('bundler', 'templates', '**', '{*,.*}')]). select{|f| !File.directory?(f)} end end @@ -450,7 +457,7 @@ By default, this RubyGems will install gem as: # for cleanup old bundler files def template_files_in dir Dir.chdir dir do - (Dir[File.join('templates', '**', '*')] + Dir[File.join('templates', '**', '.*')]). + (Dir[File.join('templates', '**', '{*,.*}')]). select{|f| !File.directory?(f)} end end |