diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-13 19:58:57 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-13 19:58:57 +0000 |
commit | 1daa0b113d853bfa57b776cc569939b61ca14292 (patch) | |
tree | f8c4acb08a551820299dff2b13966d6ac38d31e4 /lib/rubygems/commands/install_command.rb | |
parent | 85995e88d49c442b5b113c2676456133e79f5c02 (diff) |
* lib/rubygems: Update to RubyGems 2.1.3
Fixed installing platform gems
Restored concurrent requires
Fixed installing gems with extensions with --install-dir
Fixed `gem fetch -v` to install the latest version
Fixed installing gems with "./" in their files entries
* test/rubygems/test_gem_package.rb: Tests for the above.
* NEWS: Updated for RubyGems 2.1.3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/install_command.rb')
-rw-r--r-- | lib/rubygems/commands/install_command.rb | 126 |
1 files changed, 42 insertions, 84 deletions
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index f02b12906d..0b58fa665e 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -4,6 +4,8 @@ require 'rubygems/dependency_installer' require 'rubygems/local_remote_options' require 'rubygems/validator' require 'rubygems/version_option' +require 'rubygems/install_message' # must come before rdoc for messaging +require 'rubygems/rdoc' ## # Gem installer command line tool @@ -38,12 +40,6 @@ class Gem::Commands::InstallCommand < Gem::Command o[:gemdeps] = v end - add_option(:"Install/Update", '--default', - 'Add the gem\'s full specification to', - 'specifications/default and extract only its bin') do |v,o| - o[:install_as_default] = v - end - @installed_specs = nil end @@ -113,44 +109,7 @@ to write the specification by hand. For example: "#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags" end - def check_install_dir # :nodoc: - if options[:install_dir] and options[:user_install] then - alert_error "Use --install-dir or --user-install but not both" - terminate_interaction 1 - end - end - - def check_version # :nodoc: - if options[:version] != Gem::Requirement.default and - get_all_gem_names.size > 1 then - alert_error "Can't use --version w/ multiple gems. Use name:ver instead." - terminate_interaction 1 - end - end - - def execute - if gf = options[:gemdeps] then - install_from_gemdeps gf - return - end - - @installed_specs = [] - - ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9' - - check_install_dir - check_version - - load_hooks - - exit_code = install_gems - - show_installed - - raise Gem::SystemExitException, exit_code - end - - def install_from_gemdeps gf # :nodoc: + def install_from_gemdeps(gf) require 'rubygems/request_set' rs = Gem::RequestSet.new rs.load_gemdeps gf @@ -172,26 +131,51 @@ to write the specification by hand. For example: raise Gem::SystemExitException, 0 end - def install_gem name, version # :nodoc: - return if options[:conservative] and - not Gem::Dependency.new(name, version).matching_specs.empty? + def execute + if gf = options[:gemdeps] then + install_from_gemdeps gf + return + end - inst = Gem::DependencyInstaller.new options - inst.install name, Gem::Requirement.create(version) + @installed_specs = [] - @installed_specs.push(*inst.installed_gems) + ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9' - show_install_errors inst.errors - end + if options[:install_dir] and options[:user_install] + alert_error "Use --install-dir or --user-install but not both" + terminate_interaction 1 + end - def install_gems # :nodoc: exit_code = 0 + if options[:version] != Gem::Requirement.default && + get_all_gem_names.size > 1 then + alert_error "Can't use --version w/ multiple gems. Use name:ver instead." + terminate_interaction 1 + end + + get_all_gem_names_and_versions.each do |gem_name, gem_version| gem_version ||= options[:version] begin - install_gem gem_name, gem_version + next if options[:conservative] and + not Gem::Dependency.new(gem_name, gem_version).matching_specs.empty? + + inst = Gem::DependencyInstaller.new options + inst.install gem_name, Gem::Requirement.create(gem_version) + + @installed_specs.push(*inst.installed_gems) + + next unless errs = inst.errors + + errs.each do |x| + next unless Gem::SourceFetchProblem === x + + msg = "Unable to pull data from '#{x.source.uri}': #{x.error.message}" + + alert_warning msg + end rescue Gem::InstallError => e alert_error "Error installing #{gem_name}:\n\t#{e.message}" exit_code |= 1 @@ -202,38 +186,12 @@ to write the specification by hand. For example: end end - exit_code - end - - ## - # Loads post-install hooks - - def load_hooks # :nodoc: - if options[:install_as_default] - require 'rubygems/install_default_message' - else - require 'rubygems/install_message' + unless @installed_specs.empty? then + gems = @installed_specs.length == 1 ? 'gem' : 'gems' + say "#{@installed_specs.length} #{gems} installed" end - require 'rubygems/rdoc' - end - - def show_install_errors errors # :nodoc: - return unless errors - errors.each do |x| - return unless Gem::SourceFetchProblem === x - - msg = "Unable to pull data from '#{x.source.uri}': #{x.error.message}" - - alert_warning msg - end - end - - def show_installed # :nodoc: - return if @installed_specs.empty? - - gems = @installed_specs.length == 1 ? 'gem' : 'gems' - say "#{@installed_specs.length} #{gems} installed" + raise Gem::SystemExitException, exit_code end end |