mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to RubyGems 1.3.7.pre.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d0e5a34ac7
commit
372dcece3f
64 changed files with 759 additions and 240 deletions
|
@ -7,7 +7,7 @@ class Gem::Commands::ContentsCommand < Gem::Command
|
|||
|
||||
def initialize
|
||||
super 'contents', 'Display the contents of the installed gems',
|
||||
:specdirs => [], :lib_only => false
|
||||
:specdirs => [], :lib_only => false, :prefix => true
|
||||
|
||||
add_version_option
|
||||
|
||||
|
|
|
@ -159,7 +159,9 @@ class Gem::Commands::DependencyCommand < Gem::Command
|
|||
response
|
||||
end
|
||||
|
||||
# Returns list of [specification, dep] that are satisfied by spec.
|
||||
##
|
||||
# Returns an Array of [specification, dep] that are satisfied by +spec+.
|
||||
|
||||
def find_reverse_dependencies(spec)
|
||||
result = []
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ lib/rubygems/defaults/operating_system.rb
|
|||
when /^packageversion/ then
|
||||
out << Gem::RubyGemsPackageVersion
|
||||
when /^version/ then
|
||||
out << Gem::RubyGemsVersion
|
||||
out << Gem::VERSION
|
||||
when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
|
||||
out << Gem.dir
|
||||
when /^gempath/, /^path/, /^GEM_PATH/ then
|
||||
|
@ -79,7 +79,7 @@ lib/rubygems/defaults/operating_system.rb
|
|||
when nil then
|
||||
out = "RubyGems Environment:\n"
|
||||
|
||||
out << " - RUBYGEMS VERSION: #{Gem::RubyGemsVersion}\n"
|
||||
out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n"
|
||||
|
||||
out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
|
||||
out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
|
||||
|
@ -109,6 +109,7 @@ lib/rubygems/defaults/operating_system.rb
|
|||
|
||||
out << " - GEM CONFIGURATION:\n"
|
||||
Gem.configuration.each do |name, value|
|
||||
value = value.gsub(/./, '*') if name == 'gemcutter_key'
|
||||
out << " - #{name.inspect} => #{value.inspect}\n"
|
||||
end
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Gem::Commands::FetchCommand < Gem::Command
|
|||
|
||||
def execute
|
||||
version = options[:version] || Gem::Requirement.default
|
||||
all = Gem::Requirement.default
|
||||
all = Gem::Requirement.default != version
|
||||
|
||||
gem_names = get_all_gem_names
|
||||
|
||||
|
@ -42,13 +42,17 @@ class Gem::Commands::FetchCommand < Gem::Command
|
|||
dep = Gem::Dependency.new gem_name, version
|
||||
dep.prerelease = options[:prerelease]
|
||||
|
||||
specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, false, true,
|
||||
specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, all, true,
|
||||
dep.prerelease?)
|
||||
|
||||
specs_and_sources, errors =
|
||||
Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
|
||||
dep.prerelease?)
|
||||
|
||||
spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
|
||||
|
||||
if spec.nil? then
|
||||
alert_error "Could not find #{gem_name} in any repository"
|
||||
show_lookup_failure gem_name, version, errors
|
||||
next
|
||||
end
|
||||
|
||||
|
|
|
@ -127,7 +127,8 @@ to write the specification by hand. For example:
|
|||
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
|
||||
exit_code |= 1
|
||||
rescue Gem::GemNotFoundException => e
|
||||
alert_error e.message
|
||||
show_lookup_failure e.name, e.version, e.errors
|
||||
|
||||
exit_code |= 2
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
options[:installed] = value
|
||||
end
|
||||
|
||||
add_version_option
|
||||
add_version_option command, "for use with --installed"
|
||||
|
||||
add_option('-n', '--name-matches REGEXP',
|
||||
'Name of gem(s) to query on matches the',
|
||||
|
@ -185,8 +185,21 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
entry = gem_name.dup
|
||||
|
||||
if options[:versions] then
|
||||
versions = matching_tuples.map { |(name, version,_),_| version }.uniq
|
||||
entry << " (#{versions.join ', '})"
|
||||
list = if platforms.empty? or options[:details] then
|
||||
matching_tuples.map { |(name, version,_),_| version }.uniq
|
||||
else
|
||||
platforms.sort.reverse.map do |version, pls|
|
||||
if pls == [Gem::Platform::RUBY] then
|
||||
version
|
||||
else
|
||||
ruby = pls.delete Gem::Platform::RUBY
|
||||
platform_list = [ruby, *pls.sort].compact
|
||||
"#{version} #{platform_list.join ' '}"
|
||||
end
|
||||
end
|
||||
end.join ', '
|
||||
|
||||
entry << " (#{list})"
|
||||
end
|
||||
|
||||
if options[:details] then
|
||||
|
|
|
@ -5,7 +5,7 @@ class Gem::Commands::ServerCommand < Gem::Command
|
|||
|
||||
def initialize
|
||||
super 'server', 'Documentation and gem repository HTTP server',
|
||||
:port => 8808, :gemdir => Gem.dir, :daemon => false
|
||||
:port => 8808, :gemdir => [], :daemon => false
|
||||
|
||||
OptionParser.accept :Port do |port|
|
||||
if port =~ /\A\d+\z/ then
|
||||
|
@ -29,8 +29,9 @@ class Gem::Commands::ServerCommand < Gem::Command
|
|||
end
|
||||
|
||||
add_option '-d', '--dir=GEMDIR',
|
||||
'directory from which to serve gems' do |gemdir, options|
|
||||
options[:gemdir] = File.expand_path gemdir
|
||||
'directories from which to serve gems',
|
||||
'multiple directories may be provided' do |gemdir, options|
|
||||
options[:gemdir] << File.expand_path(gemdir)
|
||||
end
|
||||
|
||||
add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
|
||||
|
@ -69,6 +70,7 @@ You can set up a shortcut to gem server documentation using the URL:
|
|||
end
|
||||
|
||||
def execute
|
||||
options[:gemdir] << Gem.dir if options[:gemdir].empty?
|
||||
Gem::Server.run options
|
||||
end
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ TEXT
|
|||
|
||||
def install_rdoc
|
||||
gem_doc_dir = File.join Gem.dir, 'doc'
|
||||
rubygems_name = "rubygems-#{Gem::RubyGemsVersion}"
|
||||
rubygems_name = "rubygems-#{Gem::VERSION}"
|
||||
rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
|
||||
|
||||
if File.writable? gem_doc_dir and
|
||||
|
|
|
@ -12,7 +12,8 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|||
:version => Gem::Requirement.default,
|
||||
:target => Dir.pwd
|
||||
|
||||
add_option('--target=DIR', 'target directory for unpacking') do |value, options|
|
||||
add_option('--target=DIR',
|
||||
'target directory for unpacking') do |value, options|
|
||||
options[:target] = value
|
||||
end
|
||||
|
||||
|
@ -31,6 +32,16 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|||
"#{program_name} GEMNAME"
|
||||
end
|
||||
|
||||
def download dependency
|
||||
found = Gem::SpecFetcher.fetcher.fetch dependency
|
||||
|
||||
return if found.empty?
|
||||
|
||||
spec, source_uri = found.first
|
||||
|
||||
Gem::RemoteFetcher.fetcher.download spec, source_uri
|
||||
end
|
||||
|
||||
#--
|
||||
# TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for
|
||||
# this, so that it works for uninstall as well. (And check other commands
|
||||
|
@ -38,11 +49,12 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|||
|
||||
def execute
|
||||
get_all_gem_names.each do |name|
|
||||
path = get_path name, options[:version]
|
||||
dependency = Gem::Dependency.new name, options[:version]
|
||||
path = get_path dependency
|
||||
|
||||
if path then
|
||||
basename = File.basename(path, '.gem')
|
||||
target_dir = File.expand_path File.join(options[:target], basename)
|
||||
basename = File.basename path, '.gem'
|
||||
target_dir = File.expand_path basename, options[:target]
|
||||
FileUtils.mkdir_p target_dir
|
||||
Gem::Installer.new(path, :unpack => true).unpack target_dir
|
||||
say "Unpacked gem: '#{target_dir}'"
|
||||
|
@ -52,14 +64,15 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Return the full path to the cached gem file matching the given
|
||||
# name and version requirement. Returns 'nil' if no match.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# get_path('rake', '> 0.4') # -> '/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem'
|
||||
# get_path('rake', '< 0.1') # -> nil
|
||||
# get_path('rak') # -> nil (exact name required)
|
||||
# get_path 'rake', '> 0.4' # "/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem"
|
||||
# get_path 'rake', '< 0.1' # nil
|
||||
# get_path 'rak' # nil (exact name required)
|
||||
#--
|
||||
# TODO: This should be refactored so that it's a general service. I don't
|
||||
# think any of our existing classes are the right place though. Just maybe
|
||||
|
@ -67,30 +80,29 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|||
#
|
||||
# TODO: It just uses Gem.dir for now. What's an easy way to get the list of
|
||||
# source directories?
|
||||
def get_path(gemname, version_req)
|
||||
return gemname if gemname =~ /\.gem$/i
|
||||
|
||||
specs = Gem::source_index.find_name gemname, version_req
|
||||
def get_path dependency
|
||||
return dependency.name if dependency.name =~ /\.gem$/i
|
||||
|
||||
specs = Gem.source_index.search dependency
|
||||
|
||||
selected = specs.sort_by { |s| s.version }.last
|
||||
|
||||
return nil if selected.nil?
|
||||
return download(dependency) if selected.nil?
|
||||
|
||||
# We expect to find (basename).gem in the 'cache' directory.
|
||||
# Furthermore, the name match must be exact (ignoring case).
|
||||
if gemname =~ /^#{selected.name}$/i
|
||||
filename = selected.file_name
|
||||
path = nil
|
||||
return unless dependency.name =~ /^#{selected.name}$/i
|
||||
|
||||
Gem.path.find do |gem_dir|
|
||||
path = File.join gem_dir, 'cache', filename
|
||||
File.exist? path
|
||||
end
|
||||
# We expect to find (basename).gem in the 'cache' directory. Furthermore,
|
||||
# the name match must be exact (ignoring case).
|
||||
filename = selected.file_name
|
||||
path = nil
|
||||
|
||||
path
|
||||
else
|
||||
nil
|
||||
Gem.path.find do |gem_dir|
|
||||
path = File.join gem_dir, 'cache', filename
|
||||
File.exist? path
|
||||
end
|
||||
|
||||
path
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -56,7 +56,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|||
|
||||
rubygems_update = Gem::Specification.new
|
||||
rubygems_update.name = 'rubygems-update'
|
||||
rubygems_update.version = Gem::Version.new Gem::RubyGemsVersion
|
||||
rubygems_update.version = Gem::Version.new Gem::VERSION
|
||||
hig['rubygems-update'] = rubygems_update
|
||||
|
||||
options[:user_install] = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue