Class: Gem::Commands::FerretCommand

Inherits:
QueryCommand
  • Object
show all
Defined in:
lib/rubygems/commands/ferret_command.rb

Overview

A fulltext search for gems using rubypan.org

Instance Method Summary collapse

Constructor Details

#initializeFerretCommand

Returns a new instance of FerretCommand.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rubygems/commands/ferret_command.rb', line 9

def initialize
  super 'ferret', 'Search for text in gemspec fields via rubypan.org'

  remove_option '--name-matches'
  remove_option '--all'
  remove_option '--version'
  remove_option '-i'

  remove_option '--local'
  remove_option '--remote'
  remove_option '--both'
end

Instance Method Details

#argumentsObject

:nodoc:



22
23
24
# File 'lib/rubygems/commands/ferret_command.rb', line 22

def arguments # :nodoc:
  "TEXT          text to serach for"
end

#defaults_strObject

:nodoc:



26
27
28
# File 'lib/rubygems/commands/ferret_command.rb', line 26

def defaults_str # :nodoc:
  "--no-details"
end

#executeObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rubygems/commands/ferret_command.rb', line 34

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

#usageObject

:nodoc:



30
31
32
# File 'lib/rubygems/commands/ferret_command.rb', line 30

def usage # :nodoc:
  "#{program_name} [TEXT]"
end