quandl 0.4.4 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +5 -13
  2. data/README.md +133 -318
  3. data/lib/quandl.rb +27 -0
  4. data/lib/quandl/api_config.rb +33 -0
  5. data/lib/quandl/connection.rb +75 -0
  6. data/lib/quandl/errors/quandl_error.rb +56 -0
  7. data/lib/quandl/model/base.rb +31 -0
  8. data/lib/quandl/model/data.rb +32 -0
  9. data/lib/quandl/model/database.rb +62 -0
  10. data/lib/quandl/model/dataset.rb +24 -0
  11. data/lib/quandl/model/list.rb +45 -0
  12. data/lib/quandl/operations/base.rb +17 -0
  13. data/lib/quandl/operations/get.rb +21 -0
  14. data/lib/quandl/operations/list.rb +23 -0
  15. data/lib/quandl/util.rb +35 -0
  16. data/lib/quandl/version.rb +3 -0
  17. metadata +78 -319
  18. data/.gitignore +0 -16
  19. data/.travis.yml +0 -20
  20. data/Gemfile +0 -14
  21. data/Guardfile +0 -8
  22. data/LICENSE +0 -7
  23. data/Rakefile +0 -27
  24. data/UPGRADE.md +0 -262
  25. data/VERSION +0 -1
  26. data/bin/quandl +0 -25
  27. data/config/locales/en.yml +0 -26
  28. data/dist/resources/pkg/Distribution.erb +0 -15
  29. data/dist/resources/pkg/PackageInfo.erb +0 -6
  30. data/dist/resources/pkg/postinstall.erb +0 -47
  31. data/dist/resources/pkg/quandl +0 -25
  32. data/dist/resources/ruby/PackageInfo +0 -3
  33. data/dist/resources/windows/quandl +0 -25
  34. data/lib/commander/command/quandl_ext.rb +0 -21
  35. data/lib/quandl/command.rb +0 -47
  36. data/lib/quandl/command/client.rb +0 -0
  37. data/lib/quandl/command/client_ext.rb +0 -1
  38. data/lib/quandl/command/client_ext/user.rb +0 -11
  39. data/lib/quandl/command/compatibility_check.rb +0 -11
  40. data/lib/quandl/command/config.rb +0 -92
  41. data/lib/quandl/command/presenter.rb +0 -75
  42. data/lib/quandl/command/presenter/helper.rb +0 -19
  43. data/lib/quandl/command/presenter/record.rb +0 -113
  44. data/lib/quandl/command/presenters/dataset_presenter.rb +0 -19
  45. data/lib/quandl/command/presenters/error_presenter.rb +0 -31
  46. data/lib/quandl/command/presenters/nil_class_presenter.rb +0 -10
  47. data/lib/quandl/command/presenters/scraper_presenter.rb +0 -25
  48. data/lib/quandl/command/presenters/superset_presenter.rb +0 -10
  49. data/lib/quandl/command/task.rb +0 -44
  50. data/lib/quandl/command/task/callbacks.rb +0 -28
  51. data/lib/quandl/command/task/clientable.rb +0 -51
  52. data/lib/quandl/command/task/commandable.rb +0 -103
  53. data/lib/quandl/command/task/configurable.rb +0 -80
  54. data/lib/quandl/command/task/dependable.rb +0 -71
  55. data/lib/quandl/command/task/inputable.rb +0 -37
  56. data/lib/quandl/command/task/logging.rb +0 -83
  57. data/lib/quandl/command/task/presentation.rb +0 -36
  58. data/lib/quandl/command/task/reportable.rb +0 -35
  59. data/lib/quandl/command/task/threading.rb +0 -123
  60. data/lib/quandl/command/task/translations.rb +0 -37
  61. data/lib/quandl/command/task/updatable.rb +0 -80
  62. data/lib/quandl/command/task/validations.rb +0 -25
  63. data/lib/quandl/command/tasks.rb +0 -24
  64. data/lib/quandl/command/tasks/delete.rb +0 -34
  65. data/lib/quandl/command/tasks/download.rb +0 -44
  66. data/lib/quandl/command/tasks/info.rb +0 -48
  67. data/lib/quandl/command/tasks/list.rb +0 -31
  68. data/lib/quandl/command/tasks/login.rb +0 -47
  69. data/lib/quandl/command/tasks/replace.rb +0 -58
  70. data/lib/quandl/command/tasks/schedule.rb +0 -211
  71. data/lib/quandl/command/tasks/search.rb +0 -39
  72. data/lib/quandl/command/tasks/superset.rb +0 -66
  73. data/lib/quandl/command/tasks/uninstall.rb +0 -17
  74. data/lib/quandl/command/tasks/update.rb +0 -249
  75. data/lib/quandl/command/tasks/upload.rb +0 -60
  76. data/lib/quandl/command/version.rb +0 -5
  77. data/lib/quandl/lang.rb +0 -45
  78. data/lib/quandl/utility.rb +0 -2
  79. data/lib/quandl/utility/config.rb +0 -43
  80. data/lib/quandl/utility/ruby_version.rb +0 -143
  81. data/quandl.gemspec +0 -43
  82. data/scripts/compile_ruby_pkg.sh +0 -34
  83. data/scripts/install.sh +0 -51
  84. data/scripts/win/quandl_toolbelt.iss +0 -89
  85. data/spec/config/output.rb +0 -21
  86. data/spec/config/quandl.rb +0 -67
  87. data/spec/factories/dataset.rb +0 -10
  88. data/spec/factories/source.rb +0 -10
  89. data/spec/fixtures/scraper-test-file.rb +0 -6
  90. data/spec/lib/quandl/command/delete_spec.rb +0 -45
  91. data/spec/lib/quandl/command/download_spec.rb +0 -49
  92. data/spec/lib/quandl/command/replace_spec.rb +0 -22
  93. data/spec/lib/quandl/command/schedule_spec.rb +0 -45
  94. data/spec/lib/quandl/command/superset_spec.rb +0 -28
  95. data/spec/lib/quandl/command/upload_spec.rb +0 -86
  96. data/spec/lib/quandl/command_spec.rb +0 -38
  97. data/spec/spec_helper.rb +0 -43
  98. data/tasks/toolbelt.rake +0 -138
  99. data/tasks/toolbelt.rb +0 -116
  100. data/tasks/toolbelt/build.rb +0 -2
  101. data/tasks/toolbelt/build/darwin.rb +0 -118
  102. data/tasks/toolbelt/build/ruby.rb +0 -105
  103. data/tasks/toolbelt/build/tarball.rb +0 -79
  104. data/tasks/toolbelt/build/windows.rb +0 -25
  105. data/tasks/toolbelt/push.rb +0 -18
  106. data/tasks/toolbelt/storage.rb +0 -28
  107. data/tasks/toolbelt/tar.rb +0 -21
data/tasks/toolbelt.rb DELETED
@@ -1,116 +0,0 @@
1
- module Tasks
2
- class Toolbelt
3
- include RakeFileUtils
4
-
5
- extend ActiveModel::Callbacks
6
- define_model_callbacks :ensure
7
-
8
- class << self
9
-
10
- def execute(*args, &block)
11
- self.new(*args, &block).execute
12
- end
13
-
14
- def resource_path
15
- @resource_path ||= File.join(root_path, "dist/resources/")
16
- end
17
-
18
- def pkg_releases_path
19
- @pkg_releases_path ||= File.join( build_path, 'releases' )
20
- end
21
-
22
- def release_path
23
- @release_path ||= File.join(tarball_path, "quandl-command" )
24
- end
25
-
26
- def pkg_path
27
- @pkg_path ||= File.join(build_path, "pkg/")
28
- end
29
-
30
- def tarball_path
31
- @tarball_path ||= File.join(build_path, "tarball/")
32
- end
33
-
34
- def ruby_pkg_path
35
- @ruby_pkg_path ||= File.join(build_path, 'ruby.pkg')
36
- end
37
-
38
- def build_path
39
- @build_path ||= File.join(root_path, "build")
40
- end
41
-
42
- def tmp_path
43
- @tmp_path ||= File.join(root_path, "tmp")
44
- end
45
-
46
- def root_path
47
- @root_path ||= File.expand_path(File.join(File.dirname(__FILE__), '../'))
48
- end
49
-
50
- def trace?
51
- Rake.application.options.trace == true
52
- end
53
-
54
- end
55
-
56
- attr_accessor :args, :options, :block
57
-
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
59
-
60
- def initialize(*args, &block)
61
- self.options = OpenStruct.new(args.extract_options!)
62
- self.args = args
63
- self.block = block
64
- end
65
-
66
- def wipe_dir(p)
67
- rm_rf p
68
- mkdir p
69
- end
70
-
71
- def execute
72
- begin
73
- puts "args: #{args}, options: #{options}" if trace?
74
- call
75
- ensure
76
- run_callbacks(:ensure)
77
- end
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
99
-
100
- def revision
101
- @revision ||= options.revision.to_s.gsub("/","-") || "master"
102
- end
103
-
104
- def resource(path)
105
- File.join(resource_path, path)
106
- end
107
-
108
- def version
109
- Quandl::Command::VERSION
110
- end
111
-
112
- end
113
- end
114
-
115
- Dir.glob( File.join( Tasks::Toolbelt.root_path, 'tasks/toolbelt/*.rb') ){|f| require(f) }
116
- Dir.glob( File.join( Tasks::Toolbelt.root_path, 'tasks/toolbelt/**/*.rb') ){|f| require(f) }
@@ -1,2 +0,0 @@
1
- class Tasks::Toolbelt::Build
2
- end
@@ -1,118 +0,0 @@
1
- require "erb"
2
-
3
- class Tasks::Toolbelt::Build::Darwin < Tasks::Toolbelt
4
-
5
- CERTIFICATE_ID = ENV['CERTIFICATE_ID'] || "3PNTC7FC9Q"
6
-
7
- around_ensure :cleanup
8
-
9
- def call
10
- clean
11
-
12
- # compile build
13
- Tasks::Toolbelt::Build::Tarball.execute(options)
14
-
15
- create_release
16
- add_quandl_executable
17
-
18
- generate_distribution
19
- generate_package_info
20
- generate_postinstall
21
- generate_bom
22
-
23
- add_payload
24
- add_ruby
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
53
- mkdir_p "#{pkg_path}/Resources"
54
- mkdir_p "#{pkg_path}/quandl-toolbelt.pkg"
55
-
56
- dist = File.read(resource("pkg/Distribution.erb"))
57
- dist = ERB.new(dist).result(binding)
58
- File.open("#{pkg_path}/Distribution", "w") { |f| f.puts dist }
59
- end
60
-
61
- def generate_package_info
62
- dist = File.read(resource("pkg/PackageInfo.erb"))
63
- dist = ERB.new(dist).result(binding)
64
- File.open("#{pkg_path}/quandl-toolbelt.pkg/PackageInfo", "w") { |f| f.puts dist }
65
- end
66
-
67
- def generate_postinstall
68
- file = File.read(resource("pkg/postinstall.erb"))
69
- file = ERB.new(file).result(binding)
70
- mkdir_p "#{pkg_path}/quandl-toolbelt.pkg/Scripts"
71
- File.open("#{pkg_path}/quandl-toolbelt.pkg/Scripts/postinstall", "w") { |f| f.puts file }
72
- chmod 0755, "#{pkg_path}/quandl-toolbelt.pkg/Scripts/postinstall"
73
- end
74
-
75
- def generate_bom
76
- sh %{ mkbom -s #{release_path} #{pkg_path}/quandl-toolbelt.pkg/Bom }
77
- end
78
-
79
- def add_payload
80
- Dir.chdir(release_path) do
81
- sh %{ pax -wz -x cpio . > #{pkg_path}/quandl-toolbelt.pkg/Payload }
82
- end
83
- end
84
-
85
- def add_ruby
86
-
87
- # download, compile, and build ruby pkg unless already done
88
- Tasks::Toolbelt::Build::Ruby.execute unless File.exists?(File.join(build_path, 'ruby.pkg'))
89
-
90
- # include ruby.pkg
91
- Dir.chdir(tmp_path) do
92
- cp ruby_pkg_path, "ruby-package.pkg"
93
- sh %{ pkgutil --expand ruby-package.pkg ruby.pkg }
94
- mv "ruby.pkg", "#{pkg_path}/ruby.pkg"
95
- end
96
-
97
- end
98
-
99
- def package_and_sign
100
- sh %{ pkgutil --flatten #{pkg_path} #{build_path}/quandl-toolbelt-unsigned.pkg }
101
- sh %{ productsign --sign #{CERTIFICATE_ID} #{build_path}/quandl-toolbelt-unsigned.pkg #{build_path}/quandl-toolbelt.pkg }
102
-
103
- end
104
-
105
- def clean
106
- rm "#{build_path}/quandl-toolbelt.pkg" if File.exists?("#{build_path}/quandl-toolbelt.pkg")
107
- rm_rf tmp_path
108
- mkdir_p tmp_path
109
- rm_rf pkg_path
110
- mkdir_p pkg_path
111
- rm_rf pkg_releases_path
112
- mkdir_p pkg_releases_path
113
- end
114
-
115
- def cleanup
116
- end
117
-
118
- end
@@ -1,105 +0,0 @@
1
- require "erb"
2
-
3
- class Tasks::Toolbelt::Build::Ruby < Tasks::Toolbelt
4
-
5
- RUBY_BUILD_VERSION='ruby-1.9.3-p448'
6
-
7
- around_ensure :cleanup
8
-
9
- def call
10
- clean
11
- # work inside of tmp dir
12
- Dir.chdir(tmp_path) do
13
- compile_yaml
14
- compile_ruby
15
- end
16
- build_package
17
- end
18
-
19
- def compile_yaml
20
- sh "wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz"
21
- sh "tar zxf yaml-0.1.5.tar.gz"
22
- Dir.chdir "yaml-0.1.5" do
23
- sh "#{compile_env} ./configure --prefix=#{quandl_ruby_path}"
24
- sh "make && make install"
25
- end
26
- end
27
-
28
- def compile_ruby
29
- sh "wget http://xyz.lcs.mit.edu/ruby/#{rubyv}.zip"
30
- sh "unzip #{rubyv}.zip"
31
- Dir.chdir(rubyv) do
32
- sh "#{compile_env} ./configure #{compile_flags}"
33
- sh "make && make install"
34
- end
35
- end
36
-
37
- def build_package
38
- cp resource('ruby/PackageInfo'), "#{pkg_build_path}/PackageInfo"
39
- # enter compiled ruby path
40
- Dir.chdir(quandl_ruby_path) do
41
- sh "mkbom -s . #{pkg_build_path}/Bom"
42
- sh "pax -wz -x cpio . > #{pkg_build_path}/Payload"
43
- end
44
- Dir.chdir(prefix_path) do
45
- sh "pkgutil --flatten #{rubyv}-pkg #{ruby_pkg_path}"
46
- end
47
- end
48
-
49
- protected
50
-
51
- def rubyv
52
- RUBY_BUILD_VERSION
53
- end
54
-
55
- def compile_flags
56
- [ "--with-static-linked-ext",
57
- "--prefix=#{quandl_ruby_path}",
58
- "--enable-shared",
59
- "--disable-install-doc",
60
- "--with-opt-dir=#{quandl_ruby_path}",
61
- ].join(" ")
62
- end
63
-
64
- def compile_env
65
- f = "-mmacosx-version-min=10.5"
66
- {
67
- CFLAGS: f,
68
- CXXFLAGS: f,
69
- CPPFLAGS: f,
70
- LDFLAGS: f,
71
- OBJCFLAGS: f,
72
- OBJCXXFLAGS: f,
73
- }.collect{|k,v| %Q{#{k}="#{v}"} }.join(" ")
74
- end
75
-
76
- def clean
77
- mkdir prefix_path unless Dir.exists?(prefix_path)
78
- sh "sudo chown $USER:staff #{prefix_path}"
79
- wipe_dir pkg_build_path
80
- wipe_dir tmp_path
81
- wipe_dir quandl_ruby_path
82
- wipe_dir opt_path
83
- end
84
-
85
- def opt_path
86
- @opt_path ||= File.join( quandl_ruby_path, "opt")
87
- end
88
-
89
- def pkg_build_path
90
- @pkg_build_path ||= File.join( prefix_path, "#{rubyv}-pkg")
91
- end
92
-
93
- def quandl_ruby_path
94
- @quandl_ruby_path ||= File.join( prefix_path, "ruby")
95
- end
96
-
97
- def prefix_path
98
- "/usr/local/quandl"
99
- end
100
-
101
- def cleanup
102
- rm_rf pkg_build_path
103
- end
104
-
105
- end
@@ -1,79 +0,0 @@
1
- class Tasks::Toolbelt::Build::Tarball < Tasks::Toolbelt
2
-
3
- around_ensure :cleanup
4
-
5
- def call
6
- # checkout requested revision
7
- checkout_revision
8
- # clean directories
9
- clean
10
- # copy files into release
11
- copy_files_into_release
12
- add_quandl_executable
13
- # add revision when given
14
- append_revision_to_release_version unless git_branch == 'master'
15
- # vendorize the bundle
16
- copy_vendored_gems
17
- # build tar
18
- package_release_into_tar
19
- end
20
-
21
- protected
22
-
23
- def add_quandl_executable
24
- resource_path = options.platform.present? ? "#{options.platform}/quandl" : "pkg/quandl"
25
- mkdir_p("#{release_path}/pkg") unless Dir.exists?("#{release_path}/pkg")
26
- cp resource(resource_path), "#{release_path}/pkg/quandl"
27
- end
28
-
29
- def checkout_revision
30
- raise "You have unstaged commits." if %x{git status} =~ /Changes not staged for commit/
31
- sh "git checkout #{options.revision}"
32
- raise "Unable to checkout #{options.revision}" unless %x{git branch | grep '*'} =~ /#{options.revision}/
33
- end
34
-
35
- def copy_files_into_release
36
- # for each path
37
- ['lib', 'bin', 'config', 'VERSION'].each do |path|
38
- # recursively copy into release
39
- cp_r File.join( root_path, path ), File.join( release_path, path )
40
- end
41
- end
42
-
43
- def clean
44
- rm_rf tarball_path
45
- # create release
46
- mkdir_p release_path
47
- end
48
-
49
- def append_revision_to_release_version
50
- version_file = File.join( release_path, 'VERSION')
51
- IO.write(version_file, File.open(version_file) do |f|
52
- f.read.gsub(version, "#{version} #{prerelease_information}")
53
- end
54
- )
55
- end
56
-
57
- def copy_vendored_gems
58
- Bundler.with_clean_env do
59
- sh( "bundle install --without development test --path #{release_path}/vendor" )
60
- mv File.join(release_path, "vendor/ruby/1.9.1/gems"), File.join(release_path, "vendor")
61
- rm_rf File.join(release_path, "vendor/ruby")
62
- end
63
- end
64
-
65
- def package_release_into_tar
66
- # path to tarball
67
- tarball_filename = File.basename([ release_path, revision, 'tar.gz' ].compact.join("."))
68
- # enter tarball build directory
69
- Dir.chdir(tarball_path) do
70
- # create targz
71
- Tar.pack( 'quandl-command', File.join(tarball_path, tarball_filename) )
72
- end
73
- end
74
-
75
- def cleanup
76
- rm_rf File.join( root_path, '.bundle')
77
- end
78
-
79
- end
@@ -1,25 +0,0 @@
1
- class Tasks::Toolbelt::Build::Windows < Tasks::Toolbelt
2
-
3
- around_ensure :cleanup
4
-
5
- def call
6
- input_file = File.join( tarball_path, 'win_setup.tar.gz')
7
- # download file from s3
8
- File.open(input_file, "wb") do |saved_file|
9
- open('http://s3.amazonaws.com/quandl-command/win_setup/win_setup.tar.gz','rb') {|read_file|
10
- saved_file.write(read_file.read)
11
- }
12
- end
13
- # unpack win_setup
14
- Tar.unpack( File.join( tarball_path, "win_setup.tar.gz" ), tarball_path )
15
- #build win exe
16
- sh "cd \"#{File.join(root_path, 'scripts','win')}\" && \"#{inno_path}\\iscc\" /cc \"quandl_toolbelt.iss\""
17
- end
18
-
19
- protected
20
-
21
- def cleanup
22
- rm_rf File.join( root_path, '.bundle')
23
- end
24
-
25
- end