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/UPGRADE.md CHANGED
@@ -1,215 +1,221 @@
1
- ## 2.7.10
2
- * QUGC-168 can pass request_platform
3
-
4
-
5
- ## 2.7.9
6
-
7
- * QUGC-164 also search by code
8
- * QUGC-164 find by id or source_code/code, or build
9
- * QUGC-164 attributes slice needs to ensure that keys are symbols
10
-
11
-
12
-
13
- ## 2.7.8
14
-
15
-
16
-
17
-
18
-
19
- ## 2.7.7
20
-
21
-
22
-
23
-
24
-
25
- ## 2.7.6
26
-
27
- * QUGC-140 if a source_code is given but does not exist, it should warn the user
28
-
29
-
30
-
31
- ## 2.7.5
32
- add 'at' option for scraper scheduling
33
-
34
- ## 2.7.4
35
- full url bug fixed when "api" has no / at the end
36
-
37
-
38
- ## 2.6.2
39
-
40
- * QUGC-55 Add Report for filing reports
41
-
42
-
43
-
44
- ## 2.6.1
45
-
46
- * QUGC-113 fix Dataset#data errors dont propagate to parent object
47
- * QUGC-113 Write failing specs for Dataset#data errors dont propagate to parent object
48
-
49
-
50
-
51
- ## 2.6.0
52
-
53
- * QUGC-104 Fixes when upload fails output is not json
54
- * QUGC-103 Fixes quandl upload test -F json does not include metadata
55
-
56
-
57
-
58
- ## 2.5.2
59
-
60
- * WIKI-153 Add scrapers
61
-
62
-
63
- ## 2.5.1
64
-
65
- * QUGC-57 move data validation from Quandl::Format into Quandl::Client. Data validations only run on #valid?
66
- * QUGC-53 numeric codes require the full code
67
-
68
-
69
- ## 2.5.0
70
-
71
- * remove yajl
72
-
73
-
74
- ## 2.4.9
75
-
76
- * observe ruby platform
77
-
78
-
79
- ## 2.4.7
80
-
81
- * add middleware to track the origin of requests across quandl packages
82
-
83
-
84
- ## 2.4.6
85
-
86
- * QUGC-43 improved message on wrong number of colums
87
- * QUGC-41 enforce code formatting. always upcase codes
88
- * improved example of valid code
89
- * revise code pattern
90
-
91
-
92
- ## 2.4.5
93
-
94
- * QUGC-40 add validation to enforce: You may not change number of columns in a dataset
95
- * QUGC-37 Dataest.find accept backslash or forward slash interchangeably
96
-
97
-
98
- ## 2.4.4
99
-
100
- * Dataset#data to_table assigns column_names to headers
101
- * add skip_browse to Sheet
102
-
103
-
104
- ## 2.4.3
105
-
106
- * hotfix for full_code pattern matching ... code can be as short as two characters
107
-
108
-
109
- ## 2.4.2
110
-
111
- * Dataset.find will return nil unless the id is an integer, or matches the quandl pattern for full_code
112
-
113
-
114
- ## 2.4.1
115
-
116
- * revise reference_url http prepend
117
-
118
-
119
- ## 2.4.0
120
-
121
- * Dataset#reference_url should prepend of http:// when missing
122
- * add Quandl::Pattern for defining regex patterns with embedded examples
123
-
124
-
125
- # 2.3.2
126
-
127
- * add #elapsed_request_time_ms
128
- * refactor save_time to request_time. Add specs to #destroy for request_started_at, finished_at, elapsed_request_time
129
- * add Client::Base#save_started_at, #save_finished_at, #elapsed_save_time. before_save :touch_save_started_at, after_save :touch_save_finished_at
130
-
131
-
132
- ## 2.3.1
133
-
134
- * bump quandl_data
135
- * add human_error_messsages
136
-
137
-
138
- ## 2.3.0
139
-
140
- * add auth_token attribute to user
141
- * add Quandl::Client::User, .login for authenticating
142
- * full_url outputs the quandl link instead of the api link. Add human_status and HTTP_STATUS_CODES
143
- * should validate display_url as a url
144
- * add reference_url alias for display_url. reference_url will automatically add http when missing
145
-
146
-
147
- ## 2.2.1
148
-
149
- * full_code: dont assume that source_code is present
150
- * Dataset#data scope is cached to permit building across multiple lines. add Dataset#reload to wipe data_scope, dataset_data
151
-
152
-
153
- ## 2.2.0
154
-
155
- * add specs for Dataset.query
156
- * Dataset.query.all.metadata should pass
157
-
158
-
159
- ## 2.1.4
160
-
161
- * add specs for Dataset.query(term).all; make specs pass
162
-
163
-
164
-
165
- ## 2.1.3
166
-
167
- * add specs for data scopes
168
- * fix failing data scope specs
169
-
170
-
171
- ## 2.1.2
172
-
173
- * bump quandl_data, operation, logger
174
-
175
-
176
- ## 2.0.1
177
-
178
- * fully qualified classes to avoid collisions
179
-
180
- ## 2.0.0
181
-
182
- * update client to take advantage of new /api/v2 routes
183
-
184
- ## 0.1.17
185
-
186
- * Dataset#source_code is optional
187
-
188
-
189
- ## 0.1.16
190
-
191
- * add sheet description
192
-
193
- ## 0.1.15
194
-
195
- * revise parse_json to respond with more informative error
196
- * validation errors should return 422
197
-
198
- ## 0.1.14
199
-
200
- * add Dataset#locations spec to test that location data is returned in the same order as it is sent.
201
-
202
- ## 0.1.12
203
-
204
- * fix undefined error method
205
-
206
- ## 0.1.11
207
-
208
- * add spec for Dataset#availability_delay
209
- * add present?, exists?, blank? that check against response status.
210
- * remove erroneous source_code and code validations.
211
-
212
-
213
- ## 0.1.10
214
-
1
+ ## 2.7.12
2
+
3
+
4
+
5
+
6
+
7
+ ## 2.7.10
8
+ * QUGC-168 can pass request_platform
9
+
10
+
11
+ ## 2.7.9
12
+
13
+ * QUGC-164 also search by code
14
+ * QUGC-164 find by id or source_code/code, or build
15
+ * QUGC-164 attributes slice needs to ensure that keys are symbols
16
+
17
+
18
+
19
+ ## 2.7.8
20
+
21
+
22
+
23
+
24
+
25
+ ## 2.7.7
26
+
27
+
28
+
29
+
30
+
31
+ ## 2.7.6
32
+
33
+ * QUGC-140 if a source_code is given but does not exist, it should warn the user
34
+
35
+
36
+
37
+ ## 2.7.5
38
+ add 'at' option for scraper scheduling
39
+
40
+ ## 2.7.4
41
+ full url bug fixed when "api" has no / at the end
42
+
43
+
44
+ ## 2.6.2
45
+
46
+ * QUGC-55 Add Report for filing reports
47
+
48
+
49
+
50
+ ## 2.6.1
51
+
52
+ * QUGC-113 fix Dataset#data errors dont propagate to parent object
53
+ * QUGC-113 Write failing specs for Dataset#data errors dont propagate to parent object
54
+
55
+
56
+
57
+ ## 2.6.0
58
+
59
+ * QUGC-104 Fixes when upload fails output is not json
60
+ * QUGC-103 Fixes quandl upload test -F json does not include metadata
61
+
62
+
63
+
64
+ ## 2.5.2
65
+
66
+ * WIKI-153 Add scrapers
67
+
68
+
69
+ ## 2.5.1
70
+
71
+ * QUGC-57 move data validation from Quandl::Format into Quandl::Client. Data validations only run on #valid?
72
+ * QUGC-53 numeric codes require the full code
73
+
74
+
75
+ ## 2.5.0
76
+
77
+ * remove yajl
78
+
79
+
80
+ ## 2.4.9
81
+
82
+ * observe ruby platform
83
+
84
+
85
+ ## 2.4.7
86
+
87
+ * add middleware to track the origin of requests across quandl packages
88
+
89
+
90
+ ## 2.4.6
91
+
92
+ * QUGC-43 improved message on wrong number of colums
93
+ * QUGC-41 enforce code formatting. always upcase codes
94
+ * improved example of valid code
95
+ * revise code pattern
96
+
97
+
98
+ ## 2.4.5
99
+
100
+ * QUGC-40 add validation to enforce: You may not change number of columns in a dataset
101
+ * QUGC-37 Dataest.find accept backslash or forward slash interchangeably
102
+
103
+
104
+ ## 2.4.4
105
+
106
+ * Dataset#data to_table assigns column_names to headers
107
+ * add skip_browse to Sheet
108
+
109
+
110
+ ## 2.4.3
111
+
112
+ * hotfix for full_code pattern matching ... code can be as short as two characters
113
+
114
+
115
+ ## 2.4.2
116
+
117
+ * Dataset.find will return nil unless the id is an integer, or matches the quandl pattern for full_code
118
+
119
+
120
+ ## 2.4.1
121
+
122
+ * revise reference_url http prepend
123
+
124
+
125
+ ## 2.4.0
126
+
127
+ * Dataset#reference_url should prepend of http:// when missing
128
+ * add Quandl::Pattern for defining regex patterns with embedded examples
129
+
130
+
131
+ # 2.3.2
132
+
133
+ * add #elapsed_request_time_ms
134
+ * refactor save_time to request_time. Add specs to #destroy for request_started_at, finished_at, elapsed_request_time
135
+ * add Client::Base#save_started_at, #save_finished_at, #elapsed_save_time. before_save :touch_save_started_at, after_save :touch_save_finished_at
136
+
137
+
138
+ ## 2.3.1
139
+
140
+ * bump quandl_data
141
+ * add human_error_messsages
142
+
143
+
144
+ ## 2.3.0
145
+
146
+ * add auth_token attribute to user
147
+ * add Quandl::Client::User, .login for authenticating
148
+ * full_url outputs the quandl link instead of the api link. Add human_status and HTTP_STATUS_CODES
149
+ * should validate display_url as a url
150
+ * add reference_url alias for display_url. reference_url will automatically add http when missing
151
+
152
+
153
+ ## 2.2.1
154
+
155
+ * full_code: dont assume that source_code is present
156
+ * Dataset#data scope is cached to permit building across multiple lines. add Dataset#reload to wipe data_scope, dataset_data
157
+
158
+
159
+ ## 2.2.0
160
+
161
+ * add specs for Dataset.query
162
+ * Dataset.query.all.metadata should pass
163
+
164
+
165
+ ## 2.1.4
166
+
167
+ * add specs for Dataset.query(term).all; make specs pass
168
+
169
+
170
+
171
+ ## 2.1.3
172
+
173
+ * add specs for data scopes
174
+ * fix failing data scope specs
175
+
176
+
177
+ ## 2.1.2
178
+
179
+ * bump quandl_data, operation, logger
180
+
181
+
182
+ ## 2.0.1
183
+
184
+ * fully qualified classes to avoid collisions
185
+
186
+ ## 2.0.0
187
+
188
+ * update client to take advantage of new /api/v2 routes
189
+
190
+ ## 0.1.17
191
+
192
+ * Dataset#source_code is optional
193
+
194
+
195
+ ## 0.1.16
196
+
197
+ * add sheet description
198
+
199
+ ## 0.1.15
200
+
201
+ * revise parse_json to respond with more informative error
202
+ * validation errors should return 422
203
+
204
+ ## 0.1.14
205
+
206
+ * add Dataset#locations spec to test that location data is returned in the same order as it is sent.
207
+
208
+ ## 0.1.12
209
+
210
+ * fix undefined error method
211
+
212
+ ## 0.1.11
213
+
214
+ * add spec for Dataset#availability_delay
215
+ * add present?, exists?, blank? that check against response status.
216
+ * remove erroneous source_code and code validations.
217
+
218
+
219
+ ## 0.1.10
220
+
215
221
  * Add Dataset#availability_delay
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.11
1
+ 2.7.12
data/examples/create.rb CHANGED
@@ -1,32 +1,32 @@
1
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
-
3
- # load quandl api client
4
- require "quandl/client"
5
-
6
- # tools for debugging
7
- require "quandl/fabricate"
8
- require 'securerandom'
9
- require 'pry'
10
-
11
- # Make Dataset available in global namespace
12
- include Quandl::Client
13
-
14
- # configure quandl client
15
- Quandl::Client.use ENV['QUANDL_TEST_URL']
16
- Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
17
-
18
- # set some attributes
19
- d = Dataset.new(
20
- code: "MY_DATASET_#{Time.now.to_i.to_s(16)}",
21
- name: "My dataset has a name.",
22
- description: "This is the description.",
23
- data: [[ 2014, 1, 2 ]]
24
- )
25
- # POST to server
26
- d.save
27
-
28
- if d.saved?
29
- puts "View your new dataset at: #{d.full_url}"
30
- else
31
- puts "Something went wrong:\n#{d.human_status}\n#{d.human_error_messages}"
32
- end
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
3
+ # load quandl api client
4
+ require "quandl/client"
5
+
6
+ # tools for debugging
7
+ require "quandl/fabricate"
8
+ require 'securerandom'
9
+ require 'pry'
10
+
11
+ # Make Dataset available in global namespace
12
+ include Quandl::Client
13
+
14
+ # configure quandl client
15
+ Quandl::Client.use ENV['QUANDL_TEST_URL']
16
+ Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
17
+
18
+ # set some attributes
19
+ d = Dataset.new(
20
+ code: "MY_DATASET_#{Time.now.to_i.to_s(16)}",
21
+ name: "My dataset has a name.",
22
+ description: "This is the description.",
23
+ data: [[ 2014, 1, 2 ]]
24
+ )
25
+ # POST to server
26
+ d.save
27
+
28
+ if d.saved?
29
+ puts "View your new dataset at: #{d.full_url}"
30
+ else
31
+ puts "Something went wrong:\n#{d.human_status}\n#{d.human_error_messages}"
32
+ end
data/examples/find.rb CHANGED
@@ -1,18 +1,18 @@
1
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
-
3
- # DEBUGGING
4
- require 'pry'
5
- require "quandl/fabricate"
6
-
7
- # LOAD
8
- require "quandl/client"
9
- include Quandl::Client
10
-
11
- # CONFIGURE
12
- Quandl::Client.use ENV['QUANDL_URL']
13
- Quandl::Client.token = ENV['QUANDL_TOKEN']
14
-
15
- # FIND
16
- d = Dataset.find('MCX.ALMG2014')
17
-
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
3
+ # DEBUGGING
4
+ require 'pry'
5
+ require "quandl/fabricate"
6
+
7
+ # LOAD
8
+ require "quandl/client"
9
+ include Quandl::Client
10
+
11
+ # CONFIGURE
12
+ Quandl::Client.use ENV['QUANDL_URL']
13
+ Quandl::Client.token = ENV['QUANDL_TOKEN']
14
+
15
+ # FIND
16
+ d = Dataset.find('MCX.ALMG2014')
17
+
18
18
  binding.pry
data/examples/login.rb CHANGED
@@ -1,13 +1,13 @@
1
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
-
3
- require 'pry'
4
- require "quandl/client"
5
-
6
- include Quandl::Client
7
-
8
- Quandl::Client.use ENV['QUANDL_TEST_URL']
9
- Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
10
-
11
- u = User.login( login: 'blakehil', password: 'example' )
12
-
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
3
+ require 'pry'
4
+ require "quandl/client"
5
+
6
+ include Quandl::Client
7
+
8
+ Quandl::Client.use ENV['QUANDL_TEST_URL']
9
+ Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
10
+
11
+ u = User.login( login: 'blakehil', password: 'example' )
12
+
13
13
  binding.pry
data/examples/search.rb CHANGED
@@ -1,13 +1,13 @@
1
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
-
3
- require 'pry'
4
- require "quandl/client"
5
-
6
- include Quandl::Client
7
-
8
- Quandl::Client.use ENV['QUANDL_TEST_URL']
9
- Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
10
-
11
- datasets = Dataset.query('water').all
12
-
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
3
+ require 'pry'
4
+ require "quandl/client"
5
+
6
+ include Quandl::Client
7
+
8
+ Quandl::Client.use ENV['QUANDL_TEST_URL']
9
+ Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
10
+
11
+ datasets = Dataset.query('water').all
12
+
13
13
  binding.pry
data/examples/trims.rb CHANGED
@@ -1,16 +1,16 @@
1
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
-
3
- require 'pry'
4
- require "quandl/client"
5
-
6
- include Quandl::Client
7
-
8
- Quandl::Client.use 'http://quandl.com/api/'
9
- Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
10
-
11
- # create dataset
12
- d = Dataset.find('NSE/OIL')
13
-
14
- data = d.data.trim_start( 3.weeks.ago ).limit(10)
15
-
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+
3
+ require 'pry'
4
+ require "quandl/client"
5
+
6
+ include Quandl::Client
7
+
8
+ Quandl::Client.use 'http://quandl.com/api/'
9
+ Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
10
+
11
+ # create dataset
12
+ d = Dataset.find('NSE/OIL')
13
+
14
+ data = d.data.trim_start( 3.weeks.ago ).limit(10)
15
+
16
16
  binding.pry
@@ -1,16 +1,16 @@
1
- class Quandl::Client::Base
2
- module Attributes
3
-
4
- extend ActiveSupport::Concern
5
-
6
- def write_attribute(attribute, value)
7
- self.send(:"#{attribute}_will_change!") if @attributes[:"#{attribute}"] != value
8
- @attributes[:"#{attribute}"] = value
9
- end
10
-
11
- def read_attribute(attribute)
12
- @attributes[:"#{attribute}"]
13
- end
14
-
15
- end
1
+ class Quandl::Client::Base
2
+ module Attributes
3
+
4
+ extend ActiveSupport::Concern
5
+
6
+ def write_attribute(attribute, value)
7
+ self.send(:"#{attribute}_will_change!") if @attributes[:"#{attribute}"] != value
8
+ @attributes[:"#{attribute}"] = value
9
+ end
10
+
11
+ def read_attribute(attribute)
12
+ @attributes[:"#{attribute}"]
13
+ end
14
+
15
+ end
16
16
  end