diff options
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r-- | lib/rubygems/commands/owner_command.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/commands/push_command.rb | 3 | ||||
-rw-r--r-- | lib/rubygems/commands/query_command.rb | 27 | ||||
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 159 | ||||
-rw-r--r-- | lib/rubygems/commands/yank_command.rb | 3 |
5 files changed, 114 insertions, 82 deletions
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index 4b99434e87..8e2271657a 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -40,7 +40,9 @@ permission to. options[:remove] << value end - add_option '-h', '--host HOST', 'Use another gemcutter-compatible host' do |value, options| + add_option '-h', '--host HOST', + 'Use another gemcutter-compatible host', + ' (e.g. https://rubygems.org)' do |value, options| options[:host] = value end end diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 6adeff6b30..d294cbc8df 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -33,7 +33,8 @@ command. For further discussion see the help for the yank command. add_key_option add_option('--host HOST', - 'Push to another gemcutter-compatible host') do |value, options| + 'Push to another gemcutter-compatible host', + ' (e.g. https://rubygems.org)') do |value, options| options[:host] = value end diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb index f25d120b88..813154fa23 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -255,22 +255,21 @@ is too hard to use. name_tuples.map { |n| n.version }.uniq else platforms.sort.reverse.map do |version, pls| - if pls == [Gem::Platform::RUBY] then - if options[:domain] == :remote || specs.all? { |spec| spec.is_a? Gem::Source } - version - else - spec = specs.select { |s| s.version == version } - if spec.first.default_gem? - "default: #{version}" - else - version - end + out = version.to_s + + if options[:domain] == :local + default = specs.any? do |s| + !s.is_a?(Gem::Source) && s.version == version && s.default_gem? end - else - ruby = pls.delete Gem::Platform::RUBY - platform_list = [ruby, *pls.sort].compact - "#{version} #{platform_list.join ' '}" + out = "default: #{out}" if default + end + + if pls != [Gem::Platform::RUBY] then + platform_list = [pls.delete(Gem::Platform::RUBY), *pls.sort].compact + out = platform_list.unshift(out).join(' ') end + + out end end diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index ebb08d24d7..1fff2a7dcb 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -142,6 +142,8 @@ By default, this RubyGems will install gem as: remove_old_lib_files lib_dir + install_default_gemspec + say "RubyGems #{Gem::VERSION} installed" uninstall_old_gemcutter @@ -202,59 +204,65 @@ By default, this RubyGems will install gem as: end end - def install_executables(bin_dir) - say "Installing gem executable" if @verbose + def install_executables(bin_dir) @bin_file_names = [] - Dir.chdir 'bin' do - bin_files = Dir['*'] - - bin_files.delete 'update_rubygems' - - bin_files.each do |bin_file| - bin_file_formatted = if options[:format_executable] then - Gem.default_exec_format % bin_file - else - bin_file - end + { + 'gem' => 'bin', + 'bundler' => 'bundler/exe', + }.each do |tool, path| + say "Installing #{tool} executable" if @verbose - dest_file = File.join bin_dir, bin_file_formatted - bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}" + Dir.chdir path do + bin_files = Dir['*'] - begin - bin = File.readlines bin_file - bin[0] = "#!#{Gem.ruby}\n" + bin_files -= %w[update_rubygems bundler bundle_ruby] - File.open bin_tmp_file, 'w' do |fp| - fp.puts bin.join - end + bin_files.each do |bin_file| + bin_file_formatted = if options[:format_executable] then + Gem.default_exec_format % bin_file + else + bin_file + end - install bin_tmp_file, dest_file, :mode => 0755 - @bin_file_names << dest_file - ensure - rm bin_tmp_file - end + dest_file = File.join bin_dir, bin_file_formatted + bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}" - next unless Gem.win_platform? + begin + bin = File.readlines bin_file + bin[0] = "#!#{Gem.ruby}\n" - begin - bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat" + File.open bin_tmp_file, 'w' do |fp| + fp.puts bin.join + end - File.open bin_cmd_file, 'w' do |file| - file.puts <<-TEXT -@ECHO OFF -IF NOT "%~f0" == "~f0" GOTO :WinNT -@"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9 -GOTO :EOF -:WinNT -@"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %* -TEXT + install bin_tmp_file, dest_file, :mode => 0755 + @bin_file_names << dest_file + ensure + rm bin_tmp_file end - install bin_cmd_file, "#{dest_file}.bat", :mode => 0755 - ensure - rm bin_cmd_file + next unless Gem.win_platform? + + begin + bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat" + + File.open bin_cmd_file, 'w' do |file| + file.puts <<-TEXT + @ECHO OFF + IF NOT "%~f0" == "~f0" GOTO :WinNT + @"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9 + GOTO :EOF + :WinNT + @"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %* + TEXT + end + + install bin_cmd_file, "#{dest_file}.bat", :mode => 0755 + ensure + rm bin_cmd_file + end end end end @@ -269,18 +277,23 @@ TEXT end def install_lib(lib_dir) - say "Installing RubyGems" if @verbose - - lib_files = rb_files_in 'lib' - pem_files = pem_files_in 'lib' - - Dir.chdir 'lib' do - lib_files.each do |lib_file| - install_file lib_file, lib_dir - end + { + 'RubyGems' => 'lib', + 'Bundler' => 'bundler/lib' + }.each do |tool, path| + say "Installing #{tool}" if @verbose + + lib_files = rb_files_in path + pem_files = pem_files_in path + + Dir.chdir path do + lib_files.each do |lib_file| + install_file lib_file, lib_dir + end - pem_files.each do |pem_file| - install_file pem_file, lib_dir + pem_files.each do |pem_file| + install_file pem_file, lib_dir + end end end end @@ -326,6 +339,19 @@ TEXT return false end + def install_default_gemspec + Dir.chdir("bundler") do + bundler_spec = Gem::Specification.load("bundler.gemspec") + bundler_spec.files = Dir["{*.md,{lib,exe,man}/**/*}"] + bundler_spec.executables -= %w[bundler bundle_ruby] + Dir.entries(Gem::Specification.default_specifications_dir). + select {|gs| gs.start_with?("bundler-") }. + each {|gs| File.delete(File.join(Gem::Specification.default_specifications_dir, gs)) } + default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec") + Gem.write_binary(default_spec_path, bundler_spec.to_ruby) + end + end + def make_destination_dirs(install_destdir) lib_dir, bin_dir = Gem.default_rubygems_dirs @@ -416,23 +442,27 @@ abort "#{deprecation_message}" end def remove_old_lib_files lib_dir - rubygems_dir = File.join lib_dir, 'rubygems' - lib_files = rb_files_in 'lib/rubygems' + { + File.join(lib_dir, 'rubygems') => 'lib/rubygems', + File.join(lib_dir, 'bundler') => 'bundler/lib/bundler', + }.each do |old_lib_dir, new_lib_dir| + lib_files = rb_files_in(new_lib_dir) - old_lib_files = rb_files_in rubygems_dir + old_lib_files = rb_files_in(old_lib_dir) - to_remove = old_lib_files - lib_files + to_remove = old_lib_files - lib_files - to_remove.delete_if do |file| - file.start_with? 'defaults' - end + to_remove.delete_if do |file| + file.start_with? 'defaults' + end - Dir.chdir rubygems_dir do - to_remove.each do |file| - FileUtils.rm_f file + Dir.chdir old_lib_dir do + to_remove.each do |file| + FileUtils.rm_f file - warn "unable to remove old file #{file} please remove it by hand" if - File.exist? file + warn "unable to remove old file #{file} please remove it by hand" if + File.exist? file + end end end end @@ -481,4 +511,3 @@ abort "#{deprecation_message}" end end - diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb index 0d6575b272..36809cbd57 100644 --- a/lib/rubygems/commands/yank_command.rb +++ b/lib/rubygems/commands/yank_command.rb @@ -42,7 +42,8 @@ as the reason for the removal request. add_platform_option("remove") add_option('--host HOST', - 'Yank from another gemcutter-compatible host') do |value, options| + 'Yank from another gemcutter-compatible host', + ' (e.g. https://rubygems.org)') do |value, options| options[:host] = value end |