quandl_client 2.7.9 → 2.7.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -7
- data/.rspec +1 -1
- data/.travis.yml +20 -20
- data/.yardopts +2 -2
- data/Gemfile +12 -12
- data/Guardfile +8 -8
- data/LICENSE +7 -7
- data/README.md +303 -303
- data/Rakefile +31 -31
- data/UPGRADE.md +214 -210
- data/VERSION +1 -1
- data/examples/create.rb +32 -32
- data/examples/find.rb +17 -17
- data/examples/login.rb +12 -12
- data/examples/search.rb +12 -12
- data/examples/trims.rb +15 -15
- data/lib/quandl/client.rb +53 -49
- data/lib/quandl/client/base.rb +91 -91
- data/lib/quandl/client/base/attributes.rb +15 -15
- data/lib/quandl/client/base/model.rb +40 -40
- data/lib/quandl/client/base/search.rb +74 -74
- data/lib/quandl/client/base/validation.rb +101 -101
- data/lib/quandl/client/middleware.rb +9 -9
- data/lib/quandl/client/middleware/parse_json.rb +85 -85
- data/lib/quandl/client/models/dataset.rb +269 -269
- data/lib/quandl/client/models/dataset/data.rb +57 -57
- data/lib/quandl/client/models/location.rb +10 -10
- data/lib/quandl/client/models/report.rb +14 -14
- data/lib/quandl/client/models/scraper.rb +16 -16
- data/lib/quandl/client/models/sheet.rb +50 -50
- data/lib/quandl/client/models/source.rb +48 -48
- data/lib/quandl/client/models/superset.rb +65 -65
- data/lib/quandl/client/models/user.rb +7 -7
- data/lib/quandl/client/version.rb +14 -14
- data/lib/quandl/her/remove_method_data.rb +8 -8
- data/lib/quandl/pattern.rb +37 -37
- data/lib/quandl/pattern/client.rb +8 -8
- data/quandl_client.gemspec +33 -33
- data/spec/factories/dataset.rb +10 -10
- data/spec/factories/sheet.rb +7 -7
- data/spec/factories/source.rb +9 -9
- data/spec/fixtures/scraper.rb +5 -5
- data/spec/lib/quandl/client/dataset/attributes_spec.rb +63 -63
- data/spec/lib/quandl/client/dataset/data_spec.rb +92 -92
- data/spec/lib/quandl/client/dataset/location_spec.rb +65 -65
- data/spec/lib/quandl/client/dataset/persistence_spec.rb +104 -104
- data/spec/lib/quandl/client/dataset/search_spec.rb +19 -19
- data/spec/lib/quandl/client/dataset/source_spec.rb +47 -47
- data/spec/lib/quandl/client/dataset/trim_spec.rb +35 -35
- data/spec/lib/quandl/client/dataset/validation_spec.rb +68 -68
- data/spec/lib/quandl/client/dataset_spec.rb +57 -57
- data/spec/lib/quandl/client/scraper_spec.rb +71 -71
- data/spec/lib/quandl/client/sheet_spec.rb +37 -37
- data/spec/lib/quandl/client/source_spec.rb +51 -51
- data/spec/spec_helper.rb +30 -30
- metadata +4 -27
data/.gitignore
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
.idea/
|
2
|
-
/Gemfile.lock
|
3
|
-
/pkg
|
4
|
-
/tmp
|
5
|
-
quandl_client-*
|
6
|
-
.rvmrc
|
7
|
-
*.gem
|
1
|
+
.idea/
|
2
|
+
/Gemfile.lock
|
3
|
+
/pkg
|
4
|
+
/tmp
|
5
|
+
quandl_client-*
|
6
|
+
.rvmrc
|
7
|
+
*.gem
|
8
8
|
*.log
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--colour --format=Fivemat
|
1
|
+
--colour --format=Fivemat
|
data/.travis.yml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
rvm:
|
4
|
-
- 2.0.0
|
5
|
-
- 1.9.3
|
6
|
-
- 1.9.2
|
7
|
-
- 1.8.7
|
8
|
-
|
9
|
-
gemfile:
|
10
|
-
- Gemfile
|
11
|
-
- gemfiles/activemodel-4.0.gemfile
|
12
|
-
|
13
|
-
matrix:
|
14
|
-
exclude:
|
15
|
-
- rvm: 1.8.7
|
16
|
-
gemfile: gemfiles/activemodel-4.0.gemfile
|
17
|
-
- rvm: 1.9.2
|
18
|
-
gemfile: gemfiles/activemodel-4.0.gemfile
|
19
|
-
|
20
|
-
script: "echo 'COME ON!' && bundle exec rake spec"
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 2.0.0
|
5
|
+
- 1.9.3
|
6
|
+
- 1.9.2
|
7
|
+
- 1.8.7
|
8
|
+
|
9
|
+
gemfile:
|
10
|
+
- Gemfile
|
11
|
+
- gemfiles/activemodel-4.0.gemfile
|
12
|
+
|
13
|
+
matrix:
|
14
|
+
exclude:
|
15
|
+
- rvm: 1.8.7
|
16
|
+
gemfile: gemfiles/activemodel-4.0.gemfile
|
17
|
+
- rvm: 1.9.2
|
18
|
+
gemfile: gemfiles/activemodel-4.0.gemfile
|
19
|
+
|
20
|
+
script: "echo 'COME ON!' && bundle exec rake spec"
|
data/.yardopts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--protected
|
2
|
-
--no-private
|
1
|
+
--protected
|
2
|
+
--no-private
|
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
gemspec
|
3
|
-
|
4
|
-
use_local_gems = ENV['BUNDLE_LOCAL_GEMS'] == "true" && ENV['BUNDLE_LOCAL_DIR']
|
5
|
-
local_gem_dir = ENV['BUNDLE_LOCAL_DIR']
|
6
|
-
|
7
|
-
if use_local_gems
|
8
|
-
# gem 'her', path: "#{local_gem_dir}/her"
|
9
|
-
gem 'quandl_data', path: "#{local_gem_dir}/quandl/data"
|
10
|
-
gem 'quandl_operation', path: "#{local_gem_dir}/quandl/operation"
|
11
|
-
gem 'quandl_babelfish', path: "#{local_gem_dir}/quandl/babelfish"
|
12
|
-
end
|
1
|
+
source "https://rubygems.org"
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
use_local_gems = ENV['BUNDLE_LOCAL_GEMS'] == "true" && ENV['BUNDLE_LOCAL_DIR']
|
5
|
+
local_gem_dir = ENV['BUNDLE_LOCAL_DIR']
|
6
|
+
|
7
|
+
if use_local_gems
|
8
|
+
# gem 'her', path: "#{local_gem_dir}/her"
|
9
|
+
gem 'quandl_data', path: "#{local_gem_dir}/quandl/data"
|
10
|
+
gem 'quandl_operation', path: "#{local_gem_dir}/quandl/operation"
|
11
|
+
gem 'quandl_babelfish', path: "#{local_gem_dir}/quandl/babelfish"
|
12
|
+
end
|
data/Guardfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
group :specs do
|
2
|
-
guard :rspec, cmd: 'bundle exec rspec --fail-fast -f doc --color' do
|
3
|
-
watch(%r{^spec/.+_spec\.rb$})
|
4
|
-
watch(%r{^(lib/.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
1
|
+
group :specs do
|
2
|
+
guard :rspec, cmd: 'bundle exec rspec --fail-fast -f doc --color' do
|
3
|
+
watch(%r{^spec/.+_spec\.rb$})
|
4
|
+
watch(%r{^(lib/.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
data/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Copyright (c) 2012-2013 Blake Hilscher
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
-
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
-
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2012-2013 Blake Hilscher
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
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
|
+
|