quandl 0.2.22

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.
Files changed (54) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +20 -0
  4. data/Gemfile +14 -0
  5. data/Guardfile +8 -0
  6. data/LICENSE +7 -0
  7. data/README.md +316 -0
  8. data/Rakefile +39 -0
  9. data/UPGRADE.md +143 -0
  10. data/bin/quandl +26 -0
  11. data/dist/resources/pkg/Distribution.erb +15 -0
  12. data/dist/resources/pkg/PackageInfo.erb +6 -0
  13. data/dist/resources/pkg/postinstall +45 -0
  14. data/dist/resources/pkg/quandl +25 -0
  15. data/dist/resources/ruby/PackageInfo +3 -0
  16. data/lib/commander/command/quandl_ext.rb +21 -0
  17. data/lib/quandl/command.rb +45 -0
  18. data/lib/quandl/command/client_ext.rb +1 -0
  19. data/lib/quandl/command/client_ext/user.rb +11 -0
  20. data/lib/quandl/command/compatibility_check.rb +11 -0
  21. data/lib/quandl/command/qconfig.rb +76 -0
  22. data/lib/quandl/command/tasks.rb +15 -0
  23. data/lib/quandl/command/tasks/base.rb +263 -0
  24. data/lib/quandl/command/tasks/delete.rb +58 -0
  25. data/lib/quandl/command/tasks/download.rb +111 -0
  26. data/lib/quandl/command/tasks/info.rb +46 -0
  27. data/lib/quandl/command/tasks/list.rb +40 -0
  28. data/lib/quandl/command/tasks/login.rb +46 -0
  29. data/lib/quandl/command/tasks/update.rb +205 -0
  30. data/lib/quandl/command/tasks/upload.rb +69 -0
  31. data/lib/quandl/command/version.rb +5 -0
  32. data/lib/quandl/utility.rb +2 -0
  33. data/lib/quandl/utility/config.rb +43 -0
  34. data/lib/quandl/utility/ruby_version.rb +143 -0
  35. data/quandl.gemspec +39 -0
  36. data/scripts/compile_ruby_pkg.sh +34 -0
  37. data/scripts/install.sh +51 -0
  38. data/scripts/win/quandl_toolbelt.iss +82 -0
  39. data/spec/lib/quandl/command/delete_spec.rb +31 -0
  40. data/spec/lib/quandl/command/download_spec.rb +42 -0
  41. data/spec/lib/quandl/command/upload_spec.rb +39 -0
  42. data/spec/lib/quandl/command_spec.rb +46 -0
  43. data/spec/spec_helper.rb +20 -0
  44. data/tasks/toolbelt.rake +133 -0
  45. data/tasks/toolbelt.rb +92 -0
  46. data/tasks/toolbelt/build.rb +2 -0
  47. data/tasks/toolbelt/build/darwin.rb +71 -0
  48. data/tasks/toolbelt/build/ruby.rb +105 -0
  49. data/tasks/toolbelt/build/tarball.rb +73 -0
  50. data/tasks/toolbelt/build/windows.rb +25 -0
  51. data/tasks/toolbelt/push.rb +15 -0
  52. data/tasks/toolbelt/storage.rb +28 -0
  53. data/tasks/toolbelt/tar.rb +21 -0
  54. metadata +354 -0
@@ -0,0 +1,143 @@
1
+ ### usage examples
2
+ # RubyVersion
3
+ ### check for the main version with a Float
4
+ # RubyVersion.is? 1.8
5
+ ### use strings for exacter checking
6
+ # RubyVersion.is.above '1.8.7'
7
+ # RubyVersion.is.at_least '1.8.7' # or below, at_most, not
8
+ ### you can use the common comparison operators
9
+ # RubyVersion >= '1.8.7'
10
+ # RubyVersion.is.between? '1.8.6', '1.8.7'
11
+ ### relase date checks
12
+ # RubyVersion.is.older_than Date.today
13
+ # RubyVersion.is.newer_than '2009-08-19'
14
+ ### accessors
15
+ # RubyVersion.major # e.g. => 1
16
+ # RubyVersion.minor # e.g. => 8
17
+ # RubyVersion.tiny # e.g. => 7
18
+ # RubyVersion.patchlevel # e.g. => 249
19
+ # RubyVersion.description # e.g. => "ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]"
20
+
21
+ require 'date'
22
+ require 'time'
23
+
24
+ module Quandl
25
+ module Utility
26
+ module RubyVersion
27
+ class << self
28
+ def to_s
29
+ RUBY_VERSION
30
+ end
31
+
32
+ def full_version
33
+ "#{RUBY_VERSION}-p#{patchlevel}"
34
+ end
35
+
36
+ # comparable
37
+ def <=>(other)
38
+ value = case other
39
+ when Integer
40
+ RUBY_VERSION.to_i
41
+ when Float
42
+ RUBY_VERSION.to_f
43
+ when String
44
+ RUBY_VERSION
45
+ when Date,Time
46
+ other.class.parse(RUBY_RELEASE_DATE)
47
+ else
48
+ other = other.to_s
49
+ RUBY_VERSION
50
+ end
51
+ value <=> other
52
+ end
53
+ include Comparable
54
+
55
+ # chaining for dsl-like language
56
+ def is?(other = nil)
57
+ if other
58
+ RubyVersion == other
59
+ else
60
+ RubyVersion
61
+ end
62
+ end
63
+ alias is is?
64
+
65
+ # aliases
66
+ alias below <
67
+ alias below? <
68
+ alias at_most <=
69
+ alias at_most? <=
70
+ alias above >
71
+ alias above? >
72
+ alias at_least >=
73
+ alias at_least? >=
74
+ alias exactly ==
75
+ alias exactly? ==
76
+ def not(other)
77
+ self != other
78
+ end
79
+ alias not? not
80
+ alias between between?
81
+
82
+ # compare dates
83
+ def newer_than(other)
84
+ if other.is_a? Date or other.is_a? Time
85
+ RubyVersion > other
86
+ else
87
+ RUBY_RELEASE_DATE > other.to_s
88
+ end
89
+ end
90
+ alias newer_than? newer_than
91
+
92
+ def older_than(other)
93
+ if other.is_a? Date or other.is_a? Time
94
+ RubyVersion < other
95
+ else
96
+ RUBY_RELEASE_DATE < other.to_s
97
+ end
98
+ end
99
+ alias older_than? older_than
100
+
101
+ def released_today
102
+ RubyVersion.date == Date.today
103
+ end
104
+ alias released_today? released_today
105
+
106
+ # accessors
107
+
108
+ def major
109
+ RUBY_VERSION.to_i
110
+ end
111
+ alias main major
112
+
113
+ def minor
114
+ RUBY_VERSION.split('.')[1].to_i
115
+ end
116
+ alias mini minor
117
+
118
+ def tiny
119
+ RUBY_VERSION.split('.')[2].to_i
120
+ end
121
+
122
+ alias teeny tiny
123
+
124
+ def patchlevel
125
+ RUBY_PATCHLEVEL
126
+ end
127
+
128
+ def platform
129
+ RUBY_PLATFORM
130
+ end
131
+
132
+ def release_date
133
+ Date.parse RUBY_RELEASE_DATE
134
+ end
135
+ alias date release_date
136
+
137
+ def description
138
+ RUBY_DESCRIPTION
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
data/quandl.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "quandl/command/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "quandl"
7
+ s.version = Quandl::Command::VERSION
8
+ s.authors = ["Blake Hilscher"]
9
+ s.email = ["blake@hilscher.ca"]
10
+ s.homepage = "http://blake.hilscher.ca/"
11
+ s.license = "MIT"
12
+ s.summary = "Quandl Toolbelt"
13
+ s.description = "http://quandl.com/help/toolbelt"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = ["quandl"]
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency "commander", '4.1.5'
21
+ s.add_runtime_dependency "quandl_format", "0.2.8"
22
+ s.add_runtime_dependency "quandl_client", '2.5.1'
23
+ s.add_runtime_dependency "quandl_data", '1.3.9'
24
+ s.add_runtime_dependency "quandl_operation", '0.3.2'
25
+ s.add_runtime_dependency "quandl_babelfish", '0.0.9'
26
+ s.add_runtime_dependency "quandl_logger", '0.2.5'
27
+ s.add_runtime_dependency "json", '1.7.7'
28
+ s.add_runtime_dependency "minitar", '0.5.4'
29
+ s.add_runtime_dependency "thread", "0.1.3"
30
+
31
+ s.add_development_dependency "rake", "~> 10.1"
32
+ s.add_development_dependency "fog", "~> 1.19"
33
+ s.add_development_dependency "factory_girl", "~> 4.3"
34
+ s.add_development_dependency "rspec", "~> 2.13"
35
+ s.add_development_dependency "fivemat", "~> 1.2"
36
+ s.add_development_dependency "pry", "~> 0.9"
37
+ s.add_development_dependency "guard", "~> 2.3"
38
+ s.add_development_dependency "guard-rspec", "~> 4.2"
39
+ end
@@ -0,0 +1,34 @@
1
+ # configure
2
+ arch_flags="-mmacosx-version-min=10.5"
3
+ export CFLAGS="$arch_flags "
4
+ export CXXFLAGS="$arch_flags"
5
+ export CPPFLAGS="$arch_flags"
6
+ export LDFLAGS="$arch_flags"
7
+ export OBJCFLAGS="$arch_flags"
8
+ export OBJCXXFLAGS="$arch_flags"
9
+
10
+ QUANDL_PATH=/usr/local/quandl
11
+ INSTALL_PATH=$QUANDL_PATH/ruby/
12
+ ROOT_DIR=$(pwd)
13
+ # clean
14
+ rm -rf $INSTALL_PATH
15
+ rm -rf $ROOT_DIR/*
16
+ # download
17
+ wget http://xyz.lcs.mit.edu/ruby/ruby-1.9.3-p448.zip
18
+ extract ruby-1.9.3-p448.zip
19
+ cd ruby-1.9.3-p448
20
+ # compile
21
+ ./configure --with-static-linked-ext --prefix=$INSTALL_PATH
22
+ make
23
+ sudo make install
24
+ # make package
25
+ sudo chown $USER:staff $QUANDL_PATH
26
+ mkdir $QUANDL_PATH/ruby-1.9.3-p448-pkg/
27
+ cp $ROOT_DIR/../dist/resources/ruby/PackageInfo $QUANDL_PATH/ruby-1.9.3-p448-pkg/PackageInfo
28
+ cd $INSTALL_PATH
29
+ mkbom -s . $QUANDL_PATH/ruby-1.9.3-p448-pkg/Bom
30
+ pax -wz -x cpio . > $QUANDL_PATH/ruby-1.9.3-p448-pkg/Payload
31
+ # package
32
+ cd $QUANDL_PATH
33
+ pkgutil --flatten ruby-1.9.3-p448-pkg $ROOT_DIR/ruby.pkg
34
+ cd $ROOT_DIR
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ {
3
+ PACKAGE_URL="https://s3.amazonaws.com/quandl-command/quandl-command$1.tar.gz"
4
+ PACKAGE_PATH="/usr/local/quandl"
5
+
6
+ echo "Welcome to the Quandl Toolbelt."
7
+ ruby -v >/dev/null 2>&1 || { echo -e >&2 "\033[0;31mI require ruby 1.9 but it's not installed. Aborting.
8
+ \033[0;33mapt-get install ruby1.9.1\033[0;29m"; exit 1; }
9
+ echo "Superuser is required, you will be prompted for your password."
10
+
11
+ # clear sudo
12
+ sudo -k
13
+ # run inside sudo
14
+ sudo bash <<SCRIPT
15
+
16
+ rm -rf "$PACKAGE_PATH.new"
17
+ mkdir -p "$PACKAGE_PATH.new"
18
+ cd "$PACKAGE_PATH.new"
19
+
20
+ if [[ -z "$(which wget)" ]]; then
21
+ curl -s $PACKAGE_URL | tar xz
22
+ else
23
+ wget -qO- $PACKAGE_URL | tar xz
24
+ fi
25
+
26
+ if [ -d "quandl-command" ]; then
27
+ mv quandl-command/* .
28
+ rmdir quandl-command
29
+ rm -rf $PACKAGE_PATH
30
+ mv "$PACKAGE_PATH.new" "$PACKAGE_PATH"
31
+ sudo chown -R $USER:$GROUP $PACKAGE_PATH
32
+ else
33
+ echo -e "\033[0;33mWARNING: Revision $1 not found. \033[0;29m"
34
+ rmdir "$PACKAGE_PATH.new"
35
+ fi
36
+ SCRIPT
37
+ # remind the user to add to $PATH
38
+ if [[ ":$PATH:" != *":/usr/local/quandl/bin:"* ]]; then
39
+ echo "----"
40
+ echo -e "Installation is complete, but there is one more step you need to take."
41
+ echo -e "\033[0;33mBefore you start using Quandl Toolbelt, you must type: 'source $HOME/.bash_profile'\033[0;29m"
42
+
43
+ echo "
44
+ # Added by Quandl Toolbelt
45
+ PATH=\"/usr/local/quandl/bin:\$PATH\"" >> "$HOME/.bash_profile"
46
+ else
47
+ echo "----"
48
+ echo -e "\033[0;32mInstallation complete!\033[0;29m"
49
+ fi
50
+
51
+ }
@@ -0,0 +1,82 @@
1
+ ; Script generated by the Inno Setup Script Wizard.
2
+ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3
+
4
+ #define MyAppName "Quandl Toolbelt"
5
+ #define MyAppVersion "0.1"
6
+ #define MyAppPublisher "Quandl"
7
+ #define MyAppURL "http://www.quandl.com/"
8
+ #define MyAppExeName "quandl.bat"
9
+
10
+ [Setup]
11
+ ; NOTE: The value of AppId uniquely identifies this application.
12
+ ; Do not use the same AppId value in installers for other applications.
13
+ ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
14
+ AppId={{BC3A2597-57FE-4B8E-8105-B2945862AA97}
15
+ AppName={#MyAppName}
16
+ AppVersion={#MyAppVersion}
17
+ ;AppVerName={#MyAppName} {#MyAppVersion}
18
+ AppPublisher={#MyAppPublisher}
19
+ AppPublisherURL={#MyAppURL}
20
+ AppSupportURL={#MyAppURL}
21
+ AppUpdatesURL={#MyAppURL}
22
+ DefaultDirName=c:\Quandl
23
+ DisableDirPage=yes
24
+ DefaultGroupName={#MyAppName}
25
+ OutputBaseFilename=Quandl Setup
26
+ OutputDir=..\..\build\pkg\
27
+ Compression=lzma
28
+ SolidCompression=yes
29
+
30
+ [Languages]
31
+ Name: "english"; MessagesFile: "compiler:Default.isl"
32
+
33
+ [Files]
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\vendor\*.*"; DestDir: "{app}\vendor"; Flags: recursesubdirs;
38
+ Source: "..\..\build\tarball\quandl\quandl.bat"; DestDir: "{app}\bin"; Flags: recursesubdirs;
39
+
40
+ [Registry]
41
+ Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: "expandsz"; ValueName: "QuandlPath"; \
42
+ ValueData: "{app}"
43
+ Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: "expandsz"; ValueName: "Path"; \
44
+ ValueData: "{olddata};{app}\bin"; Check: NeedsAddPath(ExpandConstant('{app}\bin'))
45
+
46
+ [Run]
47
+ Filename: "{tmp}\rubyinstaller.exe"; Parameters: "/verysilent /noreboot /nocancel /noicons /dir=""{app}/ruby-1.9.3"""; \
48
+ Flags: shellexec waituntilterminated; StatusMsg: "Installing Ruby"; AfterInstall: MyProgress(1);
49
+ [Code]
50
+
51
+ procedure MyProgress(Mult: Integer);
52
+ begin
53
+ WizardForm.ProgressGauge.Min := 0;
54
+ WizardForm.ProgressGauge.Max := 100;
55
+ WizardForm.ProgressGauge.Position := Mult*33;
56
+ end;
57
+
58
+ function NeedsAddPath(Param: string): boolean;
59
+ var
60
+ OrigPath: string;
61
+ begin
62
+ if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
63
+ 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
64
+ 'Path', OrigPath)
65
+ then begin
66
+ Result := True;
67
+ exit;
68
+ end;
69
+ // look for the path with leading and trailing semicolon
70
+ // Pos() returns 0 if not found
71
+ Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
72
+ end;
73
+
74
+ [UninstallDelete]
75
+ Type: filesandordirs; Name: "{app}/bin"
76
+ Type: filesandordirs; Name: "{app}/lib"
77
+ Type: filesandordirs; Name: "{app}/ruby-1.9.3"
78
+ Type: filesandordirs; Name: "{app}/vendor"
79
+ Type: filesandordirs; Name: "{app}/backup"
80
+ Type: filesandordirs; Name: "{app}/update"
81
+ Type: files; Name: "{app}/*"
82
+ Type: dirifempty; Name: "{app}"
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Quandl::Command::Tasks::Delete do
5
+
6
+ let(:subject_args){ [] }
7
+ subject{ Quandl::Command::Tasks::Delete.call(*subject_args) }
8
+
9
+ context "spec/fixtures/data/datasets.qdf" do
10
+
11
+ before(:each){ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/datasets.qdf' ) }
12
+
13
+ it "should delete spec/fixtures/data/datasets.qdf" do
14
+ Quandl::Logger.should_receive(:info).with(/Deleted/).exactly(4).times
15
+ # load each dataset from file
16
+ datasets = Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf')
17
+ # send command to delete each dataset
18
+ datasets.each{|d| Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) }
19
+
20
+ Quandl::Logger.should_receive(:error).with(/Not Found/).exactly(4).times
21
+ datasets.each{|d| Quandl::Command::Tasks::Download.call( d.code ) }
22
+ end
23
+
24
+ end
25
+
26
+ it "should fail to delete missing dataset" do
27
+ Quandl::Logger.should_receive(:error).with(/Not Found/).exactly(1).times
28
+ Quandl::Command::Tasks::Delete.call("DOES_NOT_EXIST", force_yes: true )
29
+ end
30
+
31
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Quandl::Command::Tasks::Download do
5
+
6
+ def self.it_should_download(code, options={})
7
+ it "should download #{code}, #{options}" do
8
+ Quandl::Logger.should_receive(:info).with(/code: #{code}/)
9
+ Quandl::Command::Tasks::Download.call( code, options )
10
+ end
11
+ end
12
+
13
+ context "spec/fixtures/data/datasets.qdf" do
14
+
15
+ before(:all){ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/datasets.qdf' ) }
16
+
17
+ it_should_download 'TEST_1'
18
+ it_should_download 'TEST_2'
19
+ it_should_download 'TEST_4', column: 2
20
+ it_should_download 'TEST_4', order: 'asc'
21
+ it_should_download 'TEST_4', order: 'desc'
22
+ it_should_download 'TEST_4', limit: 10
23
+ it_should_download 'TEST_4', row: 10
24
+ it_should_download 'TEST_4', offset: 10
25
+ # test each transformation
26
+ Quandl::Operation::Transform.valid_transformations.each{|v| it_should_download('TEST_4', transformation: v.to_s ) }
27
+ # test each collapse
28
+ Quandl::Operation::Collapse.valid_collapses.each{|v| it_should_download('TEST_4', collapse: v.to_s ) }
29
+
30
+ after(:all){
31
+ Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf').each{|d|
32
+ Quandl::Command::Tasks::Delete.call( d.code, force_yes: true ) }
33
+ }
34
+
35
+ end
36
+
37
+ it "should not download TEST_DOES_NOT_EXIST." do
38
+ Quandl::Logger.should_receive(:error).with(/Not Found/)
39
+ Quandl::Command::Tasks::Download.call( 'TEST_DOES_NOT_EXIST' )
40
+ end
41
+
42
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Quandl::Command::Tasks::Upload do
5
+
6
+ it "should upload spec/fixtures/data/datasets.qdf" do
7
+ Quandl::Logger.should_receive(:info).with(/OK|Created/).exactly(4).times
8
+ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/datasets.qdf' )
9
+ end
10
+
11
+ it "should upload spec/fixtures/data/metadata.qdf" do
12
+ Quandl::Logger.should_receive(:info).with(/OK|Created/).exactly(3).times
13
+ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/metadata.qdf' )
14
+ end
15
+
16
+ it "should upload spec/fixtures/data/QUGC-42.qdf" do
17
+ Quandl::Logger.should_receive(:info).with(/OK|Created/).exactly(1).times
18
+ Quandl::Command::Tasks::Upload.call( 'spec/fixtures/data/QUGC-42.qdf' )
19
+ end
20
+
21
+ def self.it_should_expect_error(file, error)
22
+ it "#{file}.qdf should error with #{error}" do
23
+ Quandl::Logger.should_receive(:error).with(error).exactly(1).times
24
+ Quandl::Command::Tasks::Upload.call( "spec/fixtures/data/errors/#{file}.qdf" )
25
+ end
26
+ end
27
+
28
+ it_should_expect_error :invalid_code, /code is invalid/
29
+ it_should_expect_error :column_count_mismatch, /Expected 4 but found 5 based/
30
+ it_should_expect_error :date_parse_error, /DateParseError/
31
+ it_should_expect_error :invalid_date, /InvalidDate/
32
+ it_should_expect_error :psych, /Could not find expected ':'/
33
+ it_should_expect_error :unknown_attribute, /UnknownAttribute/
34
+
35
+ # delete test data after run
36
+ after(:all){ Quandl::Format::Dataset.load_from_file('spec/fixtures/data/datasets.qdf')
37
+ .collect(&:client).each(&:destroy) }
38
+
39
+ end