Class: Quandl::Command::Tasks::Superset

Inherits:
Quandl::Command::Task show all
Defined in:
lib/quandl/command/tasks/superset.rb

Constant Summary

Constants included from Quandl::Command::Task::Updatable

Quandl::Command::Task::Updatable::VERSION_URL

Instance Method Summary collapse

Methods included from Quandl::Command::Task::Inputable

#args_or_stdin, #each_line_in_background, #file_or_stdin

Methods included from Quandl::Command::Task::Reportable

#ask_to_send_crash_reports, #call

Methods included from Quandl::Command::Task::Clientable

#current_user

Methods included from Quandl::Command::Task::Updatable

#check_for_update, #check_for_update_once_daily

Methods included from Quandl::Command::Task::Threading

#await_thread_pool_lock!, #background_job, #exiting?, #force_load_json_support, #mutex, #obtain_thread_pool_lock, #release_thread_pool_lock, #shutdown_thread_pool_on_sigint, #thread_pool, #thread_pool_locked?, #thread_pool_locks, #threads, #threads?

Methods included from Quandl::Command::Task::Presentation

#present

Methods included from Quandl::Command::Task::Logging

#configure_logger, #debug, #error, #fatal, #info, #initialize_logger, #log_request_time, #logger, #start_request_timer, #stderr_logger, #summarize, #summarize_hash, #table

Methods included from Quandl::Command::Task::Commandable

#initialize

Methods included from Quandl::Command::Task::Validations

#run_task_validations!

Methods included from Quandl::Command::Task::Callbacks

#call

Methods included from Quandl::Command::Task::Configurable

#ask_for_confirmation!, #config, #confirmed?, #declared_params, #force_yes?, #page, #trace?, #verbose?

Instance Method Details

#deleteObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/quandl/command/tasks/superset.rb', line 55

def delete
  each_line_in_background( args_or_stdin ) do |code|
    # find
    dataset = Quandl::Client::Dataset.find( code )
    # destroy
    dataset.destroy
    # present
    present dataset
  end
end

#downloadObject



46
47
48
49
50
51
52
53
# File 'lib/quandl/command/tasks/superset.rb', line 46

def download
  each_line_in_background( args_or_stdin ) do |code|
    # find superset
    dataset = Quandl::Client::Superset.find( code )
    # present
    present dataset, output_format: :qdf
  end
end

#executeObject



17
18
19
20
21
22
# File 'lib/quandl/command/tasks/superset.rb', line 17

def execute
  # fire a subcommand if specified
  return self.send(args.shift) if args.first.present? && self.respond_to?(args.first)
  # otherwise default to upload
  upload
end

#listObject



28
29
30
31
32
# File 'lib/quandl/command/tasks/superset.rb', line 28

def list
  Quandl::Client::Superset.owner('myself').each_in_page do |superset|
    present(superset)
  end
end

#newObject



24
25
26
# File 'lib/quandl/command/tasks/superset.rb', line 24

def new
  info Quandl::Client::Superset.example.to_qdf
end

#uploadObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/quandl/command/tasks/superset.rb', line 34

def upload
  Quandl::Format::Superset.foreach( file_or_stdin ) do |superset|
    # execute in parallel
    background_job do
      # upload the superset
      superset.save if superset.respond_to?(:valid?) && superset.valid?
      # present the result
      present(superset)
    end
  end
end