summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/query_command.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-17 22:04:18 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-17 22:04:18 +0000
commit9d4f37f51fb2ffdef5e318afb3cb81516dcba4f7 ()
tree2eb3c16c59259a25f5d9315edacc61dfc8c59d62 /lib/rubygems/commands/query_command.rb
parentf98e6b91dec68ddd010ccb3bad651a18e7dca338 (diff)
Update RubyGems to 1.1.1 r1778 (almost 1.2)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rubygems/commands/query_command.rb101
1 files changed, 80 insertions, 21 deletions
@@ -1,6 +1,6 @@
require 'rubygems/command'
require 'rubygems/local_remote_options'
-require 'rubygems/source_info_cache'
require 'rubygems/version_option'
class Gem::Commands::QueryCommand < Gem::Command
@@ -74,7 +74,13 @@ class Gem::Commands::QueryCommand < Gem::Command
say "*** LOCAL GEMS ***"
say
- output_query_results Gem.source_index.search(name)
end
if remote? then
@@ -84,13 +90,26 @@ class Gem::Commands::QueryCommand < Gem::Command
all = options[:all]
begin
- Gem::SourceInfoCache.cache all
- rescue Gem::RemoteFetcher::FetchError
- # no network
end
- output_query_results Gem::SourceInfoCache.search(name, false, all)
end
end
@@ -104,28 +123,30 @@ class Gem::Commands::QueryCommand < Gem::Command
!Gem.source_index.search(dep).empty?
end
- def output_query_results(gemspecs)
output = []
- gem_list_with_version = {}
- gemspecs.flatten.each do |gemspec|
- gem_list_with_version[gemspec.name] ||= []
- gem_list_with_version[gemspec.name] << gemspec
end
- gem_list_with_version = gem_list_with_version.sort_by do |name, spec|
name.downcase
end
- gem_list_with_version.each do |gem_name, list_of_matching|
- list_of_matching = list_of_matching.sort_by { |x| x.version.to_ints }.reverse
- seen_versions = {}
- list_of_matching.delete_if do |item|
- if seen_versions[item.version] then
true
else
- seen_versions[item.version] = true
false
end
end
@@ -133,12 +154,50 @@ class Gem::Commands::QueryCommand < Gem::Command
entry = gem_name.dup
if options[:versions] then
- versions = list_of_matching.map { |s| s.version }.uniq
entry << " (#{versions.join ', '})"
end
- entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
- options[:details]
output << entry
end