summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-25 10:13:50 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-25 10:13:50 +0000
commitd478c7a7342478847cc1148f4134b5f0db04e1d9 (patch)
tree3bfca425683a94d1360ecdf5857d741b8eaac213 /lib/rubygems/commands
parent788001a9c8473130bd357846785838045387b060 (diff)
Update to RubyGems 1.3.0 r1891
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r--lib/rubygems/commands/contents_command.rb2
-rw-r--r--lib/rubygems/commands/environment_command.rb40
-rw-r--r--lib/rubygems/commands/help_command.rb4
-rw-r--r--lib/rubygems/commands/install_command.rb15
-rw-r--r--lib/rubygems/commands/lock_command.rb21
-rw-r--r--lib/rubygems/commands/outdated_command.rb2
-rw-r--r--lib/rubygems/commands/pristine_command.rb2
-rw-r--r--lib/rubygems/commands/query_command.rb23
-rw-r--r--lib/rubygems/commands/rdoc_command.rb6
-rw-r--r--lib/rubygems/commands/specification_command.rb4
-rw-r--r--lib/rubygems/commands/unpack_command.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb37
-rw-r--r--lib/rubygems/commands/which_command.rb7
13 files changed, 124 insertions, 41 deletions
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 5060403fd82..bc75fb5c03b 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -51,7 +51,7 @@ class Gem::Commands::ContentsCommand < Gem::Command
si = Gem::SourceIndex.from_gems_in(*s)
- gem_spec = si.search(/\A#{gem}\z/, version).last
+ gem_spec = si.find_name(gem, version).last
unless gem_spec then
say "Unable to find gem '#{gem}' in #{path_kind}"
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index a67c00bfd6f..e672da54f02 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -18,6 +18,46 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
return args.gsub(/^\s+/, '')
end
+ def description # :nodoc:
+ <<-EOF
+The RubyGems environment can be controlled through command line arguments,
+gemrc files, environment variables and built-in defaults.
+
+Command line argument defaults and some RubyGems defaults can be set in
+~/.gemrc file for individual users and a /etc/gemrc for all users. A gemrc
+is a YAML file with the following YAML keys:
+
+ :sources: A YAML array of remote gem repositories to install gems from
+ :verbose: Verbosity of the gem command. false, true, and :really are the
+ 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
+
+Example:
+
+ :verbose: false
+ install: --no-wrappers
+ update: --no-wrappers
+
+RubyGems' default local repository can be overriden with the GEM_PATH and
+GEM_HOME environment variables. GEM_HOME sets the default repository to
+install into. GEM_PATH allows multiple local repositories to be searched for
+gems.
+
+If you are behind a proxy server, RubyGems uses the HTTP_PROXY,
+HTTP_PROXY_USER and HTTP_PROXY_PASS environment variables to discover the
+proxy server.
+
+If you are packaging RubyGems all of RubyGems' defaults are in
+lib/rubygems/defaults.rb. You may override these in
+lib/rubygems/defaults/operating_system.rb
+ EOF
+ end
+
def usage # :nodoc:
"#{program_name} [arg]"
end
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 05ea3f7a717..0c4a4ec16f0 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -20,9 +20,9 @@ Some examples of 'gem' usage.
gem install --remote rake --test --rdoc --ri
* Install 'rake', but only version 0.3.1, even if dependencies
- are not met, and into a specific directory:
+ are not met, and into a user-specific directory:
- gem install rake --version 0.3.1 --force --install-dir $HOME/.gems
+ gem install rake --version 0.3.1 --force --user-install
* List local gems whose name begins with 'D':
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 923d578a151..1a6eb68a8ba 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -38,6 +38,19 @@ class Gem::Commands::InstallCommand < Gem::Command
"--no-test --install-dir #{Gem.dir}"
end
+ def description # :nodoc:
+ <<-EOF
+The install command installs local or remote gem into a gem repository.
+
+For gems with executables ruby installs a wrapper file into the executable
+directory by deault. This can be overridden with the --no-wrappers option.
+The wrapper allows you to choose among alternate gem versions using _version_.
+
+For example `rake _0.7.3_ --version` will run rake version 0.7.3 if a newer
+version is also installed.
+ EOF
+ end
+
def usage # :nodoc:
"#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags"
end
@@ -106,6 +119,8 @@ class Gem::Commands::InstallCommand < Gem::Command
installed_gems.each do |gem|
Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
end
+
+ Gem::DocManager.update_ri_cache
end
if options[:generate_rdoc] then
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
index 6be2774e926..5a43978dd94 100644
--- a/lib/rubygems/commands/lock_command.rb
+++ b/lib/rubygems/commands/lock_command.rb
@@ -58,15 +58,15 @@ lock it down to the exact version.
end
def complain(message)
- if options.strict then
- raise message
+ if options[:strict] then
+ raise Gem::Exception, message
else
say "# #{message}"
end
end
def execute
- say 'require "rubygems"'
+ say "require 'rubygems'"
locked = {}
@@ -77,15 +77,20 @@ lock it down to the exact version.
spec = Gem::SourceIndex.load_specification spec_path(full_name)
+ if spec.nil? then
+ complain "Could not find gem #{full_name}, try using the full name"
+ next
+ end
+
say "gem '#{spec.name}', '= #{spec.version}'" unless locked[spec.name]
locked[spec.name] = true
spec.runtime_dependencies.each do |dep|
next if locked[dep.name]
- candidates = Gem.source_index.search dep.name, dep.requirement_list
+ candidates = Gem.source_index.search dep
if candidates.empty? then
- complain "Unable to satisfy '#{dep}' from currently installed gems."
+ complain "Unable to satisfy '#{dep}' from currently installed gems"
else
pending << candidates.last.full_name
end
@@ -94,7 +99,11 @@ lock it down to the exact version.
end
def spec_path(gem_full_name)
- File.join Gem.path, "specifications", "#{gem_full_name }.gemspec"
+ gemspecs = Gem.path.map do |path|
+ File.join path, "specifications", "#{gem_full_name}.gemspec"
+ end
+
+ gemspecs.find { |gemspec| File.exist? gemspec }
end
end
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb
index 1cd1087dd1b..9e054f988cf 100644
--- a/lib/rubygems/commands/outdated_command.rb
+++ b/lib/rubygems/commands/outdated_command.rb
@@ -19,7 +19,7 @@ class Gem::Commands::OutdatedCommand < Gem::Command
locals = Gem::SourceIndex.from_installed_gems
locals.outdated.sort.each do |name|
- local = locals.search(/^#{name}$/).last
+ local = locals.find_name(name).last
dep = Gem::Dependency.new local.name, ">= #{local.version}"
remotes = Gem::SpecFetcher.fetcher.fetch dep
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 3e55a1bb308..d47fe54edd6 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -57,7 +57,7 @@ revert the gem.
end
else
gem_name = get_one_gem_name
- Gem::SourceIndex.from_installed_gems.search(gem_name,
+ Gem::SourceIndex.from_installed_gems.find_name(gem_name,
options[:version])
end
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index f4d6120bcd0..29fe8acb796 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -59,7 +59,7 @@ class Gem::Commands::QueryCommand < Gem::Command
if name.source.empty? then
alert_error "You must specify a gem name"
exit_code |= 4
- elsif installed? name.source, options[:version] then
+ elsif installed? name, options[:version] then
say "true"
else
say "false"
@@ -69,12 +69,16 @@ class Gem::Commands::QueryCommand < Gem::Command
raise Gem::SystemExitException, exit_code
end
+ dep = Gem::Dependency.new name, Gem::Requirement.default
+
if local? then
- say
- say "*** LOCAL GEMS ***"
- say
+ if ui.outs.tty? or both? then
+ say
+ say "*** LOCAL GEMS ***"
+ say
+ end
- specs = Gem.source_index.search name
+ specs = Gem.source_index.search dep
spec_tuples = specs.map do |spec|
[[spec.name, spec.version, spec.original_platform, spec], :local]
@@ -84,13 +88,14 @@ class Gem::Commands::QueryCommand < Gem::Command
end
if remote? then
- say
- say "*** REMOTE GEMS ***"
- say
+ if ui.outs.tty? or both? then
+ say
+ say "*** REMOTE GEMS ***"
+ say
+ end
all = options[:all]
- dep = Gem::Dependency.new name, Gem::Requirement.default
begin
fetcher = Gem::SpecFetcher.fetcher
spec_tuples = fetcher.find_matching dep, all, false
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index f2e677c1159..82180d485c6 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -59,11 +59,15 @@ module Gem
if specs.empty?
fail "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
end
+
if options[:include_ri]
specs.each do |spec|
Gem::DocManager.new(spec).generate_ri
end
+
+ Gem::DocManager.update_ri_cache
end
+
if options[:include_rdoc]
specs.each do |spec|
Gem::DocManager.new(spec).generate_rdoc
@@ -73,6 +77,6 @@ module Gem
true
end
end
-
+
end
end
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 689f2560c99..5aaf6d17973 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -40,6 +40,7 @@ class Gem::Commands::SpecificationCommand < Gem::Command
def execute
specs = []
gem = get_one_gem_name
+ dep = Gem::Dependency.new gem, options[:version]
if local? then
if File.exist? gem then
@@ -47,12 +48,11 @@ class Gem::Commands::SpecificationCommand < Gem::Command
end
if specs.empty? then
- specs.push(*Gem.source_index.search(/\A#{gem}\z/, options[:version]))
+ specs.push(*Gem.source_index.search(dep))
end
end
if remote? then
- dep = Gem::Dependency.new gem, options[:version]
found = Gem::SpecFetcher.fetcher.fetch dep
specs.push(*found.map { |spec,| spec })
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index d187f8a9ea4..ef9436ae34c 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -68,7 +68,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
def get_path(gemname, version_req)
return gemname if gemname =~ /\.gem$/i
- specs = Gem::source_index.search(/\A#{gemname}\z/, version_req)
+ specs = Gem::source_index.find_name gemname, version_req
selected = specs.sort_by { |s| s.version }.last
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 78baa8ba565..4490f385dc1 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -45,6 +45,8 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
def execute
+ hig = {}
+
if options[:system] then
say "Updating RubyGems"
@@ -52,16 +54,22 @@ class Gem::Commands::UpdateCommand < Gem::Command
fail "No gem names are allowed with the --system option"
end
- options[:args] = ["rubygems-update"]
+ spec = Gem::Specification.new
+ spec.name = 'rubygems-update'
+ spec.version = Gem::Version.new Gem::RubyGemsVersion
+ spec.version = Gem::Version.new '1.1.1'
+ hig['rubygems-update'] = spec
+
+ options[:user_install] = false
else
say "Updating installed gems"
- end
- hig = {} # highest installed gems
+ hig = {} # highest installed gems
- Gem.source_index.each do |name, spec|
- if hig[spec.name].nil? or hig[spec.name].version < spec.version then
- hig[spec.name] = spec
+ Gem.source_index.each do |name, spec|
+ if hig[spec.name].nil? or hig[spec.name].version < spec.version then
+ hig[spec.name] = spec
+ end
end
end
@@ -84,14 +92,14 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
if gems_to_update.include? "rubygems-update" then
- latest_ruby_gem = remote_gemspecs.select do |s|
- s.name == 'rubygems-update'
- end
+ Gem.source_index.refresh!
+
+ update_gems = Gem.source_index.search 'rubygems-update'
- latest_ruby_gem = latest_ruby_gem.sort_by { |s| s.version }.last
+ latest_update_gem = update_gems.sort_by { |s| s.version }.last
- say "Updating version of RubyGems to #{latest_ruby_gem.version}"
- installed = do_rubygems_update latest_ruby_gem.version
+ say "Updating RubyGems to #{latest_update_gem.version}"
+ installed = do_rubygems_update latest_update_gem.version
say "RubyGems system software updated" if installed
else
@@ -103,6 +111,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
end
+ ##
+ # Update the RubyGems software to +version+.
+
def do_rubygems_update(version)
args = []
args.push '--prefix', Gem.prefix unless Gem.prefix.nil?
@@ -112,8 +123,6 @@ class Gem::Commands::UpdateCommand < Gem::Command
update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
- success = false
-
Dir.chdir update_dir do
say "Installing RubyGems #{version}"
setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index b42244ce7d3..2267e44b119 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -3,10 +3,10 @@ require 'rubygems/gem_path_searcher'
class Gem::Commands::WhichCommand < Gem::Command
- EXT = %w[.rb .rbw .so .dll] # HACK
+ EXT = %w[.rb .rbw .so .dll .bundle] # HACK
def initialize
- super 'which', 'Find the location of a library',
+ super 'which', 'Find the location of a library file you can require',
:search_gems_first => false, :show_all => false
add_option '-a', '--[no-]all', 'show all matching files' do |show_all, options|
@@ -52,7 +52,7 @@ class Gem::Commands::WhichCommand < Gem::Command
paths = find_paths arg, dirs
if paths.empty? then
- say "Can't find #{arg}"
+ say "Can't find ruby library file or shared library #{arg}"
else
say paths
end
@@ -84,3 +84,4 @@ class Gem::Commands::WhichCommand < Gem::Command
end
end
+