Class: Quandl::Command::Tasks::Upload
- Inherits:
-
Quandl::Command::Task
- Object
- Quandl::Command::Task
- Quandl::Command::Tasks::Upload
- Defined in:
- lib/quandl/command/tasks/upload.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
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
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
Methods included from Quandl::Command::Task::Validations
Methods included from Quandl::Command::Task::Callbacks
Methods included from Quandl::Command::Task::Configurable
#ask_for_confirmation!, #config, #confirmed?, #declared_params, #force_yes?, #page, #trace?, #verbose?
Instance Method Details
#execute ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/quandl/command/tasks/upload.rb', line 31 def execute # datasets from file_path if given interface = file_path.present? ? File.open(file_path, "r") : $stdin # for each dataset streamed from interface t1 = Time.now Quandl::Format::Dataset.each_line(interface) do |dataset, error| # present error if given next present( error ) unless error.nil? # process in background using thread key background_job do # upload upload( dataset ) debug("#{dataset.full_code.to_s.ljust(20)} TOTAL: #{t1.elapsed_ms.ljust(20)} BREAKDOWN: #{dataset.client.human_benchmarks}") if dataset.respond_to?(:full_code) end t1 = Time.now end end |
#file_path ⇒ Object
56 57 58 |
# File 'lib/quandl/command/tasks/upload.rb', line 56 def file_path args.first end |
#upload(dataset) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/quandl/command/tasks/upload.rb', line 49 def upload(dataset) # upload unless errors were raised dataset.upload if dataset.valid? # output report to $stdout or $stderr present(dataset.client) end |