From e798ccbacf489a3af2201ae30058ff0ae7f79045 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 19 Jan 2011 00:08:49 +0000 Subject: Import rubygems 1.5.0 (release candidate) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/build_command.rb | 6 ++ lib/rubygems/commands/cert_command.rb | 14 ++- lib/rubygems/commands/check_command.rb | 25 ++---- lib/rubygems/commands/cleanup_command.rb | 8 +- lib/rubygems/commands/contents_command.rb | 6 ++ lib/rubygems/commands/dependency_command.rb | 28 +++--- lib/rubygems/commands/environment_command.rb | 11 ++- lib/rubygems/commands/fetch_command.rb | 8 +- lib/rubygems/commands/generate_index_command.rb | 17 ++-- lib/rubygems/commands/help_command.rb | 11 +-- lib/rubygems/commands/install_command.rb | 26 +++--- lib/rubygems/commands/list_command.rb | 6 ++ lib/rubygems/commands/lock_command.rb | 8 +- lib/rubygems/commands/mirror_command.rb | 111 ------------------------ lib/rubygems/commands/outdated_command.rb | 6 ++ lib/rubygems/commands/owner_command.rb | 6 ++ lib/rubygems/commands/pristine_command.rb | 7 +- lib/rubygems/commands/push_command.rb | 21 ++++- lib/rubygems/commands/query_command.rb | 34 +++----- lib/rubygems/commands/rdoc_command.rb | 6 ++ lib/rubygems/commands/search_command.rb | 6 ++ lib/rubygems/commands/server_command.rb | 14 +++ lib/rubygems/commands/setup_command.rb | 12 ++- lib/rubygems/commands/sources_command.rb | 40 +++------ lib/rubygems/commands/specification_command.rb | 9 +- lib/rubygems/commands/stale_command.rb | 6 ++ lib/rubygems/commands/uninstall_command.rb | 6 ++ lib/rubygems/commands/unpack_command.rb | 9 +- lib/rubygems/commands/update_command.rb | 79 ++++++++--------- lib/rubygems/commands/which_command.rb | 7 ++ 30 files changed, 265 insertions(+), 288 deletions(-) delete mode 100644 lib/rubygems/commands/mirror_command.rb (limited to 'lib/rubygems/commands') diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb index c1ba9d2a63..5aac489459 100644 --- a/lib/rubygems/commands/build_command.rb +++ b/lib/rubygems/commands/build_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/builder' diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb index f5b698855b..17eaaa113f 100644 --- a/lib/rubygems/commands/cert_command.rb +++ b/lib/rubygems/commands/cert_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/security' @@ -59,21 +65,21 @@ class Gem::Commands::CertCommand < Gem::Command add_option('-C', '--certificate CERT', 'Certificate for --sign command.') do |value, options| cert = OpenSSL::X509::Certificate.new(File.read(value)) - Gem::Security::OPT[:issuer_cert] = cert + options[:issuer_cert] = cert end add_option('-K', '--private-key KEY', 'Private key for --sign command.') do |value, options| key = OpenSSL::PKey::RSA.new(File.read(value)) - Gem::Security::OPT[:issuer_key] = key + options[:issuer_key] = key end add_option('-s', '--sign NEWCERT', 'Sign a certificate with my key and', 'certificate.') do |value, options| cert = OpenSSL::X509::Certificate.new(File.read(value)) - my_cert = Gem::Security::OPT[:issuer_cert] - my_key = Gem::Security::OPT[:issuer_key] + my_cert = options[:issuer_cert] + my_key = options[:issuer_key] cert = Gem::Security.sign_cert(cert, my_key, my_cert) File.open(value, 'wb') { |file| file.write(cert.to_pem) } end diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb index 0bfad9b97c..d739244bed 100644 --- a/lib/rubygems/commands/check_command.rb +++ b/lib/rubygems/commands/check_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/validator' @@ -21,25 +27,10 @@ class Gem::Commands::CheckCommand < Gem::Command options[:alien] = true end - add_option('-v', '--verbose', "Spew more words") do |value, options| - options[:verbose] = true - end - - add_option('-t', '--test', "Run unit tests for gem") do |value, options| - options[:test] = true - end - - add_version_option 'run tests for' + add_version_option 'check' end def execute - if options[:test] - version = options[:version] || Gem::Requirement.default - dep = Gem::Dependency.new get_one_gem_name, version - gem_spec = Gem::SourceIndex.from_installed_gems.search(dep).first - Gem::Validator.new.unit_test(gem_spec) - end - if options[:alien] say "Performing the 'alien' operation" say @@ -52,7 +43,7 @@ class Gem::Commands::CheckCommand < Gem::Command say " #{error_entry.problem}" end else - say "#{key} is error-free" if options[:verbose] + say "#{key} is error-free" if Gem.configuration.verbose end say end diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb index 1b6e405782..0cdf50433e 100644 --- a/lib/rubygems/commands/cleanup_command.rb +++ b/lib/rubygems/commands/cleanup_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/source_index' require 'rubygems/dependency_list' @@ -8,7 +14,7 @@ class Gem::Commands::CleanupCommand < Gem::Command def initialize super 'cleanup', 'Clean up old versions of installed gems in the local repository', - :force => false, :test => false, :install_dir => Gem.dir + :force => false, :install_dir => Gem.dir add_option('-d', '--dryrun', "") do |value, options| options[:dryrun] = true diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index a49918689c..42ae913b01 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/version_option' diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb index 649e3c2d2d..98d6b42893 100644 --- a/lib/rubygems/commands/dependency_command.rb +++ b/lib/rubygems/commands/dependency_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/version_option' @@ -76,25 +82,13 @@ class Gem::Commands::DependencyCommand < Gem::Command if remote? and not options[:reverse_dependencies] then fetcher = Gem::SpecFetcher.fetcher - begin - specs_and_sources = fetcher.find_matching(dependency, false, true, - dependency.prerelease?) - - specs_and_sources.each do |spec_tuple, source_uri| - spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri) - - source_indexes[source_uri].add_spec spec - end - rescue Gem::RemoteFetcher::FetchError => e - raise unless fetcher.warn_legacy e do - require 'rubygems/source_info_cache' + specs_and_sources = fetcher.find_matching(dependency, false, true, + dependency.prerelease?) - specs = Gem::SourceInfoCache.search_with_source dependency, false + specs_and_sources.each do |spec_tuple, source_uri| + spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri) - specs.each do |spec, source_uri| - source_indexes[source_uri].add_spec spec - end - end + source_indexes[source_uri].add_spec spec end end diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb index a8284b4bf6..f8de984547 100644 --- a/lib/rubygems/commands/environment_command.rb +++ b/lib/rubygems/commands/environment_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' class Gem::Commands::EnvironmentCommand < Gem::Command @@ -13,6 +19,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command gempath display path used to search for gems version display the gem format version remotesources display the remote gem servers + platform display the supporte gem platforms display everything EOF return args.gsub(/^\s+/, '') @@ -32,8 +39,6 @@ is a YAML file with the following YAML keys: levels :update_sources: Enable/disable automatic updating of repository metadata :backtrace: Print backtrace when RubyGems encounters an error - :bulk_threshold: Switch to a bulk update when this many sources are out of - date (legacy setting) :gempath: The paths in which to look for gems gem_command: A string containing arguments for the specified gem command @@ -76,6 +81,8 @@ lib/rubygems/defaults/operating_system.rb out << Gem.path.join(File::PATH_SEPARATOR) when /^remotesources/ then out << Gem.sources.join("\n") + when /^platform/ then + out << Gem.platforms.join(File::PATH_SEPARATOR) when nil then out = "RubyGems Environment:\n" diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb index 43229c0512..a95f1e4fb6 100644 --- a/lib/rubygems/commands/fetch_command.rb +++ b/lib/rubygems/commands/fetch_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/version_option' @@ -52,7 +58,7 @@ class Gem::Commands::FetchCommand < Gem::Command spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last if spec.nil? then - show_lookup_failure gem_name, version, errors + show_lookup_failure gem_name, version, errors, options[:domain] next end diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb index 945d32383c..bd074fd5ec 100644 --- a/lib/rubygems/commands/generate_index_command.rb +++ b/lib/rubygems/commands/generate_index_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/indexer' @@ -19,8 +25,7 @@ class Gem::Commands::GenerateIndexCommand < Gem::Command end add_option '--[no-]legacy', - 'Generate indexes for RubyGems older than', - '1.2.0' do |value, options| + 'Generate Marshal.4.8' do |value, options| unless options[:build_modern] or value then raise OptionParser::InvalidOption, 'no indicies will be built' end @@ -87,20 +92,12 @@ When done, it will generate a set of files like this: quick/Marshal./.gemspec.rz # Marshal quick index file # these files support legacy RubyGems - quick/index - quick/index.rz # quick index manifest - quick/.gemspec.rz # legacy YAML quick index - # file Marshal. Marshal..Z # Marshal full index - yaml - yaml.Z # legacy YAML full index The .Z and .rz extension files are compressed with the inflate algorithm. The Marshal version number comes from ruby's Marshal::MAJOR_VERSION and Marshal::MINOR_VERSION constants. It is used to ensure compatibility. -The yaml indexes exist for legacy RubyGems clients and fallback in case of -Marshal version changes. If --rss-host and --rss-gem-host are given an RSS feed will be generated at index.rss containing gems released in the last two days. diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb index 0c4a4ec16f..16921ead37 100644 --- a/lib/rubygems/commands/help_command.rb +++ b/lib/rubygems/commands/help_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' class Gem::Commands::HelpCommand < Gem::Command @@ -14,11 +20,6 @@ Some examples of 'gem' usage. gem install rake --remote -* Install 'rake' from remote server, and run unit tests, - and generate RDocs: - - gem install --remote rake --test --rdoc --ri - * Install 'rake', but only version 0.3.1, even if dependencies are not met, and into a user-specific directory: diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 06a89eeb0a..530f746e89 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/doc_manager' require 'rubygems/install_update_options' @@ -22,7 +28,6 @@ class Gem::Commands::InstallCommand < Gem::Command :generate_rdoc => true, :generate_ri => true, :format_executable => false, - :test => false, :version => Gem::Requirement.default, }) @@ -41,7 +46,7 @@ class Gem::Commands::InstallCommand < Gem::Command def defaults_str # :nodoc: "--both --version '#{Gem::Requirement.default}' --rdoc --ri --no-force\n" \ - "--no-test --install-dir #{Gem.dir}" + "--install-dir #{Gem.dir}" end def description # :nodoc: @@ -115,6 +120,8 @@ to write the specification by hand. For example: get_all_gem_names.each do |gem_name| begin + next if options[:conservative] && Gem.available?(gem_name, options[:version]) + inst = Gem::DependencyInstaller.new options inst.install gem_name, options[:version] @@ -127,7 +134,7 @@ to write the specification by hand. For example: alert_error "Error installing #{gem_name}:\n\t#{e.message}" exit_code |= 1 rescue Gem::GemNotFoundException => e - show_lookup_failure e.name, e.version, e.errors + show_lookup_failure e.name, e.version, e.errors, options[:domain] exit_code |= 2 end @@ -154,19 +161,6 @@ to write the specification by hand. For example: Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc end end - - if options[:test] then - installed_gems.each do |spec| - gem_spec = Gem::SourceIndex.from_installed_gems.find_name(spec.name, spec.version.version).first - result = Gem::Validator.new.unit_test(gem_spec) - if result and not result.passed? - unless ask_yes_no("...keep Gem?", true) - require 'rubygems/uninstaller' - Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall - end - end - end - end end raise Gem::SystemExitException, exit_code diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb index f3e5da9551..267c20f432 100644 --- a/lib/rubygems/commands/list_command.rb +++ b/lib/rubygems/commands/list_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/commands/query_command' diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb index 5a43978dd9..a17dd36d7a 100644 --- a/lib/rubygems/commands/lock_command.rb +++ b/lib/rubygems/commands/lock_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' class Gem::Commands::LockCommand < Gem::Command @@ -75,7 +81,7 @@ lock it down to the exact version. until pending.empty? do full_name = pending.shift - spec = Gem::SourceIndex.load_specification spec_path(full_name) + spec = Gem::Specification.load spec_path(full_name) if spec.nil? then complain "Could not find gem #{full_name}, try using the full name" diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb deleted file mode 100644 index 7cb8583326..0000000000 --- a/lib/rubygems/commands/mirror_command.rb +++ /dev/null @@ -1,111 +0,0 @@ -require 'yaml' -require 'zlib' - -require 'rubygems/command' -require 'open-uri' - -class Gem::Commands::MirrorCommand < Gem::Command - - def initialize - super 'mirror', 'Mirror a gem repository' - end - - def description # :nodoc: - <<-EOF -The mirror command uses the ~/.gemmirrorrc config file to mirror remote gem -repositories to a local path. The config file is a YAML document that looks -like this: - - --- - - from: http://gems.example.com # source repository URI - to: /path/to/mirror # destination directory - -Multiple sources and destinations may be specified. - EOF - end - - def execute - config_file = File.join Gem.user_home, '.gemmirrorrc' - - raise "Config file #{config_file} not found" unless File.exist? config_file - - mirrors = YAML.load_file config_file - - raise "Invalid config file #{config_file}" unless mirrors.respond_to? :each - - mirrors.each do |mir| - raise "mirror missing 'from' field" unless mir.has_key? 'from' - raise "mirror missing 'to' field" unless mir.has_key? 'to' - - get_from = mir['from'] - save_to = File.expand_path mir['to'] - - raise "Directory not found: #{save_to}" unless File.exist? save_to - raise "Not a directory: #{save_to}" unless File.directory? save_to - - gems_dir = File.join save_to, "gems" - - if File.exist? gems_dir then - raise "Not a directory: #{gems_dir}" unless File.directory? gems_dir - else - Dir.mkdir gems_dir - end - - source_index_data = '' - - say "fetching: #{get_from}/Marshal.#{Gem.marshal_version}.Z" - - get_from = URI.parse get_from - - if get_from.scheme.nil? then - get_from = get_from.to_s - elsif get_from.scheme == 'file' then - # check if specified URI contains a drive letter (file:/D:/Temp) - get_from = get_from.to_s - get_from = if get_from =~ /^file:.*[a-z]:/i then - get_from[6..-1] - else - get_from[5..-1] - end - end - - open File.join(get_from.to_s, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y| - source_index_data = Zlib::Inflate.inflate y.read - open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out| - out.write source_index_data - end - end - - source_index = Marshal.load source_index_data - - progress = ui.progress_reporter source_index.size, - "Fetching #{source_index.size} gems" - source_index.each do |fullname, gem| - gem_file = gem.file_name - gem_dest = File.join gems_dir, gem_file - - unless File.exist? gem_dest then - begin - open "#{get_from}/gems/#{gem_file}", "rb" do |g| - contents = g.read - open gem_dest, "wb" do |out| - out.write contents - end - end - rescue - old_gf = gem_file - gem_file = gem_file.downcase - retry if old_gf != gem_file - alert_error $! - end - end - - progress.updated gem_file - end - - progress.done - end - end - -end - diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb index 9e054f988c..0a9a87060e 100644 --- a/lib/rubygems/commands/outdated_command.rb +++ b/lib/rubygems/commands/outdated_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/spec_fetcher' diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index e88734e8fb..8b770e6f54 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/gemcutter_utilities' diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index ef11129d2c..64ea8ce91c 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -1,4 +1,9 @@ -require 'fileutils' +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/format' require 'rubygems/installer' diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index cabcd3d94d..e72b74ebbf 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/gemcutter_utilities' @@ -21,6 +27,13 @@ class Gem::Commands::PushCommand < Gem::Command def initialize super 'push', description add_proxy_option + + add_option( + '--host HOST', + 'Push to another gemcutter-compatible host' + ) do |value, options| + options[:host] = value + end end def execute @@ -29,9 +42,13 @@ class Gem::Commands::PushCommand < Gem::Command end def send_gem name - say "Pushing gem to RubyGems.org..." + say "Pushing gem to #{options[:host] || Gem.host}..." + + args = [:post, "api/v1/gems"] + + args << options[:host] if options[:host] - response = rubygems_api_request :post, "api/v1/gems" do |request| + response = rubygems_api_request(*args) do |request| request.body = Gem.read_binary name request.add_field "Content-Length", request.body.size request.add_field "Content-Type", "application/octet-stream" diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb index 65258fd1ac..29e53065e7 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/spec_fetcher' @@ -108,31 +114,11 @@ class Gem::Commands::QueryCommand < Gem::Command all = options[:all] - begin - fetcher = Gem::SpecFetcher.fetcher - spec_tuples = fetcher.find_matching dep, all, false, prerelease - - spec_tuples += fetcher.find_matching dep, false, false, true if - prerelease and all - rescue Gem::RemoteFetcher::FetchError => e - if prerelease then - raise Gem::OperationNotSupportedError, - "Prereleases not supported on legacy repositories" - end - - raise unless fetcher.warn_legacy e do - require 'rubygems/source_info_cache' - - dep.name = '' if dep.name == // + fetcher = Gem::SpecFetcher.fetcher + spec_tuples = fetcher.find_matching dep, all, false, prerelease - specs = Gem::SourceInfoCache.search_with_source dep, false, all - - spec_tuples = specs.map do |spec, source_uri| - [[spec.name, spec.version, spec.original_platform, spec], - source_uri] - end - end - end + spec_tuples += fetcher.find_matching dep, false, false, true if + prerelease and all output_query_results spec_tuples end diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb index ea0f3ad592..d7912fd279 100644 --- a/lib/rubygems/commands/rdoc_command.rb +++ b/lib/rubygems/commands/rdoc_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/doc_manager' diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb index 52e96fd1ef..1d1c194dac 100644 --- a/lib/rubygems/commands/search_command.rb +++ b/lib/rubygems/commands/search_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/commands/query_command' diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb index 1760700e27..0d18a82201 100644 --- a/lib/rubygems/commands/server_command.rb +++ b/lib/rubygems/commands/server_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/server' @@ -43,6 +49,14 @@ class Gem::Commands::ServerCommand < Gem::Command options[:addresses] ||= [] options[:addresses].push(*address) end + + add_option '-l', '--launch[=COMMAND]', + 'launches a browser window', + "COMMAND defaults to 'start' on Windows", + "and 'open' on all other platforms" do |launch, options| + launch ||= Gem.win_platform? ? 'start' : 'open' + options[:launch] = launch + end end def defaults_str # :nodoc: diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 4bc115eaf8..288be22f31 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -1,7 +1,10 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' -require 'fileutils' -require 'rbconfig' -require 'tmpdir' ## # Installs RubyGems itself. This command is ordinarily only available from a @@ -10,6 +13,8 @@ require 'tmpdir' class Gem::Commands::SetupCommand < Gem::Command def initialize + require 'tmpdir' + super 'setup', 'Install RubyGems', :format_executable => true, :rdoc => true, :ri => true, :site_or_vendor => :sitelibdir, @@ -98,6 +103,7 @@ By default, this RubyGems will install gem as: check_ruby_version + require 'fileutils' if Gem.configuration.really_verbose then extend FileUtils::Verbose else diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb index 245ab91c9f..571e664272 100644 --- a/lib/rubygems/commands/sources_command.rb +++ b/lib/rubygems/commands/sources_command.rb @@ -1,4 +1,9 @@ -require 'fileutils' +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/remote_fetcher' require 'rubygems/source_info_cache' @@ -10,6 +15,8 @@ class Gem::Commands::SourcesCommand < Gem::Command include Gem::LocalRemoteOptions def initialize + require 'fileutils' + super 'sources', 'Manage the sources and cache file RubyGems uses to search for gems' @@ -79,23 +86,7 @@ class Gem::Commands::SourcesCommand < Gem::Command rescue URI::Error, ArgumentError say "#{source_uri} is not a URI" rescue Gem::RemoteFetcher::FetchError => e - yaml_uri = uri + 'yaml' - gem_repo = Gem::RemoteFetcher.fetcher.fetch_size yaml_uri rescue false - - if e.uri =~ /specs\.#{Regexp.escape Gem.marshal_version}\.gz$/ and - gem_repo then - - alert_warning <<-EOF -RubyGems 1.2+ index not found for: -\t#{source_uri} - -Will cause RubyGems to revert to legacy indexes, degrading performance. - EOF - - say "#{source_uri} added to sources" - else - say "Error fetching #{source_uri}:\n\t#{e.message}" - end + say "Error fetching #{source_uri}:\n\t#{e.message}" end end @@ -115,15 +106,10 @@ Will cause RubyGems to revert to legacy indexes, degrading performance. if options[:update] then fetcher = Gem::SpecFetcher.fetcher - if fetcher.legacy_repos.empty? then - Gem.sources.each do |update_uri| - update_uri = URI.parse update_uri - fetcher.load_specs update_uri, 'specs' - fetcher.load_specs update_uri, 'latest_specs' - end - else - Gem::SourceInfoCache.cache true - Gem::SourceInfoCache.cache.flush + Gem.sources.each do |update_uri| + update_uri = URI.parse update_uri + fetcher.load_specs update_uri, 'specs' + fetcher.load_specs update_uri, 'latest_specs' end say "source cache successfully updated" diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb index 07d2c2cf0d..dd2f6bd4da 100644 --- a/lib/rubygems/commands/specification_command.rb +++ b/lib/rubygems/commands/specification_command.rb @@ -1,4 +1,9 @@ -require 'yaml' +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/version_option' @@ -11,6 +16,8 @@ class Gem::Commands::SpecificationCommand < Gem::Command include Gem::VersionOption def initialize + Gem.load_yaml + super 'specification', 'Display gem specification (in yaml)', :domain => :local, :version => Gem::Requirement.default, :format => :yaml diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb index 78cbdcc00a..9a024faa6d 100644 --- a/lib/rubygems/commands/stale_command.rb +++ b/lib/rubygems/commands/stale_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' class Gem::Commands::StaleCommand < Gem::Command diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index db6aeed022..52d5b03edb 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/uninstaller' diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb index 8ed99babbe..5e0bc830f2 100644 --- a/lib/rubygems/commands/unpack_command.rb +++ b/lib/rubygems/commands/unpack_command.rb @@ -1,4 +1,9 @@ -require 'fileutils' +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/installer' require 'rubygems/version_option' @@ -8,6 +13,8 @@ class Gem::Commands::UnpackCommand < Gem::Command include Gem::VersionOption def initialize + require 'fileutils' + super 'unpack', 'Unpack an installed gem to the current directory', :version => Gem::Requirement.default, :target => Dir.pwd diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index 2e6f11949a..b2f69a5b52 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/command_manager' require 'rubygems/install_update_options' @@ -17,8 +23,7 @@ class Gem::Commands::UpdateCommand < Gem::Command 'Update the named gems (or all installed gems) in the local repository', :generate_rdoc => true, :generate_ri => true, - :force => false, - :test => false + :force => false add_install_update_options @@ -37,7 +42,7 @@ class Gem::Commands::UpdateCommand < Gem::Command end def defaults_str # :nodoc: - "--rdoc --ri --no-force --no-test --install-dir #{Gem.dir}" + "--rdoc --ri --no-force --install-dir #{Gem.dir}" end def usage # :nodoc: @@ -60,6 +65,19 @@ class Gem::Commands::UpdateCommand < Gem::Command hig['rubygems-update'] = rubygems_update options[:user_install] = false + + Gem.source_index.refresh! + + update_gems = Gem.source_index.find_name 'rubygems-update' + + latest_update_gem = update_gems.sort_by { |s| s.version }.last + + say "Updating RubyGems to #{latest_update_gem.version}" + installed = do_rubygems_update latest_update_gem.version + + say "RubyGems system software updated" if installed + + return else say "Updating installed gems" @@ -97,35 +115,22 @@ class Gem::Commands::UpdateCommand < Gem::Command end end - if gems_to_update.include? "rubygems-update" then - Gem.source_index.refresh! - - update_gems = Gem.source_index.find_name 'rubygems-update' - - latest_update_gem = update_gems.sort_by { |s| s.version }.last - - say "Updating RubyGems to #{latest_update_gem.version}" - installed = do_rubygems_update latest_update_gem.version - - say "RubyGems system software updated" if installed + if updated.empty? then + say "Nothing to update" else - if updated.empty? then - say "Nothing to update" - else - say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}" - - if options[:generate_ri] then - updated.each do |gem| - Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri - end + say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}" - Gem::DocManager.update_ri_cache + if options[:generate_ri] then + updated.each do |gem| + Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri end - if options[:generate_rdoc] then - updated.each do |gem| - Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc - end + Gem::DocManager.update_ri_cache + end + + if options[:generate_rdoc] then + updated.each do |gem| + Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc end end end @@ -164,22 +169,8 @@ class Gem::Commands::UpdateCommand < Gem::Command dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}" - begin - fetcher = Gem::SpecFetcher.fetcher - spec_tuples = fetcher.find_matching dependency - rescue Gem::RemoteFetcher::FetchError => e - raise unless fetcher.warn_legacy e do - require 'rubygems/source_info_cache' - - dependency.name = '' if dependency.name == // - - specs = Gem::SourceInfoCache.search_with_source dependency - - spec_tuples = specs.map do |spec, source_uri| - [[spec.name, spec.version, spec.original_platform], source_uri] - end - end - end + fetcher = Gem::SpecFetcher.fetcher + spec_tuples = fetcher.find_matching dependency matching_gems = spec_tuples.select do |(name, _, platform),| name == l_name and Gem::Platform.match platform diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb index b785f15660..aeb91f203c 100644 --- a/lib/rubygems/commands/which_command.rb +++ b/lib/rubygems/commands/which_command.rb @@ -1,3 +1,9 @@ +###################################################################### +# This file is imported from the rubygems project. +# DO NOT make modifications in this repo. They _will_ be reverted! +# File a patch instead and assign it to Ryan Davis or Eric Hodel. +###################################################################### + require 'rubygems/command' require 'rubygems/gem_path_searcher' @@ -33,6 +39,7 @@ class Gem::Commands::WhichCommand < Gem::Command found = false options[:args].each do |arg| + arg = arg.sub(/#{Regexp.union(*EXT)}$/, '') dirs = $LOAD_PATH spec = searcher.find arg -- cgit v1.2.3