mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
* lib/rubygems: Update to RubyGems 2.2.0.preview.1
This brings several new features to RubyGems summarized here: https://github.com/rubygems/rubygems/blob/v2.2.0.preview.1/History.txt * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
81629f0531
commit
95683e5cb2
25 changed files with 540 additions and 159 deletions
|
@ -33,13 +33,7 @@ To search for remote gems use the search command.
|
|||
end
|
||||
|
||||
def usage # :nodoc:
|
||||
"#{program_name} [STRING]"
|
||||
end
|
||||
|
||||
def execute
|
||||
string = get_one_optional_argument || ''
|
||||
options[:name] = /^#{string}/i
|
||||
super
|
||||
"#{program_name} [STRING ...]"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -12,6 +12,7 @@ class Gem::Commands::PristineCommand < Gem::Command
|
|||
'Restores installed gems to pristine condition from files located in the gem cache',
|
||||
:version => Gem::Requirement.default,
|
||||
:extensions => true,
|
||||
:extensions_set => false,
|
||||
:all => false
|
||||
|
||||
add_option('--all',
|
||||
|
@ -23,7 +24,8 @@ class Gem::Commands::PristineCommand < Gem::Command
|
|||
add_option('--[no-]extensions',
|
||||
'Restore gems with extensions',
|
||||
'in addition to regular gems') do |value, options|
|
||||
options[:extensions] = value
|
||||
options[:extensions_set] = true
|
||||
options[:extensions] = value
|
||||
end
|
||||
|
||||
add_option('--only-executables',
|
||||
|
@ -62,6 +64,9 @@ If the cached gem cannot be found it will be downloaded.
|
|||
|
||||
If --no-extensions is provided pristine will not attempt to restore a gem
|
||||
with an extension.
|
||||
|
||||
If --extensions is given (but not --all or gem names) only gems with
|
||||
extensions will be restored.
|
||||
EOF
|
||||
end
|
||||
|
||||
|
@ -72,6 +77,14 @@ with an extension.
|
|||
def execute
|
||||
specs = if options[:all] then
|
||||
Gem::Specification.map
|
||||
|
||||
# `--extensions` must be explicitly given to pristine only gems
|
||||
# with extensions.
|
||||
elsif options[:extensions_set] and
|
||||
options[:extensions] and options[:args].empty? then
|
||||
Gem::Specification.select do |spec|
|
||||
spec.extensions and not spec.extensions.empty?
|
||||
end
|
||||
else
|
||||
get_all_gem_names.map do |gem_name|
|
||||
Gem::Specification.find_all_by_name gem_name, options[:version]
|
||||
|
|
|
@ -69,13 +69,18 @@ You can upgrade or downgrade to the latest release version with:
|
|||
terminate_interaction 1
|
||||
end
|
||||
|
||||
gem_data = Gem::Package.new(name)
|
||||
|
||||
unless @host then
|
||||
if gem_data = Gem::Package.new(name) then
|
||||
@host = gem_data.spec.metadata['default_gem_server']
|
||||
end
|
||||
@host = gem_data.spec.metadata['default_gem_server']
|
||||
end
|
||||
|
||||
args << @host if @host
|
||||
# Always include this, even if it's nil
|
||||
args << @host
|
||||
|
||||
if gem_data.spec.metadata.has_key?('allowed_push_host')
|
||||
args << gem_data.spec.metadata['allowed_push_host']
|
||||
end
|
||||
|
||||
say "Pushing gem to #{@host || Gem.host}..."
|
||||
|
||||
|
|
|
@ -72,16 +72,26 @@ is too hard to use.
|
|||
|
||||
def execute
|
||||
exit_code = 0
|
||||
if options[:args].to_a.empty? and options[:name].source.empty?
|
||||
name = options[:name]
|
||||
no_name = true
|
||||
elsif !options[:name].source.empty?
|
||||
name = Array(options[:name])
|
||||
else
|
||||
name = options[:args].to_a.map{|arg| /#{arg}/i }
|
||||
end
|
||||
|
||||
name = options[:name]
|
||||
prerelease = options[:prerelease]
|
||||
|
||||
unless options[:installed].nil? then
|
||||
if name.source.empty? then
|
||||
if no_name then
|
||||
alert_error "You must specify a gem name"
|
||||
exit_code |= 4
|
||||
elsif name.count > 1
|
||||
alert_error "You must specify only ONE gem!"
|
||||
exit_code |= 4
|
||||
else
|
||||
installed = installed? name, options[:version]
|
||||
installed = installed? name.first, options[:version]
|
||||
installed = !installed unless options[:installed]
|
||||
|
||||
if installed then
|
||||
|
@ -95,6 +105,22 @@ is too hard to use.
|
|||
terminate_interaction exit_code
|
||||
end
|
||||
|
||||
names = Array(name)
|
||||
names.each { |n| show_gems n, prerelease }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def display_header type
|
||||
if (ui.outs.tty? and Gem.configuration.verbose) or both? then
|
||||
say
|
||||
say "*** #{type} GEMS ***"
|
||||
say
|
||||
end
|
||||
end
|
||||
|
||||
#Guts of original execute
|
||||
def show_gems name, prerelease
|
||||
req = Gem::Requirement.default
|
||||
# TODO: deprecate for real
|
||||
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
|
||||
|
@ -105,11 +131,7 @@ is too hard to use.
|
|||
alert_warning "prereleases are always shown locally"
|
||||
end
|
||||
|
||||
if ui.outs.tty? or both? then
|
||||
say
|
||||
say "*** LOCAL GEMS ***"
|
||||
say
|
||||
end
|
||||
display_header 'LOCAL'
|
||||
|
||||
specs = Gem::Specification.find_all { |s|
|
||||
s.name =~ name and req =~ s.version
|
||||
|
@ -123,11 +145,7 @@ is too hard to use.
|
|||
end
|
||||
|
||||
if remote? then
|
||||
if ui.outs.tty? or both? then
|
||||
say
|
||||
say "*** REMOTE GEMS ***"
|
||||
say
|
||||
end
|
||||
display_header 'REMOTE'
|
||||
|
||||
fetcher = Gem::SpecFetcher.fetcher
|
||||
|
||||
|
@ -155,8 +173,6 @@ is too hard to use.
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
# Check if gem +name+ version +version+ is installed.
|
||||
|
||||
|
|
|
@ -36,11 +36,5 @@ To list local gems use the list command.
|
|||
"#{program_name} [STRING]"
|
||||
end
|
||||
|
||||
def execute
|
||||
string = get_one_optional_argument
|
||||
options[:name] = /#{string}/i
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|||
def initialize
|
||||
super 'uninstall', 'Uninstall gems from the local repository',
|
||||
:version => Gem::Requirement.default, :user_install => true,
|
||||
:install_dir => Gem.dir, :check_dev => false
|
||||
:check_dev => false
|
||||
|
||||
add_option('-a', '--[no-]all',
|
||||
'Uninstall all matching versions'
|
||||
|
@ -84,7 +84,6 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|||
|
||||
def defaults_str # :nodoc:
|
||||
"--version '#{Gem::Requirement.default}' --no-force " +
|
||||
"--install-dir #{Gem.dir}\n" +
|
||||
"--user-install"
|
||||
end
|
||||
|
||||
|
@ -104,8 +103,7 @@ that is a dependency of an existing gem. You can use the
|
|||
|
||||
def execute
|
||||
if options[:all] and not options[:args].empty? then
|
||||
alert_error 'Gem names and --all may not be used together'
|
||||
terminate_interaction 1
|
||||
uninstall_specific
|
||||
elsif options[:all] then
|
||||
uninstall_all
|
||||
else
|
||||
|
|
|
@ -244,6 +244,9 @@ command to remove old versions.
|
|||
args << '--no-rdoc' unless options[:document].include? 'rdoc'
|
||||
args << '--no-ri' unless options[:document].include? 'ri'
|
||||
args << '--no-format-executable' if options[:no_format_executable]
|
||||
args << '--previous-version' << Gem::VERSION if
|
||||
options[:system] == true or
|
||||
Gem::Version.new(options[:system]) >= Gem::Version.new(2)
|
||||
args
|
||||
end
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ requiring to see why it does not behave as you expect.
|
|||
|
||||
if spec then
|
||||
if options[:search_gems_first] then
|
||||
dirs = gem_paths(spec) + $LOAD_PATH
|
||||
dirs = spec.full_require_paths + $LOAD_PATH
|
||||
else
|
||||
dirs = $LOAD_PATH + gem_paths(spec)
|
||||
dirs = $LOAD_PATH + spec.full_require_paths
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -81,10 +81,6 @@ requiring to see why it does not behave as you expect.
|
|||
result
|
||||
end
|
||||
|
||||
def gem_paths(spec)
|
||||
spec.require_paths.collect { |d| File.join spec.full_gem_path, d }
|
||||
end
|
||||
|
||||
def usage # :nodoc:
|
||||
"#{program_name} FILE [FILE ...]"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue