quandl_client 2.7.11 → 2.7.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +7 -7
  2. data/.rspec +1 -1
  3. data/.travis.yml +20 -20
  4. data/.yardopts +2 -2
  5. data/Gemfile +12 -12
  6. data/Guardfile +8 -8
  7. data/LICENSE +7 -7
  8. data/README.md +303 -303
  9. data/Rakefile +31 -31
  10. data/UPGRADE.md +220 -214
  11. data/VERSION +1 -1
  12. data/examples/create.rb +32 -32
  13. data/examples/find.rb +17 -17
  14. data/examples/login.rb +12 -12
  15. data/examples/search.rb +12 -12
  16. data/examples/trims.rb +15 -15
  17. data/lib/quandl/client/base/attributes.rb +15 -15
  18. data/lib/quandl/client/base/model.rb +40 -40
  19. data/lib/quandl/client/base/search.rb +74 -74
  20. data/lib/quandl/client/base/validation.rb +103 -101
  21. data/lib/quandl/client/base.rb +91 -91
  22. data/lib/quandl/client/middleware/parse_json.rb +87 -85
  23. data/lib/quandl/client/middleware.rb +9 -9
  24. data/lib/quandl/client/models/dataset/data.rb +57 -57
  25. data/lib/quandl/client/models/dataset.rb +269 -269
  26. data/lib/quandl/client/models/location.rb +10 -10
  27. data/lib/quandl/client/models/report.rb +14 -14
  28. data/lib/quandl/client/models/scraper.rb +16 -16
  29. data/lib/quandl/client/models/sheet.rb +50 -50
  30. data/lib/quandl/client/models/source.rb +48 -48
  31. data/lib/quandl/client/models/superset.rb +65 -65
  32. data/lib/quandl/client/models/user.rb +7 -7
  33. data/lib/quandl/client/version.rb +14 -14
  34. data/lib/quandl/client.rb +54 -53
  35. data/lib/quandl/her/collection.rb +18 -0
  36. data/lib/quandl/her/remove_method_data.rb +8 -8
  37. data/lib/quandl/pattern/client.rb +8 -8
  38. data/lib/quandl/pattern.rb +37 -37
  39. data/quandl_client.gemspec +33 -33
  40. data/spec/factories/dataset.rb +10 -10
  41. data/spec/factories/sheet.rb +7 -7
  42. data/spec/factories/source.rb +9 -9
  43. data/spec/fixtures/scraper.rb +5 -5
  44. data/spec/lib/quandl/client/dataset/attributes_spec.rb +63 -63
  45. data/spec/lib/quandl/client/dataset/data_spec.rb +92 -92
  46. data/spec/lib/quandl/client/dataset/location_spec.rb +65 -65
  47. data/spec/lib/quandl/client/dataset/persistence_spec.rb +104 -104
  48. data/spec/lib/quandl/client/dataset/search_spec.rb +19 -19
  49. data/spec/lib/quandl/client/dataset/source_spec.rb +47 -47
  50. data/spec/lib/quandl/client/dataset/trim_spec.rb +35 -35
  51. data/spec/lib/quandl/client/dataset/validation_spec.rb +68 -68
  52. data/spec/lib/quandl/client/dataset_spec.rb +57 -57
  53. data/spec/lib/quandl/client/scraper_spec.rb +71 -71
  54. data/spec/lib/quandl/client/sheet_spec.rb +37 -37
  55. data/spec/lib/quandl/client/source_spec.rb +51 -51
  56. data/spec/spec_helper.rb +30 -30
  57. metadata +28 -4
data/README.md CHANGED
@@ -1,303 +1,303 @@
1
- # Quandl::Client
2
-
3
- ## Purpose
4
-
5
- The purpose of this gem is to interact with the [quandl api](http://www.quandl.com/help/api)
6
-
7
-
8
- ## Installation
9
-
10
- ```ruby
11
-
12
- gem 'quandl_client'
13
-
14
- ```
15
-
16
-
17
-
18
-
19
- ## Configuration
20
-
21
- ```ruby
22
-
23
- require 'quandl/client'
24
-
25
- Quandl::Client.use 'http://localhost:3000/api/'
26
- Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN']
27
-
28
-
29
- ```
30
-
31
-
32
-
33
-
34
- ## Usage
35
-
36
-
37
- ### Quandl::Client::Dataset
38
-
39
-
40
- #### Search
41
-
42
- scope :rows, :exclude_data, :exclude_headers, :trim_start, :trim_end, :transform, :collapse
43
-
44
- ```ruby
45
-
46
- datasets = Quandl::Client::Dataset.query('cobalt').source_code('ofdp').all
47
- => [#<Quandl::Client::Dataset(datasets) source_code="OFDP" code="COBALT_51">, ...]
48
-
49
- ```
50
-
51
-
52
- #### Show
53
-
54
- attributes :data, :source_code, :code, :name, :urlize_name,
55
- :description, :updated_at, :frequency, :from_date,
56
- :to_date, :column_names, :private, :type
57
-
58
- ```ruby
59
-
60
- d = Quandl::Client::Dataset.find('OFDP/COBALT_51')
61
- d.full_code
62
- d.data
63
-
64
-
65
- d = Quandl::Client::Dataset.collapse('weekly').trim_start("2012-03-31").trim_end("2013-06-30").find('OFDP/COBALT_51')
66
- d.data
67
-
68
-
69
- d = Quandl::Client::Dataset.exclude_data('true').find('OFDP/COBALT_51')
70
- d.data
71
-
72
- ```
73
-
74
-
75
- #### Create
76
-
77
- ```ruby
78
-
79
- attributes = {
80
- code: "TEST_#{Time.now.to_i}",
81
- source_code: 'OFDP',
82
- name: "Test Upload #{Time.now.to_i}",
83
- frequency: 'daily',
84
- locations:
85
- [
86
- {
87
- type: 'http',
88
- url: 'http://test.com',
89
- post_data: '[magic]',
90
- cookie_url: 'http://cookies.com'
91
- }
92
- ]
93
- }
94
- d = Dataset.create( attributes )
95
-
96
- ```
97
-
98
-
99
- #### Update
100
-
101
- ```ruby
102
-
103
- d = Dataset.find( d.full_code )
104
- d.name = 'New Name'
105
- d.data = Quandl::Fabricate::Data.rand.to_csv
106
- d.save
107
-
108
- d = Dataset.collapse(:weekly).find( d.full_code )
109
- d.data
110
- => [[...],...]
111
-
112
- ```
113
-
114
-
115
- #### Delete
116
-
117
- ```ruby
118
-
119
- Dataset.destroy_existing('SOME_SOURCE/SOME_CODE')
120
- Dataset.destroy_existing(52352)
121
-
122
- Dataset.find('SOME_SOURCE/SOME_CODE')
123
- => nil
124
-
125
- ```
126
-
127
-
128
- #### Delete Data
129
-
130
- ```ruby
131
-
132
- d = Dataset.find('SOME_SOURCE/SOME_CODE')
133
- d.delete_data
134
- d.data
135
- => nil
136
-
137
- d.delete_rows( '1998-02-01','1998-03-03' )
138
- d.data
139
- => # given rows are deleted
140
-
141
- ```
142
-
143
-
144
- #### Error Handling
145
-
146
- ```ruby
147
-
148
- d = Dataset.create(code: 'TEST', source_code: 'OFDP', locations: [{ type: 'http', url: 'test.com' }] )
149
- d.error_messages
150
- => {:name=>["can't be blank"]}
151
-
152
- d = Dataset.create(name: 'asdfs', code: 'TEST', source_code: 'OFDP', locations: [{ type: 'http', url: 'test.com' }] )
153
- d.error_messages
154
- => {"code"=>["has already been taken"], "frequency"=>["is not included in the list"]}
155
-
156
- ```
157
-
158
-
159
-
160
-
161
- ### Quandl::Client::Source
162
-
163
-
164
- #### Search
165
-
166
- ```ruby
167
-
168
- sources = Quandl::Client::Source.query('can').all
169
-
170
- => [#<Quandl::Client::Source(sources/413) code="STATSCAN5" datasets_count=1>...]
171
-
172
- ```
173
-
174
-
175
- #### Show
176
-
177
- ```ruby
178
-
179
- s = Quandl::Client::Source.find('STATSCAN5')
180
-
181
- ```
182
-
183
-
184
- #### Create
185
-
186
- ```ruby
187
-
188
- s = Source.create( code: 'test' )
189
- s.valid?
190
- s.error_messages
191
- => {:code=>["is invalid"], :host=>["can't be blank"], :name=>["can't be blank"]}
192
-
193
- s = Source.create(code: %Q{TEST_#{Time.now.to_i}}, name: 'asdf', host: "http://asdf#{Time.now}.com" )
194
- s.saved?
195
- => true
196
-
197
- ```
198
-
199
-
200
- #### Update
201
-
202
- ```ruby
203
-
204
- s = Source.find(s.code)
205
- s.name = "Updated Name #{Time.now.to_i}"
206
- s.code = "DATA_#{Time.now.to_i}"
207
- s.save
208
-
209
- ```
210
-
211
-
212
- #### Delete
213
-
214
- ```ruby
215
-
216
- Source.destroy_existing('SOMESOURCE')
217
- Source.destroy_existing(52352)
218
-
219
- ```
220
-
221
-
222
-
223
-
224
- ### Quandl::Client::Sheet
225
-
226
-
227
- #### Search
228
-
229
- ```ruby
230
-
231
- sheets = Quandl::Client::Sheet.query('canada').all
232
- => [[#<Quandl::Client::Sheet(sheets) title="La Canada Flintridge>,...]
233
-
234
- ```
235
-
236
-
237
- #### Show
238
-
239
- ```ruby
240
-
241
- sheet = Quandl::Client::Sheet.find('housing/hood')
242
-
243
- ```
244
-
245
-
246
- #### Create
247
-
248
- ```ruby
249
-
250
- s = Quandl::Client::Sheet.create( title: 'ocean' )
251
- s = Quandl::Client::Sheet.create( full_url_title: 'ocean/river', title: 'River' )
252
- s = Quandl::Client::Sheet.create( full_url_title: 'ocean/river/lake', title: 'Lake!' )
253
-
254
- Sheet.find('ocean/river/lake').title
255
- => 'Lake!'
256
-
257
- Sheet.find('ocean').children.first.title
258
- => River
259
-
260
- ```
261
-
262
-
263
- #### Update
264
-
265
- ```ruby
266
-
267
- s = Quandl::Client::Sheet.find('ocean/river')
268
- s.title = "River #{Time.now.to_i}"
269
- s.save
270
-
271
- ```
272
-
273
-
274
- #### Delete
275
-
276
- ```ruby
277
-
278
- Quandl::Client::Sheet.destroy_existing('ocean/river/lake')
279
-
280
- Quandl::Client::Sheet.destroy_existing(15252)
281
-
282
- ```
283
-
284
-
285
-
286
-
287
- ### Authentication
288
-
289
- ```ruby
290
-
291
- require 'quandl/client'
292
-
293
- Quandl::Client.use 'http://localhost:3000/api/'
294
- Quandl::Client.token = 'xyz'
295
-
296
-
297
- s = Quandl::Client::Sheet.find_by_url_title('testing')
298
- s.title = 'more testing'
299
- s.save
300
- => true
301
-
302
- ```
303
-
1
+ # Quandl::Client
2
+
3
+ ## Purpose
4
+
5
+ The purpose of this gem is to interact with the [quandl api](http://www.quandl.com/help/api)
6
+
7
+
8
+ ## Installation
9
+
10
+ ```ruby
11
+
12
+ gem 'quandl_client'
13
+
14
+ ```
15
+
16
+
17
+
18
+
19
+ ## Configuration
20
+
21
+ ```ruby
22
+
23
+ require 'quandl/client'
24
+
25
+ Quandl::Client.use 'http://localhost:3000/api/'
26
+ Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN']
27
+
28
+
29
+ ```
30
+
31
+
32
+
33
+
34
+ ## Usage
35
+
36
+
37
+ ### Quandl::Client::Dataset
38
+
39
+
40
+ #### Search
41
+
42
+ scope :rows, :exclude_data, :exclude_headers, :trim_start, :trim_end, :transform, :collapse
43
+
44
+ ```ruby
45
+
46
+ datasets = Quandl::Client::Dataset.query('cobalt').source_code('ofdp').all
47
+ => [#<Quandl::Client::Dataset(datasets) source_code="OFDP" code="COBALT_51">, ...]
48
+
49
+ ```
50
+
51
+
52
+ #### Show
53
+
54
+ attributes :data, :source_code, :code, :name, :urlize_name,
55
+ :description, :updated_at, :frequency, :from_date,
56
+ :to_date, :column_names, :private, :type
57
+
58
+ ```ruby
59
+
60
+ d = Quandl::Client::Dataset.find('OFDP/COBALT_51')
61
+ d.full_code
62
+ d.data
63
+
64
+
65
+ d = Quandl::Client::Dataset.collapse('weekly').trim_start("2012-03-31").trim_end("2013-06-30").find('OFDP/COBALT_51')
66
+ d.data
67
+
68
+
69
+ d = Quandl::Client::Dataset.exclude_data('true').find('OFDP/COBALT_51')
70
+ d.data
71
+
72
+ ```
73
+
74
+
75
+ #### Create
76
+
77
+ ```ruby
78
+
79
+ attributes = {
80
+ code: "TEST_#{Time.now.to_i}",
81
+ source_code: 'OFDP',
82
+ name: "Test Upload #{Time.now.to_i}",
83
+ frequency: 'daily',
84
+ locations:
85
+ [
86
+ {
87
+ type: 'http',
88
+ url: 'http://test.com',
89
+ post_data: '[magic]',
90
+ cookie_url: 'http://cookies.com'
91
+ }
92
+ ]
93
+ }
94
+ d = Dataset.create( attributes )
95
+
96
+ ```
97
+
98
+
99
+ #### Update
100
+
101
+ ```ruby
102
+
103
+ d = Dataset.find( d.full_code )
104
+ d.name = 'New Name'
105
+ d.data = Quandl::Fabricate::Data.rand.to_csv
106
+ d.save
107
+
108
+ d = Dataset.collapse(:weekly).find( d.full_code )
109
+ d.data
110
+ => [[...],...]
111
+
112
+ ```
113
+
114
+
115
+ #### Delete
116
+
117
+ ```ruby
118
+
119
+ Dataset.destroy_existing('SOME_SOURCE/SOME_CODE')
120
+ Dataset.destroy_existing(52352)
121
+
122
+ Dataset.find('SOME_SOURCE/SOME_CODE')
123
+ => nil
124
+
125
+ ```
126
+
127
+
128
+ #### Delete Data
129
+
130
+ ```ruby
131
+
132
+ d = Dataset.find('SOME_SOURCE/SOME_CODE')
133
+ d.delete_data
134
+ d.data
135
+ => nil
136
+
137
+ d.delete_rows( '1998-02-01','1998-03-03' )
138
+ d.data
139
+ => # given rows are deleted
140
+
141
+ ```
142
+
143
+
144
+ #### Error Handling
145
+
146
+ ```ruby
147
+
148
+ d = Dataset.create(code: 'TEST', source_code: 'OFDP', locations: [{ type: 'http', url: 'test.com' }] )
149
+ d.error_messages
150
+ => {:name=>["can't be blank"]}
151
+
152
+ d = Dataset.create(name: 'asdfs', code: 'TEST', source_code: 'OFDP', locations: [{ type: 'http', url: 'test.com' }] )
153
+ d.error_messages
154
+ => {"code"=>["has already been taken"], "frequency"=>["is not included in the list"]}
155
+
156
+ ```
157
+
158
+
159
+
160
+
161
+ ### Quandl::Client::Source
162
+
163
+
164
+ #### Search
165
+
166
+ ```ruby
167
+
168
+ sources = Quandl::Client::Source.query('can').all
169
+
170
+ => [#<Quandl::Client::Source(sources/413) code="STATSCAN5" datasets_count=1>...]
171
+
172
+ ```
173
+
174
+
175
+ #### Show
176
+
177
+ ```ruby
178
+
179
+ s = Quandl::Client::Source.find('STATSCAN5')
180
+
181
+ ```
182
+
183
+
184
+ #### Create
185
+
186
+ ```ruby
187
+
188
+ s = Source.create( code: 'test' )
189
+ s.valid?
190
+ s.error_messages
191
+ => {:code=>["is invalid"], :host=>["can't be blank"], :name=>["can't be blank"]}
192
+
193
+ s = Source.create(code: %Q{TEST_#{Time.now.to_i}}, name: 'asdf', host: "http://asdf#{Time.now}.com" )
194
+ s.saved?
195
+ => true
196
+
197
+ ```
198
+
199
+
200
+ #### Update
201
+
202
+ ```ruby
203
+
204
+ s = Source.find(s.code)
205
+ s.name = "Updated Name #{Time.now.to_i}"
206
+ s.code = "DATA_#{Time.now.to_i}"
207
+ s.save
208
+
209
+ ```
210
+
211
+
212
+ #### Delete
213
+
214
+ ```ruby
215
+
216
+ Source.destroy_existing('SOMESOURCE')
217
+ Source.destroy_existing(52352)
218
+
219
+ ```
220
+
221
+
222
+
223
+
224
+ ### Quandl::Client::Sheet
225
+
226
+
227
+ #### Search
228
+
229
+ ```ruby
230
+
231
+ sheets = Quandl::Client::Sheet.query('canada').all
232
+ => [[#<Quandl::Client::Sheet(sheets) title="La Canada Flintridge>,...]
233
+
234
+ ```
235
+
236
+
237
+ #### Show
238
+
239
+ ```ruby
240
+
241
+ sheet = Quandl::Client::Sheet.find('housing/hood')
242
+
243
+ ```
244
+
245
+
246
+ #### Create
247
+
248
+ ```ruby
249
+
250
+ s = Quandl::Client::Sheet.create( title: 'ocean' )
251
+ s = Quandl::Client::Sheet.create( full_url_title: 'ocean/river', title: 'River' )
252
+ s = Quandl::Client::Sheet.create( full_url_title: 'ocean/river/lake', title: 'Lake!' )
253
+
254
+ Sheet.find('ocean/river/lake').title
255
+ => 'Lake!'
256
+
257
+ Sheet.find('ocean').children.first.title
258
+ => River
259
+
260
+ ```
261
+
262
+
263
+ #### Update
264
+
265
+ ```ruby
266
+
267
+ s = Quandl::Client::Sheet.find('ocean/river')
268
+ s.title = "River #{Time.now.to_i}"
269
+ s.save
270
+
271
+ ```
272
+
273
+
274
+ #### Delete
275
+
276
+ ```ruby
277
+
278
+ Quandl::Client::Sheet.destroy_existing('ocean/river/lake')
279
+
280
+ Quandl::Client::Sheet.destroy_existing(15252)
281
+
282
+ ```
283
+
284
+
285
+
286
+
287
+ ### Authentication
288
+
289
+ ```ruby
290
+
291
+ require 'quandl/client'
292
+
293
+ Quandl::Client.use 'http://localhost:3000/api/'
294
+ Quandl::Client.token = 'xyz'
295
+
296
+
297
+ s = Quandl::Client::Sheet.find_by_url_title('testing')
298
+ s.title = 'more testing'
299
+ s.save
300
+ => true
301
+
302
+ ```
303
+
data/Rakefile CHANGED
@@ -1,31 +1,31 @@
1
- require "bundler"
2
- require "rake"
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
-
7
- require 'pry'
8
- require "quandl/client"
9
-
10
- include Quandl::Client
11
-
12
- config = OpenStruct.new(YAML.load(File.read("#{ENV['HOME']}/.quandl/config")))
13
-
14
- Quandl::Client.use config.quandl_url
15
- Quandl::Client.token = config.token
16
-
17
- task :default => :spec
18
-
19
- desc "Run all specs"
20
- RSpec::Core::RakeTask.new(:spec) do |task|
21
- task.pattern = "spec/**/*_spec.rb"
22
- end
23
-
24
- require 'quandl/utility/rake_tasks'
25
- Quandl::Utility::Tasks.configure do |c|
26
- c.name = 'quandl'
27
- c.tag_prefix = 'v'
28
- c.version_path = 'VERSION'
29
- c.changelog_path = 'UPGRADE.md'
30
- c.changelog_matching = ['^QUGC','^WIKI']
31
- end
1
+ require "bundler"
2
+ require "rake"
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
+
7
+ require 'pry'
8
+ require "quandl/client"
9
+
10
+ include Quandl::Client
11
+
12
+ config = OpenStruct.new(YAML.load(File.read("#{ENV['HOME']}/.quandl/config")))
13
+
14
+ Quandl::Client.use config.quandl_url
15
+ Quandl::Client.token = config.token
16
+
17
+ task :default => :spec
18
+
19
+ desc "Run all specs"
20
+ RSpec::Core::RakeTask.new(:spec) do |task|
21
+ task.pattern = "spec/**/*_spec.rb"
22
+ end
23
+
24
+ require 'quandl/utility/rake_tasks'
25
+ Quandl::Utility::Tasks.configure do |c|
26
+ c.name = 'quandl'
27
+ c.tag_prefix = 'v'
28
+ c.version_path = 'VERSION'
29
+ c.changelog_path = 'UPGRADE.md'
30
+ c.changelog_matching = ['^QUGC','^WIKI']
31
+ end