mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rubygems*: Updated to RubyGems 2.0
* test/rubygems*: ditto. * common.mk (prelude): Updated for RubyGems 2.0 source rearrangement. * tool/change_maker.rb: Allow invalid UTF-8 characters in source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3f606b7063
commit
9694bb8cac
214 changed files with 14049 additions and 7085 deletions
|
@ -21,6 +21,10 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
options[:installed] = value
|
||||
end
|
||||
|
||||
add_option('-I', 'Equivalent to --no-installed') do |value, options|
|
||||
options[:installed] = false
|
||||
end
|
||||
|
||||
add_version_option command, "for use with --installed"
|
||||
|
||||
add_option('-n', '--name-matches REGEXP',
|
||||
|
@ -80,6 +84,7 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
req = Gem::Requirement.default
|
||||
# TODO: deprecate for real
|
||||
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
|
||||
dep.prerelease = prerelease
|
||||
|
||||
if local? then
|
||||
if prerelease and not both? then
|
||||
|
@ -97,7 +102,7 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
}
|
||||
|
||||
spec_tuples = specs.map do |spec|
|
||||
[[spec.name, spec.version, spec.original_platform, spec], :local]
|
||||
[spec.name_tuple, spec]
|
||||
end
|
||||
|
||||
output_query_results spec_tuples
|
||||
|
@ -110,13 +115,27 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
say
|
||||
end
|
||||
|
||||
all = options[:all]
|
||||
|
||||
fetcher = Gem::SpecFetcher.fetcher
|
||||
spec_tuples = fetcher.find_matching dep, all, false, prerelease
|
||||
|
||||
spec_tuples += fetcher.find_matching dep, false, false, true if
|
||||
prerelease and all
|
||||
type = if options[:all]
|
||||
if options[:prerelease]
|
||||
:complete
|
||||
else
|
||||
:released
|
||||
end
|
||||
elsif options[:prerelease]
|
||||
:prerelease
|
||||
else
|
||||
:latest
|
||||
end
|
||||
|
||||
if options[:name].source.empty?
|
||||
spec_tuples = fetcher.detect(type) { true }
|
||||
else
|
||||
spec_tuples = fetcher.detect(type) do |gem_name, ver, plat|
|
||||
options[:name] === gem_name
|
||||
end
|
||||
end
|
||||
|
||||
output_query_results spec_tuples
|
||||
end
|
||||
|
@ -135,32 +154,30 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
output = []
|
||||
versions = Hash.new { |h,name| h[name] = [] }
|
||||
|
||||
spec_tuples.each do |spec_tuple, source_uri|
|
||||
versions[spec_tuple.first] << [spec_tuple, source_uri]
|
||||
spec_tuples.each do |spec_tuple, source|
|
||||
versions[spec_tuple.name] << [spec_tuple, source]
|
||||
end
|
||||
|
||||
versions = versions.sort_by do |(name,_),_|
|
||||
name.downcase
|
||||
versions = versions.sort_by do |(n,_),_|
|
||||
n.downcase
|
||||
end
|
||||
|
||||
versions.each do |gem_name, matching_tuples|
|
||||
matching_tuples = matching_tuples.sort_by do |(_, version,_),_|
|
||||
version
|
||||
end.reverse
|
||||
matching_tuples = matching_tuples.sort_by { |n,_| n.version }.reverse
|
||||
|
||||
platforms = Hash.new { |h,version| h[version] = [] }
|
||||
|
||||
matching_tuples.map do |(_, version, platform,_),_|
|
||||
platforms[version] << platform if platform
|
||||
matching_tuples.map do |n,_|
|
||||
platforms[n.version] << n.platform if n.platform
|
||||
end
|
||||
|
||||
seen = {}
|
||||
|
||||
matching_tuples.delete_if do |(_, version,_),_|
|
||||
if seen[version] then
|
||||
matching_tuples.delete_if do |n,_|
|
||||
if seen[n.version] then
|
||||
true
|
||||
else
|
||||
seen[version] = true
|
||||
seen[n.version] = true
|
||||
false
|
||||
end
|
||||
end
|
||||
|
@ -169,7 +186,7 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
|
||||
if options[:versions] then
|
||||
list = if platforms.empty? or options[:details] then
|
||||
matching_tuples.map { |(_, version,_),_| version }.uniq
|
||||
matching_tuples.map { |n,_| n.version }.uniq
|
||||
else
|
||||
platforms.sort.reverse.map do |version, pls|
|
||||
if pls == [Gem::Platform::RUBY] then
|
||||
|
@ -188,12 +205,11 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
if options[:details] then
|
||||
detail_tuple = matching_tuples.first
|
||||
|
||||
spec = if detail_tuple.first.length == 4 then
|
||||
detail_tuple.first.last
|
||||
else
|
||||
uri = URI.parse detail_tuple.last
|
||||
Gem::SpecFetcher.fetcher.fetch_spec detail_tuple.first, uri
|
||||
end
|
||||
spec = detail_tuple.last
|
||||
|
||||
unless spec.kind_of? Gem::Specification
|
||||
spec = spec.fetch_spec detail_tuple.first
|
||||
end
|
||||
|
||||
entry << "\n"
|
||||
|
||||
|
@ -243,9 +259,9 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|||
entry << "\n" << " Installed at: #{loaded_from}"
|
||||
else
|
||||
label = 'Installed at'
|
||||
matching_tuples.each do |(_,version,_,s),|
|
||||
matching_tuples.each do |n,s|
|
||||
loaded_from = File.dirname File.dirname(s.loaded_from)
|
||||
entry << "\n" << " #{label} (#{version}): #{loaded_from}"
|
||||
entry << "\n" << " #{label} (#{n.version}): #{loaded_from}"
|
||||
label = ' ' * label.length
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue