Slightly smaller patch.
--
Jos Backus
jos at catnook.com
diff --git a/commands/query_command.rb b/commands/query_command.rb
index df17cc8..0a36c56 100644
--- a/commands/query_command.rb
+++ b/commands/query_command.rb
@@ -102,8 +102,7 @@ class Gem::Commands::QueryCommand < Gem::Command
!Gem.source_index.search(dep).empty?
end
- def output_query_results(gemspecs)
- output = []
+ def collect_query_results(gemspecs)
gem_list_with_version = {}
gemspecs.flatten.each do |gemspec|
@@ -115,7 +114,7 @@ class Gem::Commands::QueryCommand < Gem::Command
name.downcase
end
- gem_list_with_version.each do |gem_name, list_of_matching|
+ gem_list_with_version.collect do |gem_name, list_of_matching|
list_of_matching = list_of_matching.sort_by { |x| x.version.to_ints }.reverse
seen_versions = {}
@@ -128,16 +127,33 @@ class Gem::Commands::QueryCommand < Gem::Command
end
end
- entry = gem_name.dup
+ entry = {:name => gem_name.dup, :versions => []}
if options[:versions] then
versions = list_of_matching.map { |s| s.version }.uniq
- entry << " (#{versions.join ', '})"
+ entry[:versions] += versions
+ end
+
+ entry[:summary] = list_of_matching[0].summary if options[:details]
+
+ entry
+ end
+
+ end
+
+ def output_query_results(gemspecs)
+ output = []
+ collect_query_results(gemspecs).each do |entry|
+ text = entry[:name]
+
+ if options[:versions] then
+ versions = entry[:versions]
+ text << " (#{versions.join ', '})"
end
- entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
+ text << "\n" << format_text(entry[:summary], 68, 4) if
options[:details]
- output << entry
+ output << text
end
say output.join(options[:details] ? "\n\n" : "\n")
_______________________________________________
Rubygems-developers mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers