Class: Chimps::Commands::Search
Constant Summary
collapse
- USAGE =
"usage: chimps search [OPTIONS] QUERY"
- HELP =
<<EOF
Search for #{default_resources_type} on Infochimps for the given
QUERY.
Examples:
$ chimps search music # search all datasets for 'music'
$ chimps search --my 'finance AND nyse' # search your datasets for 'finance' and 'nyse'
EOF
Instance Attribute Summary
#config
Class Method Summary
collapse
Instance Method Summary
collapse
#first_arg_is_resource_type?, #has_resource_identifier?, included, #plural_resource, #resource_identifier, #resource_path, #resource_type, #resources_path
#headers, included, #normalize_fmt
#initialize, name, #name
Class Method Details
.allowed_resources ⇒ Object
9
10
11
|
# File 'lib/chimps-cli/commands/search.rb', line 9
def self.allowed_resources
%w[dataset]
end
|
.allowed_response_fmts ⇒ Object
13
14
15
|
# File 'lib/chimps-cli/commands/search.rb', line 13
def self.allowed_response_fmts
super().concat(['tsv'])
end
|
.default_response_fmt ⇒ Object
17
18
19
|
# File 'lib/chimps-cli/commands/search.rb', line 17
def self.default_response_fmt
'tsv'
end
|
Instance Method Details
#execute! ⇒ Object
48
49
50
|
# File 'lib/chimps-cli/commands/search.rb', line 48
def execute!
Request.new(path, :query_params => query_params, :sign => config[:my]).get().print(config)
end
|
#path ⇒ Object
44
45
46
|
# File 'lib/chimps-cli/commands/search.rb', line 44
def path
config[:my] ? "/my/search.#{response_fmt}" : "/search.#{response_fmt}"
end
|
#query ⇒ Object
33
34
35
36
|
# File 'lib/chimps-cli/commands/search.rb', line 33
def query
raise CLIError.new(self.class::USAGE) if config.rest.size < 2
config.rest[1..-1].join(' ')
end
|
#query_params ⇒ Object
38
39
40
41
42
|
# File 'lib/chimps-cli/commands/search.rb', line 38
def query_params
{:query => query}.tap do |qp|
qp[:skip_header] = true if config[:skip_column_names]
end
end
|