Sha256: 612364766d075ff82d0dc0ce1dd6c41e8a9a9d9f7b7eb11d2517c262975d267e

Contents?: true

Size: 884 Bytes

Versions: 10

Compression:

Stored size: 884 Bytes

Contents

class Quandl::Command::Tasks::Search < Quandl::Command::Task
  autoload_quandl_client
  
  syntax "quandl search STRING"
  description "Search for datasets matching STRING"
  
  options({
    String => {
      source_code:  "Return datasets matching: [SOURCE_CODE]",
      code:         "Return datasets where code matches [code]",
    },
    Integer => {
      limit:        "Limit the number of datasets returned by the search. Defaults to unlimited.",
      page:         "Return datasets starting from: [page]",
    }
  })
  
  before_execute :upcase_source_code
  
  validates :query, presence: true
  
  def execute
    Quandl::Client::Dataset.query( query ).where( declared_params ).each_in_page do |dataset|
      present(dataset)
    end
  end
  
  
  protected
  
  def query
    args.first
  end
  
  def upcase_source_code
    options.source_code.to_s.upcase!
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
quandl-0.4.4 lib/quandl/command/tasks/search.rb
quandl-0.4.3 lib/quandl/command/tasks/search.rb
quandl-0.4.2 lib/quandl/command/tasks/search.rb
quandl-0.4.1 lib/quandl/command/tasks/search.rb
quandl-0.4.0 lib/quandl/command/tasks/search.rb
quandl-0.3.7 lib/quandl/command/tasks/search.rb
quandl-0.3.6 lib/quandl/command/tasks/search.rb
quandl-0.3.4 lib/quandl/command/tasks/search.rb
quandl-0.3.3 lib/quandl/command/tasks/search.rb
quandl-0.3.0 lib/quandl/command/tasks/search.rb