quandl_client 2.6.2 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,8 +9,10 @@ require "quandl/client"
9
9
 
10
10
  include Quandl::Client
11
11
 
12
- Quandl::Client.use ENV['QUANDL_URL']
13
- Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN']
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
14
16
 
15
17
  task :default => :spec
16
18
 
data/UPGRADE.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 2.7.0
2
+
3
+
4
+
5
+
6
+
7
+ ## 2.7.0
8
+
9
+
10
+
11
+
12
+
1
13
  ## 2.6.2
2
14
 
3
15
  * QUGC-55 Add Report for filing reports
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.6.2
1
+ 2.7.0
@@ -14,7 +14,8 @@ module Search
14
14
  include ScopeComposer::Model
15
15
 
16
16
  has_scope_composer
17
-
17
+
18
+ scope :limit
18
19
  scope :with_id, ->(value) { where( id: value.to_i )}
19
20
  scope_helper :all, ->{ connection.where(attributes_with_scopes).fetch }
20
21
  scope_helper :connection, -> { self.class.parent }
@@ -41,6 +42,30 @@ module Search
41
42
  attributes.merge(scope_attributes)
42
43
  end
43
44
 
45
+ def each_in_page(options={}, &block)
46
+ # count
47
+ options[:count] ||= 0
48
+ options[:limit] ||= attributes[:limit]
49
+ # fetch records
50
+ records = all
51
+ # pass each record upstream
52
+ records.each do |r|
53
+ # is a limit set?
54
+ return if options[:limit].present? && options[:count] > options[:limit]
55
+ # call block
56
+ block.call( r )
57
+ # increase counter
58
+ options[:count] += 1
59
+ end
60
+ # blank array indidcates last page
61
+ return if records.blank? || records.count < records.try(:metadata).try(:[], :per_page).to_i
62
+ # next page
63
+ scope_attributes[:page] = 1 if scope_attributes[:page].blank?
64
+ scope_attributes[:page] = scope_attributes[:page].to_i + 1
65
+ # call recursively until we reach the end
66
+ each_in_page(options, &block)
67
+ end
68
+
44
69
  end
45
70
 
46
71
  end
@@ -7,25 +7,18 @@ module Validation
7
7
 
8
8
  before_save :halt_unless_valid!
9
9
 
10
- validate :response_errors_should_be_blank!
10
+ after_save :apply_response_errors
11
11
 
12
- def response_errors_should_be_blank!
12
+ def apply_response_errors
13
13
  return unless response_errors.respond_to?(:each)
14
14
  response_errors.each do |key, messages|
15
- if messages.respond_to?(:each)
16
- messages.each{|message| errors.add(key, message) }
15
+ if messages.respond_to?(:each) && @errors.respond_to?(:add)
16
+ messages.each{|message| @errors.add(key.to_sym, message) unless @errors.has_key?(key.to_sym) }
17
17
  end
18
18
  end
19
19
  true
20
20
  end
21
21
 
22
- def valid_with_server?
23
- return false unless valid?
24
- return false unless errors_params.blank?
25
- return false unless errors_server.blank?
26
- true
27
- end
28
-
29
22
  def save!
30
23
  save
31
24
  end
@@ -58,10 +51,6 @@ module Validation
58
51
  metadata[:status].to_i
59
52
  end
60
53
 
61
- def parse_error
62
- error_messages[:response_errors].try( :[], :parse_error )
63
- end
64
-
65
54
  def human_error_messages
66
55
  return if errors.blank?
67
56
  m = "#{status}\n"
@@ -72,30 +61,21 @@ module Validation
72
61
  end.flatten.compact.join
73
62
  end
74
63
 
75
- def human_error_message(name, message)
76
- message = message.join(', ') if message.respond_to?(:join)
77
- " #{name}: #{message}\n"
78
- end
79
-
80
64
  def error_messages
81
65
  valid?
82
- errors_client.deep_merge(errors_server).deep_merge(errors_params)
83
- end
84
-
85
- def errors_client
86
- errors.messages || {}
66
+ errors.messages
87
67
  end
88
68
 
89
- def errors_server
90
- messages = self.attributes[:errors] || {}
91
- messages[:message] = self.error if self.respond_to?(:error) && self.error.present?
92
- messages
69
+ def errors
70
+ apply_response_errors
71
+ super
93
72
  end
94
-
95
- def errors_params
96
- response_errors.present? ? { response_errors: response_errors } : {}
73
+
74
+ def human_error_message(name, message)
75
+ message = message.join(', ') if message.respond_to?(:join)
76
+ " #{name}: #{message}\n"
97
77
  end
98
-
78
+
99
79
  protected
100
80
 
101
81
  def halt_unless_valid!
@@ -72,7 +72,7 @@ class ParseJSON < Faraday::Response::Middleware
72
72
  json = {
73
73
  id: 1,
74
74
  errors: {
75
- parse_error: "Quandl::Client::ParseJSON error. status: #{env[:status]}, body: #{body.inspect}"
75
+ parse_errors: [ "Quandl::Client::ParseJSON error. status: #{env[:status]}, body: #{body.inspect}" ]
76
76
  }
77
77
  }
78
78
  end
@@ -28,7 +28,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
28
28
  end
29
29
 
30
30
  # SEARCH
31
- scope :query, :rows
31
+ scope :query, :rows, :owner
32
32
  scope :page, ->(p){ where( page: p.to_i )}
33
33
  scope :source_code, ->(c){ where( code: c.to_s.upcase )}
34
34
 
@@ -0,0 +1,40 @@
1
+ class Quandl::Client::Superset < Quandl::Client::Base
2
+
3
+ scope :query, :page, :owner, :code, :source_code
4
+
5
+ attributes :id, :source_code, :code, :name, :urlize_name, :description, :updated_at, :private
6
+ attributes :column_codes, :column_names
7
+ attributes :frequency, :from_date, :to_date
8
+
9
+ validates :code, presence: true, format: { with: Quandl::Pattern.code, message: "is invalid. Expected format: #{Quandl::Pattern.code.to_example}" }
10
+ validates :column_codes, presence: true
11
+ validate :column_codes_should_be_valid!
12
+
13
+ def data
14
+ @data ||= Quandl::Client::Dataset::Data.with_id(id)
15
+ end
16
+
17
+ protected
18
+
19
+ def column_codes_should_be_valid!
20
+ # must be an array
21
+ unless column_codes.respond_to?(:each)
22
+ # failure
23
+ self.errors.add( :column_codes, "expected an array, but got #{column_codes.class}.")
24
+ # nothing more to do
25
+ return false
26
+ end
27
+ # check each code
28
+ column_codes.each do |code|
29
+ # is the code valid?
30
+ next if code =~ /#{Quandl::Pattern.code}\.#{Quandl::Pattern.code}\.[0-9]+/
31
+ # otherwise report error
32
+ self.errors.add( :column_codes, "Code '#{code}' is invalid. Expected: /#{Quandl::Pattern.code.to_example}.#{Quandl::Pattern.code.to_example}.INTEGER/" )
33
+ # nothing more to do here
34
+ return false
35
+ end
36
+ # success
37
+ true
38
+ end
39
+
40
+ end
data/lib/quandl/client.rb CHANGED
@@ -18,6 +18,7 @@ require 'quandl/client/models/user'
18
18
  require 'quandl/client/models/location'
19
19
  require 'quandl/client/models/scraper'
20
20
  require 'quandl/client/models/report'
21
+ require 'quandl/client/models/superset'
21
22
 
22
23
  module Quandl
23
24
  module Client
@@ -23,8 +23,7 @@ describe Dataset do
23
23
  its(:status){ should eq 401 }
24
24
 
25
25
  its(:request_started_at){ should be_a Time }
26
- its(:request_finished_at){ should be_a Time }
27
- its(:elapsed_request_time){ should be > 0 }
26
+ its(:request_finished_at){ should eq nil }
28
27
 
29
28
  after(:all){ Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN'] }
30
29
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 2.7.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Blake Hilscher
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
12
+ date: 2014-03-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: quandl_data
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,20 +30,23 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: activesupport
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 3.0.0
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 3.0.0
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: her
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: json
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: scope_composer
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rake
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ~>
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ~>
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: rspec
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ~>
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ~>
109
124
  - !ruby/object:Gem::Version
@@ -111,20 +126,23 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: factory_girl_rails
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - '>='
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - '>='
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: fivemat
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ~>
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ~>
137
156
  - !ruby/object:Gem::Version
@@ -139,57 +158,65 @@ dependencies:
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: pry
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
- - - '>='
163
+ - - ! '>='
144
164
  - !ruby/object:Gem::Version
145
165
  version: '0'
146
166
  type: :development
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
- - - '>='
171
+ - - ! '>='
151
172
  - !ruby/object:Gem::Version
152
173
  version: '0'
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: guard
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
- - - '>='
179
+ - - ! '>='
158
180
  - !ruby/object:Gem::Version
159
181
  version: '0'
160
182
  type: :development
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
- - - '>='
187
+ - - ! '>='
165
188
  - !ruby/object:Gem::Version
166
189
  version: '0'
167
190
  - !ruby/object:Gem::Dependency
168
191
  name: guard-rspec
169
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
170
194
  requirements:
171
- - - '>='
195
+ - - ! '>='
172
196
  - !ruby/object:Gem::Version
173
197
  version: '0'
174
198
  type: :development
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
177
202
  requirements:
178
- - - '>='
203
+ - - ! '>='
179
204
  - !ruby/object:Gem::Version
180
205
  version: '0'
181
206
  - !ruby/object:Gem::Dependency
182
207
  name: quandl_utility
183
208
  requirement: !ruby/object:Gem::Requirement
209
+ none: false
184
210
  requirements:
185
- - - '>='
211
+ - - ! '>='
186
212
  - !ruby/object:Gem::Version
187
213
  version: '0'
188
214
  type: :development
189
215
  prerelease: false
190
216
  version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
191
218
  requirements:
192
- - - '>='
219
+ - - ! '>='
193
220
  - !ruby/object:Gem::Version
194
221
  version: '0'
195
222
  description: An orm for the cassinatra rest interface.
@@ -230,6 +257,7 @@ files:
230
257
  - lib/quandl/client/models/scraper.rb
231
258
  - lib/quandl/client/models/sheet.rb
232
259
  - lib/quandl/client/models/source.rb
260
+ - lib/quandl/client/models/superset.rb
233
261
  - lib/quandl/client/models/user.rb
234
262
  - lib/quandl/client/version.rb
235
263
  - lib/quandl/her/remove_method_data.rb
@@ -256,26 +284,33 @@ files:
256
284
  homepage: http://blake.hilscher.ca/
257
285
  licenses:
258
286
  - MIT
259
- metadata: {}
260
287
  post_install_message:
261
288
  rdoc_options: []
262
289
  require_paths:
263
290
  - lib
264
291
  required_ruby_version: !ruby/object:Gem::Requirement
292
+ none: false
265
293
  requirements:
266
- - - '>='
294
+ - - ! '>='
267
295
  - !ruby/object:Gem::Version
268
296
  version: '0'
297
+ segments:
298
+ - 0
299
+ hash: 1086237193611827581
269
300
  required_rubygems_version: !ruby/object:Gem::Requirement
301
+ none: false
270
302
  requirements:
271
- - - '>='
303
+ - - ! '>='
272
304
  - !ruby/object:Gem::Version
273
305
  version: '0'
306
+ segments:
307
+ - 0
308
+ hash: 1086237193611827581
274
309
  requirements: []
275
310
  rubyforge_project:
276
- rubygems_version: 2.1.10
311
+ rubygems_version: 1.8.23
277
312
  signing_key:
278
- specification_version: 4
313
+ specification_version: 3
279
314
  summary: Client rest orm.
280
315
  test_files:
281
316
  - spec/factories/dataset.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 454f69cbe4f61aaa0df1982140c16d450b469270
4
- data.tar.gz: f7c57a5ee81fd54fb4076d4782028985499100a4
5
- SHA512:
6
- metadata.gz: b53f0cd1b254d0e97152059408c159a5651ee0f79ff28c2bae01f85cee93ffc3aff1e0db9f4fcbf382657d9fc1c3705b2b43a2727f20b78e5af350ebddb80e90
7
- data.tar.gz: e1d557e659627e0ef55ac3640631f440623f75871ff50c1a287f1ebe93bf763fbd1d2f083f63cf79f4e54d7378f3f797215ea6119ff1ca28161c09d778fa8d9c