summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/install_command.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/commands/install_command.rb126
1 files changed, 84 insertions, 42 deletions
@@ -4,8 +4,6 @@ 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
@@ -40,6 +38,12 @@ class Gem::Commands::InstallCommand < Gem::Command
o[:gemdeps] = v
end
@installed_specs = nil
end
@@ -109,7 +113,44 @@ to write the specification by hand. For example:
"#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags"
end
- def install_from_gemdeps(gf)
require 'rubygems/request_set'
rs = Gem::RequestSet.new
rs.load_gemdeps gf
@@ -131,51 +172,26 @@ to write the specification by hand. For example:
raise Gem::SystemExitException, 0
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'
- if options[:install_dir] and options[:user_install]
- alert_error "Use --install-dir or --user-install but not both"
- terminate_interaction 1
- end
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
- 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
@@ -186,12 +202,38 @@ to write the specification by hand. For example:
end
end
- unless @installed_specs.empty? then
- gems = @installed_specs.length == 1 ? 'gem' : 'gems'
- say "#{@installed_specs.length} #{gems} installed"
end
- raise Gem::SystemExitException, exit_code
end
end