quandl 0.3.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.2"
23
- s.add_runtime_dependency "quandl_client", '2.7.8'
22
+ s.add_runtime_dependency "quandl_format", "0.4.3"
23
+ s.add_runtime_dependency "quandl_client", '2.8.0'
24
24
  s.add_runtime_dependency "quandl_data", '1.4.1'
25
25
  s.add_runtime_dependency "quandl_operation", '0.3.2'
26
- s.add_runtime_dependency "quandl_babelfish", '0.0.10'
27
- s.add_runtime_dependency "quandl_logger", '0.2.5'
26
+ s.add_runtime_dependency "quandl_babelfish", '0.0.11'
27
+ s.add_runtime_dependency "quandl_logger", '0.2.6'
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"
@@ -32,12 +32,15 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
32
32
 
33
33
  [Files]
34
34
  Source: "..\..\build\tarball\installer\rubyinstaller.exe"; DestDir: "{tmp}";
35
- Source: "..\..\build\tarball\quandl-command\bin\*.*"; DestDir: "{app}\bin"; Flags: recursesubdirs;
36
- Source: "..\..\build\tarball\quandl-command\lib\*.*"; DestDir: "{app}\lib"; Flags: recursesubdirs;
37
- Source: "..\..\build\tarball\quandl-command\config\*.*"; DestDir: "{app}\config"; Flags: recursesubdirs;
38
- Source: "..\..\build\tarball\quandl-command\vendor\*.*"; DestDir: "{app}\vendor"; Flags: recursesubdirs;
35
+ Source: "..\..\dist\resources\windows\*.*"; DestDir: "{app}\bin"; Flags: recursesubdirs;
36
+ Source: "..\..\build\tarball\quandl-command\lib\*.*"; DestDir: "{app}\current\lib"; Flags: recursesubdirs;
37
+ Source: "..\..\build\tarball\quandl-command\config\*.*"; DestDir: "{app}\current\config"; Flags: recursesubdirs;
38
+ Source: "..\..\build\tarball\quandl-command\vendor\*.*"; DestDir: "{app}\current\vendor"; Flags: recursesubdirs;
39
39
  Source: "..\..\build\tarball\quandl\quandl.bat"; DestDir: "{app}\bin"; Flags: recursesubdirs;
40
- Source: "..\..\VERSION"; DestDir: "{app}";
40
+ Source: "..\..\VERSION"; DestDir: "{app}\current";
41
+
42
+ [Dirs]
43
+ Name: "{app}\releases"; Permissions: everyone-modify
41
44
 
42
45
  [Registry]
43
46
  Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: "expandsz"; ValueName: "QuandlPath"; \
@@ -80,5 +83,7 @@ Type: filesandordirs; Name: "{app}/ruby-1.9.3"
80
83
  Type: filesandordirs; Name: "{app}/vendor"
81
84
  Type: filesandordirs; Name: "{app}/backup"
82
85
  Type: filesandordirs; Name: "{app}/update"
86
+ Type: filesandordirs; Name: "{app}/current"
87
+ Type: filesandordirs; Name: "{app}/releases"
83
88
  Type: files; Name: "{app}/*"
84
89
  Type: dirifempty; Name: "{app}"
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :dataset do
4
+ association :source, factory: :source
5
+ sequence(:code) { |n| "QUANDL_CLIENT_#{(Time.now.to_f * 1000).to_i}_#{n}" }
6
+ name "Quandl Client Dataset"
7
+ description "Quandl Client Dataset Spec"
8
+ end
9
+
10
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :source do
4
+ sequence(:code) { |n| "QUANDL_CLIENT_#{(Time.now.to_f * 1000).to_i}_#{n}" }
5
+ name "Quandl Client Source"
6
+ description "Quandl Client Source Spec"
7
+ sequence(:host) { |n| "http://quandl.com/host/#{(Time.now.to_f * 1000).to_i}_#{n}" }
8
+ end
9
+
10
+ end
@@ -5,11 +5,17 @@ describe "./bin/quandl delete" do
5
5
 
6
6
  let(:command){ self.class.superclass.description }
7
7
  subject{ quandl("delete #{command}") }
8
+
8
9
 
9
10
  context "DOES_NOT_EXIST" do
10
11
  its(:stdout){ should match 'Not Found' }
11
12
  end
12
13
 
14
+ context "DATASET_1" do
15
+ before(:each){ create(:dataset, code: 'DATASET_1') }
16
+ its(:stdout){ should match 'Deleted' }
17
+ end
18
+
13
19
  end
14
20
 
15
21
  describe Quandl::Command::Tasks::Delete do
@@ -22,7 +28,7 @@ describe Quandl::Command::Tasks::Delete do
22
28
  before(:each){ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/datasets.qdf' ) }
23
29
 
24
30
  it "should delete spec/fixtures/data/datasets.qdf" do
25
- TestOutput.should_receive(:info).with(/OK/).at_least(4).times
31
+ TestOutput.should_receive(:info).with(/Deleted/).at_least(4).times
26
32
  datasets = Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf')
27
33
  datasets.each{|d| Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) }
28
34
  end
@@ -10,7 +10,7 @@ describe "./bin/quandl replace" do
10
10
  subject{ quandl( [prefix, command].flatten.join(" ") ) }
11
11
 
12
12
  context data_path("replace.qdf") do
13
- its(:stdout){ should match /OK|Created/ }
13
+ its(:stdout){ should match /Updated|Created/ }
14
14
  its(:stderr){ should be_blank }
15
15
  end
16
16
 
@@ -8,11 +8,42 @@ describe "Quandl::Command::Tasks::Schedule" do
8
8
 
9
9
  its "should parse 'at' time to cron correctly " do
10
10
  schedule.stub_chain(:options, :at){'13:00'}
11
- schedule.instance_eval{cron_at}.should == "0 13 * * *"
11
+ schedule.instance_eval{cron_at}.should == "* 0 13 * * *"
12
12
  end
13
13
 
14
14
  its "should parse 'at' time to cron correctly " do
15
15
  schedule.stub_chain(:options, :at){'7pm monday'}
16
- schedule.instance_eval{cron_at}.should == "0 19 * * 1"
16
+ schedule.instance_eval{cron_at}.should == "* 0 19 * * 1"
17
17
  end
18
+ end
19
+
20
+ describe "./bin/quandl schedule" do
21
+
22
+ let(:command){ self.class.superclass.description }
23
+ subject{ quandl("schedule #{command}") }
24
+
25
+ context "list" do
26
+ its(:stdout){ should_not match "scraper-test-file.rb" }
27
+ end
28
+
29
+ context "add spec/fixtures/scraper-test-file.rb" do
30
+ its(:stdout){ should match "You have successfully scheduled 'scraper-test-file.rb'" }
31
+ end
32
+
33
+ context "delete scraper-test-file.rb --force-yes" do
34
+ its(:stdout){ should match "You have successfully deleted 'scraper-test-file.rb'" }
35
+ end
36
+
37
+ context "add spec/fixtures/scraper-test-file.rb --at 7pm" do
38
+ its(:stdout){ should match "You have successfully scheduled 'scraper-test-file.rb'" }
39
+ end
40
+
41
+ context "list" do
42
+ its(:stdout){ should match "scraper-test-file.rb Scheduled: every day at 23:00"}
43
+ end
44
+
45
+ context "delete scraper-test-file.rb --force-yes" do
46
+ its(:stdout){ should match "You have successfully deleted 'scraper-test-file.rb'" }
47
+ end
48
+
18
49
  end
@@ -14,7 +14,7 @@ describe "./bin/quandl superset" do
14
14
  end
15
15
 
16
16
  context "upload spec/fixtures/superset.qdf" do
17
- its(:stdout){ should match /Created|OK/ }
17
+ its(:stdout){ should match /Created|Updated/ }
18
18
  end
19
19
 
20
20
  context "download SUPERSET_EXAMPLE" do
@@ -22,7 +22,7 @@ describe "./bin/quandl superset" do
22
22
  end
23
23
 
24
24
  context "delete SUPERSET_EXAMPLE" do
25
- its(:stdout){ should match /OK/ }
25
+ its(:stdout){ should match /Deleted/ }
26
26
  end
27
27
 
28
28
  end
@@ -8,17 +8,17 @@ describe "./bin/quandl upload" do
8
8
  subject{ quandl( [prefix, command].flatten.join(" ") ) }
9
9
 
10
10
  context data_path("datasets.qdf") do
11
- its(:stdout){ should match /OK|Created/ }
11
+ its(:stdout){ should match /Updated|Created/ }
12
12
  its(:stderr){ should be_blank }
13
13
  end
14
14
 
15
15
  context data_path("metadata.qdf") do
16
- its(:stdout){ should match /OK|Created/ }
16
+ its(:stdout){ should match /Updated|Created/ }
17
17
  its(:stderr){ should be_blank }
18
18
  end
19
19
 
20
20
  context data_path("QUGC-42.qdf") do
21
- its(:stdout){ should match /OK|Created/ }
21
+ its(:stdout){ should match /Updated|Created/ }
22
22
  its(:stderr){ should be_blank }
23
23
  end
24
24
 
@@ -13,7 +13,7 @@ describe "./bin/quandl" do
13
13
  end
14
14
 
15
15
  context "upload spec/fixtures/data/metadata.qdf" do
16
- its(:stdout){ should match /Created|OK/ }
16
+ its(:stdout){ should match /Created|Updated/ }
17
17
  its(:stderr){ should be_blank }
18
18
  end
19
19
 
@@ -23,11 +23,11 @@ describe "./bin/quandl" do
23
23
  end
24
24
 
25
25
  context "delete TEST_1 TEST_5 TEST_15 --force-yes" do
26
- its(:stdout){ should match 'OK' }
26
+ its(:stdout){ should match 'Deleted' }
27
27
  end
28
28
 
29
29
  context "info" do
30
- its(:stdout){ should match ENV['QUANDL_TEST_URL'] }
30
+ its(:stdout){ should match QuandlTestConfig.quandl_url }
31
31
  its(:stderr){ should be_blank }
32
32
  end
33
33
 
@@ -1,15 +1,26 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
3
+ require 'yaml'
4
+ require 'ostruct'
5
+
6
+ QuandlTestConfig = OpenStruct.new(YAML.load(File.read(File.join(ENV['HOME'], '.quandl/test'))))
2
7
 
3
- ENV['QUANDL_TOKEN'] = ENV['QUANDL_TEST_TOKEN']
4
- ENV['QUANDL_URL'] = ENV['QUANDL_TEST_URL']
8
+ ENV['QUANDL_TOKEN'] = QuandlTestConfig.token
9
+ ENV['QUANDL_URL'] = QuandlTestConfig.quandl_url
5
10
 
6
11
  require "rspec"
7
12
  require 'factory_girl'
8
13
  require 'pry'
9
14
  require 'commander'
10
15
  require 'quandl/command'
16
+ require 'quandl/client'
11
17
  require 'open3'
12
18
 
19
+ include Quandl::Client
20
+
21
+ Quandl::Client.token = QuandlTestConfig.token
22
+ Quandl::Client.use QuandlTestConfig.quandl_url
23
+
13
24
  # disable log output
14
25
  class TestOutput
15
26
 
@@ -41,7 +52,7 @@ end
41
52
  def quandl(statement)
42
53
  version = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
43
54
  path = File.join(Quandl::Command::Tasks.root, 'bin/quandl')
44
- command = "bundle exec #{path} #{statement} --token #{ENV['QUANDL_TEST_TOKEN']} --url #{ENV['QUANDL_TEST_URL']} --force-yes --trace"
55
+ command = "bundle exec #{path} #{statement} --token #{QuandlTestConfig.token} --url #{QuandlTestConfig.quandl_url} --threads 1 --force-yes --trace --sandbox"
45
56
  stdin, stdout, stderr = Open3.popen3(command)
46
57
  OpenStruct.new( stderr: stderr.read, stdout: stdout.read )
47
58
  end
@@ -27,42 +27,48 @@ def windows_root
27
27
  end
28
28
  end
29
29
 
30
- namespace :toolbelt do
30
+ namespace :quandl do
31
31
 
32
32
  namespace :release do
33
33
 
34
34
  desc "Build tarball, windows, and darwin and push to storage"
35
- task :all, :revision do |t, args|
35
+ task :all do |t, args|
36
36
  # build tarball
37
- Rake::Task["toolbelt:release:tarball"].execute args.to_hash
37
+ Rake::Task["quandl:release:tarball"].execute args.to_hash
38
38
  # build windows exe
39
- Rake::Task["toolbelt:release:windows"].execute args.to_hash
39
+ Rake::Task["quandl:release:windows"].execute args.to_hash
40
40
  # build darwin pkg
41
- Rake::Task["toolbelt:release:darwin"].execute args.to_hash
41
+ Rake::Task["quandl:release:darwin"].execute args.to_hash
42
42
  end
43
43
 
44
44
  desc "Build tarball and push to storage"
45
- task :tarball, :revision do |t, args|
45
+ task :tarball do
46
+ revision = `git branch | grep '*'`.gsub("*", '').strip.rstrip
47
+ args = {}
48
+ args[:revision] = revision unless revision == 'master'
46
49
  # build package
47
- Rake::Task["toolbelt:build:tarball"].execute args.to_hash
50
+ Rake::Task["quandl:build:tarball"].execute args
48
51
  # push package to s3
49
- Rake::Task["toolbelt:push:tarball"].execute args.to_hash
52
+ Rake::Task["quandl:push:tarball"].execute args
50
53
  end
51
54
 
52
55
  desc "Build darwin and push to storage"
53
- task :darwin, :revision do |t, args|
56
+ task :darwin do |t, args|
54
57
  # build package
55
- Rake::Task["toolbelt:build:darwin"].execute args.to_hash
58
+ Rake::Task["quandl:build:darwin"].execute args.to_hash
56
59
  # push package to s3
57
- Rake::Task["toolbelt:push:darwin"].execute args.to_hash
60
+ Rake::Task["quandl:push:darwin"].execute args.to_hash
58
61
  end
59
62
 
60
63
  desc "Build windows executable and push to storage"
61
- task :windows, :revision do |t, args|
64
+ task :windows do |t, args|
65
+ revision = `git branch | grep '*'`.gsub("*", '').strip.rstrip
66
+ args = {}
67
+ args[:revision] = revision unless revision == 'master'
62
68
  # build tarball
63
- Rake::Task["toolbelt:build:tarball"].execute args.to_hash
69
+ Rake::Task["quandl:build:tarball"].execute args.to_hash.merge({ platform: 'windows' })
64
70
  # push tarball to s3
65
- Rake::Task["toolbelt:push:tarball"].execute args.to_hash.merge( platform: 'windows' )
71
+ Rake::Task["quandl:push:tarball"].execute args.to_hash.merge( platform: 'windows' )
66
72
  # prereleases should not build Quandl Setup
67
73
  unless args[:revision].present?
68
74
  # inno is required
@@ -71,7 +77,7 @@ namespace :toolbelt do
71
77
  puts "Cannot build 'Quandl Setup.exe'"
72
78
  else
73
79
  # create windows exe setup
74
- Rake::Task["toolbelt:build:windows"].execute
80
+ Rake::Task["quandl:build:windows"].execute
75
81
  # push windows-package to s3
76
82
  input_file = File.join( Toolbelt.pkg_path, 'Quandl Setup.exe')
77
83
  # upload to s3
@@ -92,7 +98,7 @@ namespace :toolbelt do
92
98
  Toolbelt::Build::Windows.execute args.to_hash
93
99
  end
94
100
 
95
- task :tarball, :revision do |t, args|
101
+ task :tarball, :revision, :platform do |t, args|
96
102
  Toolbelt::Build::Tarball.execute args.to_hash
97
103
  end
98
104
 
@@ -120,10 +126,13 @@ namespace :toolbelt do
120
126
  end
121
127
 
122
128
  task :darwin, :revision, :platform do |t,args|
123
- Toolbelt::Storage.create( 'quandl-toolbelt.pkg', File.open( File.join(Toolbelt.build_path, 'quandl-toolbelt.pkg') ) )
129
+ name = "quandl-toolbelt"
130
+ name += "-#{args[:revision]}" if args[:revision].present?
131
+ Toolbelt::Storage.create( "#{name}.pkg", File.open( File.join(Toolbelt.build_path, 'quandl-toolbelt.pkg') ) )
132
+ Toolbelt::Storage.create( "VERSION", File.open( File.join(Toolbelt.root_path, 'VERSION') ) )
133
+
124
134
  end
125
135
 
126
136
  end
127
-
128
137
 
129
138
  end
@@ -15,6 +15,10 @@ class Toolbelt
15
15
  @resource_path ||= File.join(root_path, "dist/resources/")
16
16
  end
17
17
 
18
+ def pkg_releases_path
19
+ @pkg_releases_path ||= File.join( build_path, 'releases' )
20
+ end
21
+
18
22
  def release_path
19
23
  @release_path ||= File.join(tarball_path, "quandl-command" )
20
24
  end
@@ -46,12 +50,12 @@ class Toolbelt
46
50
  def trace?
47
51
  Rake.application.options.trace == true
48
52
  end
49
-
53
+
50
54
  end
51
55
 
52
56
  attr_accessor :args, :options, :block
53
57
 
54
- delegate :root_path, :ruby_pkg_path, :pkg_path, :tmp_path, :build_path, :tarball_path, :release_path, :resource_path, :trace?, to: :class
58
+ delegate :root_path, :ruby_pkg_path, :pkg_path, :tmp_path, :build_path, :tarball_path, :pkg_releases_path, :release_path, :resource_path, :trace?, to: :class
55
59
 
56
60
  def initialize(*args, &block)
57
61
  self.options = OpenStruct.new(args.extract_options!)
@@ -72,6 +76,26 @@ class Toolbelt
72
76
  run_callbacks(:ensure)
73
77
  end
74
78
  end
79
+
80
+ def timestamp
81
+ @timestamp ||= (Time.now.getutc.to_f * 10000).to_i.to_s.gsub('.','')
82
+ end
83
+
84
+ def git_short_reference
85
+ @git_short_reference ||= git_reference[0..7]
86
+ end
87
+
88
+ def git_reference
89
+ @git_reference ||= `git rev-parse HEAD`.strip.rstrip
90
+ end
91
+
92
+ def git_branch
93
+ @git_branch ||= `git rev-parse --abbrev-ref HEAD`.strip.rstrip
94
+ end
95
+
96
+ def prerelease_information
97
+ "(#{git_branch.split('/').first}/#{git_short_reference})" unless git_branch == 'master'
98
+ end
75
99
 
76
100
  def revision
77
101
  @revision ||= options.revision.to_s.gsub("/","-") || "master"
@@ -12,32 +12,77 @@ class Tasks::Toolbelt::Build::Darwin < Tasks::Toolbelt
12
12
  # compile build
13
13
  Tasks::Toolbelt::Build::Tarball.execute(options)
14
14
 
15
- rm "#{release_path}/bin/quandl"
16
- cp resource("pkg/quandl"), "#{release_path}/bin/quandl"
15
+ create_release
16
+ add_quandl_executable
17
+
18
+ generate_distribution
19
+ generate_package_info
20
+ generate_postinstall
21
+ generate_bom
17
22
 
18
- kbytes = %x{ du -ks #{release_path} | cut -f 1 }.strip.rstrip
19
- num_files = %x{ find #{release_path} | wc -l }.strip.rstrip
23
+ add_payload
24
+ add_ruby
20
25
 
26
+ package_and_sign
27
+
28
+ end
29
+
30
+ def kbytes
31
+ @kbytes ||= %x{ du -ks #{release_path} | cut -f 1 }.strip.rstrip
32
+ end
33
+
34
+ def num_files
35
+ @num_files ||= %x{ find #{release_path} | wc -l }.strip.rstrip
36
+ end
37
+
38
+ private
39
+
40
+ def create_release
41
+ # create releases dir and move quandl into it
42
+ mv release_path, "#{pkg_releases_path}/#{timestamp}"
43
+ mkdir_p release_path
44
+ mv pkg_releases_path, "#{release_path}/releases"
45
+ end
46
+
47
+ def add_quandl_executable
48
+ mkdir_p "#{release_path}/bin"
49
+ cp resource("pkg/quandl"), "#{release_path}/bin/quandl"
50
+ end
51
+
52
+ def generate_distribution
21
53
  mkdir_p "#{pkg_path}/Resources"
22
54
  mkdir_p "#{pkg_path}/quandl-toolbelt.pkg"
23
55
 
24
56
  dist = File.read(resource("pkg/Distribution.erb"))
25
57
  dist = ERB.new(dist).result(binding)
26
58
  File.open("#{pkg_path}/Distribution", "w") { |f| f.puts dist }
27
-
59
+ end
60
+
61
+ def generate_package_info
28
62
  dist = File.read(resource("pkg/PackageInfo.erb"))
29
63
  dist = ERB.new(dist).result(binding)
30
64
  File.open("#{pkg_path}/quandl-toolbelt.pkg/PackageInfo", "w") { |f| f.puts dist }
31
-
65
+ end
66
+
67
+ def generate_postinstall
68
+ file = File.read(resource("pkg/postinstall.erb"))
69
+ file = ERB.new(file).result(binding)
32
70
  mkdir_p "#{pkg_path}/quandl-toolbelt.pkg/Scripts"
33
- cp resource("pkg/postinstall"), "#{pkg_path}/quandl-toolbelt.pkg/Scripts/postinstall"
71
+ File.open("#{pkg_path}/quandl-toolbelt.pkg/Scripts/postinstall", "w") { |f| f.puts file }
34
72
  chmod 0755, "#{pkg_path}/quandl-toolbelt.pkg/Scripts/postinstall"
35
-
73
+ end
74
+
75
+ def generate_bom
36
76
  sh %{ mkbom -s #{release_path} #{pkg_path}/quandl-toolbelt.pkg/Bom }
37
-
77
+ end
78
+
79
+ def add_payload
38
80
  Dir.chdir(release_path) do
39
81
  sh %{ pax -wz -x cpio . > #{pkg_path}/quandl-toolbelt.pkg/Payload }
40
82
  end
83
+ end
84
+
85
+ def add_ruby
41
86
 
42
87
  # download, compile, and build ruby pkg unless already done
43
88
  Tasks::Toolbelt::Build::Ruby.execute unless File.exists?(File.join(build_path, 'ruby.pkg'))
@@ -49,20 +94,22 @@ class Tasks::Toolbelt::Build::Darwin < Tasks::Toolbelt
49
94
  mv "ruby.pkg", "#{pkg_path}/ruby.pkg"
50
95
  end
51
96
 
97
+ end
98
+
99
+ def package_and_sign
52
100
  sh %{ pkgutil --flatten #{pkg_path} #{build_path}/quandl-toolbelt-unsigned.pkg }
53
101
  sh %{ productsign --sign #{CERTIFICATE_ID} #{build_path}/quandl-toolbelt-unsigned.pkg #{build_path}/quandl-toolbelt.pkg }
54
102
 
55
103
  end
56
104
 
57
- protected
58
-
59
-
60
105
  def clean
61
106
  rm "#{build_path}/quandl-toolbelt.pkg" if File.exists?("#{build_path}/quandl-toolbelt.pkg")
62
107
  rm_rf tmp_path
63
108
  mkdir_p tmp_path
64
109
  rm_rf pkg_path
65
110
  mkdir_p pkg_path
111
+ rm_rf pkg_releases_path
112
+ mkdir_p pkg_releases_path
66
113
  end
67
114
 
68
115
  def cleanup