require 'rubygems/command' require 'rubygems/commands/query_command' ## # A fulltext search for gems using http://rubypan.org class Gem::Commands::FerretCommand < Gem::Commands::QueryCommand def initialize super 'search!', 'Search for text in gemspec fields via rubypan.org' remove_option '--name-matches' remove_option '--all' remove_option '--installed' remove_option '--version' remove_option '--local' remove_option '--remote' remove_option '--both' end def arguments # :nodoc: "TEXT text to serach for" end def defaults_str # :nodoc: "--no-details" end def usage # :nodoc: "#{program_name} [TEXT]" end def execute search = URI.escape options[:args].join(' ') search_uri = URI.parse "http://rubypan.org/search.Marshal?q=#{search}" data = Gem::RemoteFetcher.fetcher.fetch_path search_uri spec_tuples = Marshal.load data output_query_results spec_tuples end end