diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-09 22:32:29 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-09 22:32:29 +0000 |
commit | 6e5f49770c9b9be151e3142a575abe99a69b0d14 (patch) | |
tree | 15495cf2652a8a3d2010ace89b0813e8589341bd /lib/rubygems | |
parent | 08c07a215d3d4b5e26293d9d52bc06b486f15844 (diff) | |
download | ruby-6e5f49770c9b9be151e3142a575abe99a69b0d14.tar.gz |
Import rubygems 1.6.2 (release candidate @ 2026fbb5)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/commands/outdated_command.rb | 9 | ||||
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/custom_require.rb | 34 | ||||
-rw-r--r-- | lib/rubygems/dependency_installer.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/dependency_list.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/doc_manager.rb | 1 | ||||
-rw-r--r-- | lib/rubygems/gem_path_searcher.rb | 8 | ||||
-rw-r--r-- | lib/rubygems/gemcutter_utilities.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/indexer.rb | 1 | ||||
-rw-r--r-- | lib/rubygems/mock_gem_ui.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/spec_fetcher.rb | 13 | ||||
-rw-r--r-- | lib/rubygems/test_case.rb | 1 | ||||
-rw-r--r-- | lib/rubygems/user_interaction.rb | 35 |
13 files changed, 82 insertions, 32 deletions
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb index 0a9a87060e..7b6e1cfe8e 100644 --- a/lib/rubygems/commands/outdated_command.rb +++ b/lib/rubygems/commands/outdated_command.rb @@ -25,12 +25,13 @@ class Gem::Commands::OutdatedCommand < Gem::Command locals = Gem::SourceIndex.from_installed_gems locals.outdated.sort.each do |name| - local = locals.find_name(name).last - - dep = Gem::Dependency.new local.name, ">= #{local.version}" + local = locals.find_name(name).last + dep = Gem::Dependency.new local.name, ">= #{local.version}" remotes = Gem::SpecFetcher.fetcher.fetch dep - remote = remotes.last.first + next if remotes.empty? + + remote = remotes.last.first say "#{local.name} (#{local.version} < #{remote.version})" end end diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 9090353e3b..cf844c6674 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -335,7 +335,7 @@ abort "#{deprecation_message}" require 'rdoc/rdoc' - args << '--main' << 'README.rdoc' + args << '--main' << 'README.rdoc' << '--quiet' args << '.' args << 'README.rdoc' << 'UPGRADING.rdoc' args << 'LICENSE.txt' << 'GPL.txt' << 'History.txt' diff --git a/lib/rubygems/custom_require.rb b/lib/rubygems/custom_require.rb index ebe7b05558..eaa04b31c3 100644 --- a/lib/rubygems/custom_require.rb +++ b/lib/rubygems/custom_require.rb @@ -12,10 +12,16 @@ module Kernel - ## - # The Kernel#require from before RubyGems was loaded. + if defined?(gem_original_require) then + # Ruby ships with a custom_require, override its require + remove_method :require + else + ## + # The Kernel#require from before RubyGems was loaded. - alias gem_original_require require + alias gem_original_require require + private :gem_original_require + end ## # When RubyGems is required, Kernel#require is replaced with our own which @@ -35,15 +41,20 @@ module Kernel if Gem.unresolved_deps.empty? or Gem.loaded_path? path then gem_original_require path else - specs = Gem.searcher.find_in_unresolved path - unless specs.empty? then - specs = [specs.last] - else - specs = Gem.searcher.find_in_unresolved_tree path - end + spec = Gem.searcher.find_active path + + unless spec then + found_specs = Gem.searcher.find_in_unresolved path + unless found_specs.empty? then + found_specs = [found_specs.last] + else + found_specs = Gem.searcher.find_in_unresolved_tree path + end - specs.each do |spec| - Gem.activate spec.name, spec.version # FIX: this is dumb + found_specs.each do |found_spec| + # FIX: this is dumb, activate a spec instead of name/version + Gem.activate found_spec.name, found_spec.version + end end return gem_original_require path @@ -57,7 +68,6 @@ module Kernel end private :require - private :gem_original_require end diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index 46ec63f14f..5afb1bfa0d 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -74,7 +74,7 @@ class Gem::DependencyInstaller @installed_gems = [] @install_dir = options[:install_dir] || Gem.dir - @cache_dir = options[:cache_dir] || Gem.cache_dir(@install_dir) + @cache_dir = options[:cache_dir] || @install_dir # Set with any errors that SpecFetcher finds while search through # gemspecs for a dep diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb index 91c7c5ade4..a3db1d6829 100644 --- a/lib/rubygems/dependency_list.rb +++ b/lib/rubygems/dependency_list.rb @@ -121,7 +121,7 @@ class Gem::DependencyList def why_not_ok? quick = false unsatisfied = Hash.new { |h,k| h[k] = [] } source_index = Gem.source_index - @specs.each do |spec| + each do |spec| spec.runtime_dependencies.each do |dep| inst = source_index.any? { |_, installed_spec| dep.name == installed_spec.name and diff --git a/lib/rubygems/doc_manager.rb b/lib/rubygems/doc_manager.rb index 71c7d850ad..9cfa31a0a0 100644 --- a/lib/rubygems/doc_manager.rb +++ b/lib/rubygems/doc_manager.rb @@ -171,6 +171,7 @@ class Gem::DocManager args << @spec.require_paths.clone args << @spec.extra_rdoc_files args << '--title' << "#{@spec.full_name} Documentation" + args << '--quiet' args = args.flatten.map do |arg| arg.to_s end if self.class.rdoc_version >= Gem::Version.new('2.4.0') then diff --git a/lib/rubygems/gem_path_searcher.rb b/lib/rubygems/gem_path_searcher.rb index 5b85cbc9fb..79c3b0f6c9 100644 --- a/lib/rubygems/gem_path_searcher.rb +++ b/lib/rubygems/gem_path_searcher.rb @@ -56,6 +56,14 @@ class Gem::GemPathSearcher end end + def find_active(glob) + # HACK violation of encapsulation + @gemspecs.find do |spec| + # TODO: inverted responsibility + spec.loaded? and matching_file? spec, glob + end + end + ## # Works like #find, but finds all gemspecs matching +glob+. diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index a77a4911f2..9dce97cc1f 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -15,7 +15,9 @@ module Gem::GemcutterUtilities # Add the --key option def add_key_option - add_option '-k', '--key KEYNAME', Symbol, 'Use the given API key' do |value,options| + add_option('-k', '--key KEYNAME', Symbol, + 'Use the given API key', + 'from ~/.gem/credentials') do |value,options| options[:key] = value end end diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb index 1a585c3c25..6e481c6790 100644 --- a/lib/rubygems/indexer.rb +++ b/lib/rubygems/indexer.rb @@ -6,6 +6,7 @@ require 'rubygems' require 'rubygems/format' +require 'time' begin gem 'builder' diff --git a/lib/rubygems/mock_gem_ui.rb b/lib/rubygems/mock_gem_ui.rb index f45f769b38..4450cc97a6 100644 --- a/lib/rubygems/mock_gem_ui.rb +++ b/lib/rubygems/mock_gem_ui.rb @@ -37,7 +37,7 @@ class Gem::MockGemUi < Gem::StreamUI outs.extend TTY errs.extend TTY - super ins, outs, errs + super ins, outs, errs, true @terminated = false end diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb index ab05c2f9dd..6c71ee63aa 100644 --- a/lib/rubygems/spec_fetcher.rb +++ b/lib/rubygems/spec_fetcher.rb @@ -76,7 +76,8 @@ class Gem::SpecFetcher # Returns the local directory to write +uri+ to. def cache_dir(uri) - escaped_path = uri.path.sub(%r[^/([a-z]):/]i, '/\\1-/') # Correct for windows paths + # Correct for windows paths + escaped_path = uri.path.sub(/^\/([a-z]):\//i, '/\\1-/') File.join @dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path) end @@ -86,8 +87,14 @@ class Gem::SpecFetcher # false, all platforms are returned. If +prerelease+ is true, # prerelease versions are included. - def fetch_with_errors(dependency, all = false, matching_platform = true, prerelease = false) - specs_and_sources, errors = find_matching_with_errors dependency, all, matching_platform, prerelease + def fetch_with_errors(dependency, + all = false, + matching_platform = true, + prerelease = false) + specs_and_sources, errors = find_matching_with_errors(dependency, + all, + matching_platform, + prerelease) ss = specs_and_sources.map do |spec_tuple, source_uri| [fetch_spec(spec_tuple, URI.parse(source_uri)), source_uri] diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 5c32bd2ddb..0f3b892eb1 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -463,7 +463,6 @@ class Gem::TestCase < MiniTest::Unit::TestCase util_build_gem spec cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem" - gems_dir = File.dirname cache_file FileUtils.mkdir_p File.dirname cache_file FileUtils.mv Gem.cache_gem("#{spec.original_name}.gem"), cache_file FileUtils.rm File.join(@gemhome, 'specifications', spec.spec_name) diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb index 538793181e..87d13dab26 100644 --- a/lib/rubygems/user_interaction.rb +++ b/lib/rubygems/user_interaction.rb @@ -138,10 +138,19 @@ class Gem::StreamUI attr_reader :ins, :outs, :errs - def initialize(in_stream, out_stream, err_stream=STDERR) + def initialize(in_stream, out_stream, err_stream=STDERR, usetty=true) @ins = in_stream @outs = out_stream @errs = err_stream + @usetty = usetty + end + + def tty? + if RUBY_PLATFORM =~ /mingw|mswin/ + @usetty + else + @usetty && @ins.tty? + end end ## @@ -173,7 +182,7 @@ class Gem::StreamUI # default. def ask_yes_no(question, default=nil) - unless @ins.tty? then + unless tty? then if default.nil? then raise Gem::OperationNotSupportedError, "Not connected to a tty and no default specified" @@ -209,7 +218,7 @@ class Gem::StreamUI # Ask a question. Returns an answer if connected to a tty, nil otherwise. def ask(question) - return nil if not @ins.tty? + return nil if not tty? @outs.print(question + " ") @outs.flush @@ -224,7 +233,7 @@ class Gem::StreamUI # Ask for a password. Does not echo response to terminal. def ask_for_password(question) - return nil if not @ins.tty? + return nil if not tty? require 'io/console' @@ -240,7 +249,7 @@ class Gem::StreamUI # Ask for a password. Does not echo response to terminal. def ask_for_password(question) - return nil if not @ins.tty? + return nil if not tty? @outs.print(question + " ") @outs.flush @@ -252,6 +261,8 @@ class Gem::StreamUI # Asks for a password that works on windows. Ripped from the Heroku gem. def ask_for_password_on_windows + return nil if not tty? + require "Win32API" char = nil password = '' @@ -273,6 +284,8 @@ class Gem::StreamUI # Asks for a password that works on unix def ask_for_password_on_unix + return nil if not tty? + system "stty -echo" password = @ins.gets password.chomp! if password @@ -333,6 +346,10 @@ class Gem::StreamUI # Return a progress reporter object chosen from the current verbosity. def progress_reporter(*args) + if self.kind_of?(Gem::SilentUI) + return SilentProgressReporter.new(@outs, *args) + end + case Gem.configuration.verbose when nil, false SilentProgressReporter.new(@outs, *args) @@ -435,6 +452,10 @@ class Gem::StreamUI # Return a download reporter object chosen from the current verbosity def download_reporter(*args) + if self.kind_of?(Gem::SilentUI) + return SilentDownloadReporter.new(@outs, *args) + end + case Gem.configuration.verbose when nil, false SilentDownloadReporter.new(@outs, *args) @@ -518,7 +539,7 @@ end class Gem::ConsoleUI < Gem::StreamUI def initialize - super STDIN, STDOUT, STDERR + super STDIN, STDOUT, STDERR, true end end @@ -537,7 +558,7 @@ class Gem::SilentUI < Gem::StreamUI writer = File.open('nul', 'w') end - super reader, writer, writer + super reader, writer, writer, false end def download_reporter(*args) |