quandl 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWZhODVmN2E1YzI4MTVhNDdlZDBjNmExOWUzNDYzMDM3M2IwNTNhMw==
4
+ NDE0ZTgyNWUyNmExYWE1YWFiMTdmNTU1ZWVkNDA1MDQ4MWIxMTI2YQ==
5
5
  data.tar.gz: !binary |-
6
- ZTNhZmQ0OGI3MmNiNzQyZTQxYTA5YzYzMjQzMzcyN2QxNDVmMWNiOA==
6
+ ZGI0ZDZiYjVlYzI3N2QxMDE2ZTNhNzg2ZjZlMTdlYzUwYjM5MGYyZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDI5MjJhNDQwZjU5YTE1MmU0YTJjN2FiNDAwYWFkNmY2YTA2NTk3YzQ4ZTM5
10
- OTIyYzAzZjhmNjYyNjJiYWNiYzBjOTgwMzA2OTkzZGIxMzkwOGVhODU0MGY1
11
- MmEzNmZmZGZjZjJhZTA1ZmFhZGU2MjhhZTcwYzM1YmUwMDhkMDc=
9
+ Njc4M2NiMjg3ZGJiMzA1MzYyYWJhYzFlZWQyMzkzMTA4YTUyMWRkMTA4MzM0
10
+ YzJkODQyODk5MDRmYWQ0NjhiYjc4YzVlZDEzZjgxYWI4NWU2YTQwZDlkMDIx
11
+ ODc0ZDYyNjFmOGM5NDc3N2ViNDI0YThiYTdjZDMxMDYyMDZjZjQ=
12
12
  data.tar.gz: !binary |-
13
- MDM2MDRhOTRlMTkzN2I4ZTJlZGI0MGEwNGExMjVmNGE5MzdkMzYzOWRmN2Uy
14
- Zjk1MDRlOTJkNmZjZTVjYmJmODRiNTE5MzczNDhlMGE4OTExMjI1NTQ0OGI4
15
- ODBiMzA4ZjNjOTFjOWEzNTllMTU1ZTc2YzVhZDU0Zjc2YzRhMDY=
13
+ ZjQ1NjNjZGJjNmE3NGVjYjhlYWYxNDFkNmNhM2I4MTk0NjRjZmVkZTY5YjNm
14
+ YTg3MWY1YWMwM2RjZDEyNmU5ZTVlOTZjY2VlYTkwYWY2MWQ3NzQ5OGFhODkx
15
+ NzkwNDA2NjFmY2MxOTg0MDA0MWM4M2Y0ZTE0ODFjNDdhZTYyYjQ=
data/UPGRADE.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.4.1
2
+
3
+ * added schedule run (now) feature
4
+
5
+
6
+
1
7
  ## 0.4.0
2
8
 
3
9
  * QUGC-166 fix quandl schedule list --token incorrect_token
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -12,7 +12,8 @@ class Quandl::Command::Tasks::Schedule < Quandl::Command::Task
12
12
 
13
13
  schedule list [FILE]
14
14
  schedule add RUN_FILE [DEPENDENT_FILE1] [DEPENDENT_FILE2] [--at TIME]
15
- schedule delete FILE
15
+ schedule delete SCRIPT
16
+ schedule run SCRIPT
16
17
 
17
18
  EXAMPLES:
18
19
 
@@ -21,6 +22,12 @@ class Quandl::Command::Tasks::Schedule < Quandl::Command::Task
21
22
 
22
23
  $ quandl schedule add scraper.rb helper.txt helper2.txt --at "7pm Monday"
23
24
  You have successfully scheduled scraper.rb to run alongside helper.txt, helper2.txt. [weekly scraper]
25
+
26
+ $ quandl schedule deleted scraper.rb
27
+ You have successfully deleted scraper.rb.
28
+
29
+ $ quandl schedule run scraper.rb
30
+ Your scraper.rb will run immediately.
24
31
  }
25
32
 
26
33
  options({
@@ -47,7 +54,8 @@ class Quandl::Command::Tasks::Schedule < Quandl::Command::Task
47
54
  (info("'#{name}' does not exist "); return;) if scraper.blank?
48
55
  script_info scraper
49
56
  else
50
- scrapers.each { |x| script_info x}
57
+ # create new blank scope and iterate over all pages
58
+ Quandl::Client::Scraper.scope.new.each_in_page{|x| script_info(x) }
51
59
  end
52
60
  end
53
61
 
@@ -88,6 +96,22 @@ class Quandl::Command::Tasks::Schedule < Quandl::Command::Task
88
96
 
89
97
  end
90
98
 
99
+ def run
100
+ (info("'#{name}' does not exist "); return;) if scraper.blank?
101
+ info("You are about to run '#{scraper.name}'")
102
+ return unless confirmed?
103
+ result=scraper.run_now if scraper.respond_to?(:run_now)
104
+ if result.valid?
105
+ info("Your '#{scraper.name}' will run immediately.")
106
+ else
107
+ if result.status == 429
108
+ info("You have exceeded your daily run limit.")
109
+ else
110
+ error "#{Quandl::Command::Presenter.pretty_errors(result.errors.messages).to_s.gsub("\n", ' ')}"
111
+ end
112
+ end
113
+
114
+ end
91
115
 
92
116
  #not supported for now
93
117
  =begin
@@ -124,9 +148,9 @@ class Quandl::Command::Tasks::Schedule < Quandl::Command::Task
124
148
  def schedule_message
125
149
  if options.at
126
150
  "Your script first run will happen in #{scraper.schedule_next}. It will continue to run #{scraper.schedule_run_time}
127
- Check your scrapers run status at #{quandl_url.gsub(/\/api\/?/,'')}/scrapers"
151
+ Check your script run status at #{quandl_url.gsub(/\/api\/?/,'')}/schedule/#{scraper.id}"
128
152
  else
129
- "It will run 3 times a day starting immediately.\nCheck your scrapers run status at #{quandl_url.gsub(/\/api\/?/,'')}/scrapers"
153
+ "It will run 3 times a day starting immediately.\nCheck your script run status at #{quandl_url.gsub(/\/api\/?/,'')}/schedule/#{scraper.id}"
130
154
  end
131
155
  end
132
156
 
@@ -33,13 +33,14 @@ class Quandl::Command::Tasks::Upload < Quandl::Command::Task
33
33
  interface = file_path.present? ? File.open(file_path, "r") : $stdin
34
34
  # for each dataset streamed from interface
35
35
  Quandl::Format::Dataset.each_line(interface) do |dataset, error|
36
- debug("started processing #{dataset.full_code}") if dataset.respond_to?(:full_code)
37
36
  # present error if given
38
37
  next present( error ) unless error.nil?
39
38
  # process in background using thread key
40
39
  background_job do
41
40
  # upload
41
+ t1 = Time.now
42
42
  upload( dataset )
43
+ debug("#{dataset.full_code.to_s.ljust(20)} #{t1.elapsed_ms}") if dataset.respond_to?(:full_code)
43
44
  end
44
45
  end
45
46
  end
data/quandl.gemspec CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_runtime_dependency "commander", '4.1.5'
21
21
 
22
- s.add_runtime_dependency "quandl_format", "0.4.3"
23
- s.add_runtime_dependency "quandl_client", '2.8.0'
24
- s.add_runtime_dependency "quandl_data", '1.4.1'
25
- s.add_runtime_dependency "quandl_operation", '0.3.2'
22
+ s.add_runtime_dependency "quandl_format", "0.5.0"
23
+ s.add_runtime_dependency "quandl_client", '2.10.0'
24
+ s.add_runtime_dependency "quandl_data", '1.5.1'
25
+ s.add_runtime_dependency "quandl_operation", '0.4.1'
26
26
  s.add_runtime_dependency "quandl_babelfish", '0.0.11'
27
- s.add_runtime_dependency "quandl_logger", '0.2.6'
27
+ s.add_runtime_dependency "quandl_logger", '0.3.1'
28
28
  s.add_runtime_dependency "json", '1.7.7'
29
29
  s.add_runtime_dependency "minitar", '0.5.4'
30
30
  s.add_runtime_dependency "thread", "0.1.3"
@@ -0,0 +1,21 @@
1
+
2
+ # disable log output
3
+ class Spec::Config::Output
4
+
5
+ class << self
6
+ def info(*args)
7
+ puts(*args)
8
+ end
9
+ def fatal(*args)
10
+ puts(*args)
11
+ end
12
+ def error(*args)
13
+ puts(*args)
14
+ end
15
+ def debug(*args)
16
+ puts(*args)
17
+ end
18
+ end
19
+
20
+ end
21
+ Quandl::Logger.use(Spec::Config::Output)
@@ -0,0 +1,16 @@
1
+ require 'ostruct'
2
+ require 'yaml'
3
+
4
+ module Spec
5
+ module Config
6
+ Quandl = OpenStruct.new(YAML.load(File.read(File.join(ENV['HOME'], '.quandl/test'))))
7
+ end
8
+ end
9
+
10
+ require "quandl/client"
11
+ require "quandl/fabricate"
12
+
13
+ include Quandl::Client
14
+
15
+ Quandl::Client.token = Spec::Config::Quandl.token
16
+ Quandl::Client.use( Spec::Config::Quandl.quandl_url )
@@ -28,7 +28,7 @@ describe Quandl::Command::Tasks::Delete do
28
28
  before(:each){ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/datasets.qdf' ) }
29
29
 
30
30
  it "should delete spec/fixtures/data/datasets.qdf" do
31
- TestOutput.should_receive(:info).with(/Deleted/).at_least(4).times
31
+ Spec::Config::Output.should_receive(:info).with(/Deleted/).at_least(4).times
32
32
  datasets = Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf')
33
33
  datasets.each{|d| Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) }
34
34
  end
@@ -36,7 +36,7 @@ describe Quandl::Command::Tasks::Delete do
36
36
  it "should not download" do
37
37
  datasets = Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf')
38
38
  datasets.each{|d| Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) }
39
- TestOutput.should_receive(:info).with(nil).at_least(4).times
39
+ Spec::Config::Output.should_receive(:info).with(nil).at_least(4).times
40
40
  datasets.each{|d| Quandl::Command::Tasks::Download.call( d.code ) }
41
41
  end
42
42
 
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- replace_string = "source_code: BLAKEHIL\ncode: SCRAPER_TEST_1394485290783983\nname: Untitled Dataset 2014-04-04 13:08:49\ndescription: This dataset has no description.\nprivate: false\nreference_url: \nfrequency: daily\n-\nDate,High,Low,Settle\n2014-03-11,9.958,11.0,13.92\n\n"
5
-
6
4
  describe "./bin/quandl replace" do
7
5
 
8
6
  let(:prefix){ "replace" }
@@ -17,7 +15,8 @@ describe "./bin/quandl replace" do
17
15
  context "SCRAPER_TEST_1394485290783983" do
18
16
  let(:prefix){ "download" }
19
17
 
20
- its(:stdout){ should eq replace_string }
18
+ its(:stdout){ should match "code: SCRAPER_TEST_1394485290783983" }
19
+
21
20
  end
22
21
 
23
22
  end
@@ -27,7 +27,7 @@ describe "./bin/quandl" do
27
27
  end
28
28
 
29
29
  context "info" do
30
- its(:stdout){ should match QuandlTestConfig.quandl_url }
30
+ its(:stdout){ should match Spec::Config::Quandl.quandl_url }
31
31
  its(:stderr){ should be_blank }
32
32
  end
33
33
 
data/spec/spec_helper.rb CHANGED
@@ -3,44 +3,21 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
3
  require 'yaml'
4
4
  require 'ostruct'
5
5
 
6
- QuandlTestConfig = OpenStruct.new(YAML.load(File.read(File.join(ENV['HOME'], '.quandl/test'))))
7
-
8
- ENV['QUANDL_TOKEN'] = QuandlTestConfig.token
9
- ENV['QUANDL_URL'] = QuandlTestConfig.quandl_url
6
+ # require and configure quandl_client with test config
7
+ require_relative 'config/quandl'
8
+
9
+ ENV['QUANDL_TOKEN'] = Spec::Config::Quandl.token
10
+ ENV['QUANDL_URL'] = Spec::Config::Quandl.quandl_url
10
11
 
11
12
  require "rspec"
12
13
  require 'factory_girl'
13
14
  require 'pry'
14
15
  require 'commander'
15
16
  require 'quandl/command'
16
- require 'quandl/client'
17
17
  require 'open3'
18
18
 
19
- include Quandl::Client
20
-
21
- Quandl::Client.token = QuandlTestConfig.token
22
- Quandl::Client.use QuandlTestConfig.quandl_url
23
-
24
- # disable log output
25
- class TestOutput
26
-
27
- class << self
28
- def info(*args)
29
- puts(*args)
30
- end
31
- def fatal(*args)
32
- puts(*args)
33
- end
34
- def error(*args)
35
- puts(*args)
36
- end
37
- def debug(*args)
38
- puts(*args)
39
- end
40
- end
41
-
42
- end
43
- Quandl::Logger.use(TestOutput)
19
+ # configure Quandl::Logger to use Config::Output
20
+ require_relative 'config/output'
44
21
 
45
22
  factory_dir = File.join( File.dirname(__FILE__), 'factories/**/*.rb' )
46
23
  Dir.glob( factory_dir ).each{|f| require(f); puts f }
@@ -52,7 +29,7 @@ end
52
29
  def quandl(statement)
53
30
  version = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
54
31
  path = File.join(Quandl::Command::Tasks.root, 'bin/quandl')
55
- command = "bundle exec #{path} #{statement} --token #{QuandlTestConfig.token} --url #{QuandlTestConfig.quandl_url} --threads 1 --force-yes --trace --sandbox"
32
+ command = "bundle exec #{path} #{statement} --token #{Spec::Config::Quandl.token} --url #{Spec::Config::Quandl.quandl_url} --threads 1 --force-yes --trace --sandbox"
56
33
  stdin, stdout, stderr = Open3.popen3(command)
57
34
  OpenStruct.new( stderr: stderr.read, stdout: stdout.read )
58
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -30,56 +30,56 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.3
33
+ version: 0.5.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.3
40
+ version: 0.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: quandl_client
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 2.8.0
47
+ version: 2.10.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.8.0
54
+ version: 2.10.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: quandl_data
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 1.4.1
61
+ version: 1.5.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 1.4.1
68
+ version: 1.5.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: quandl_operation
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.3.2
75
+ version: 0.4.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 0.3.2
82
+ version: 0.4.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: quandl_babelfish
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.2.6
103
+ version: 0.3.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.2.6
110
+ version: 0.3.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -380,6 +380,8 @@ files:
380
380
  - scripts/compile_ruby_pkg.sh
381
381
  - scripts/install.sh
382
382
  - scripts/win/quandl_toolbelt.iss
383
+ - spec/config/output.rb
384
+ - spec/config/quandl.rb
383
385
  - spec/factories/dataset.rb
384
386
  - spec/factories/source.rb
385
387
  - spec/fixtures/scraper-test-file.rb
@@ -426,6 +428,8 @@ signing_key:
426
428
  specification_version: 4
427
429
  summary: Quandl Toolbelt
428
430
  test_files:
431
+ - spec/config/output.rb
432
+ - spec/config/quandl.rb
429
433
  - spec/factories/dataset.rb
430
434
  - spec/factories/source.rb
431
435
  - spec/fixtures/scraper-test-file.rb