Class: Quandl::Command::Tasks::Upload
- Inherits:
-
Base
- Object
- Base
- Quandl::Command::Tasks::Upload
show all
- Defined in:
- lib/quandl/command/tasks/upload.rb
Instance Attribute Summary
Attributes inherited from Base
#args, #options, #request_timer
Instance Method Summary
collapse
Methods inherited from Base
#ask_yes_or_no, authenticated_users_only!, call, #call, command_name, configure, #current_user, #debug, description, disable!, disabled?, #error, #fatal, #force_yes?, #info, #initialize, #logger, options, #summarize, #summarize_hash, syntax, #table, #verbose?, warn_unauthenticated_users
Instance Method Details
#execute ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/quandl/command/tasks/upload.rb', line 35
def execute
interface = file_path.present? ? File.open(file_path, "r") : $stdin
Quandl::Format::Dataset.each_line(interface) do |dataset|
pool.process{ upload( dataset ) }
end
pool.shutdown
end
|
#file_path ⇒ Object
65
66
67
|
# File 'lib/quandl/command/tasks/upload.rb', line 65
def file_path
args.first
end
|
#report(dataset) ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/quandl/command/tasks/upload.rb', line 54
def report(dataset)
if [200,201].include?( dataset.client.status )
info table dataset.client.human_status,
dataset.client.elapsed_request_time_ms,
dataset.client.full_url
else
error(dataset.human_errors)
end
debug "---"
end
|
#upload(dataset) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/quandl/command/tasks/upload.rb', line 45
def upload(dataset)
debug dataset.attributes.to_s
dataset.upload if dataset.valid?
report(dataset)
end
|