quandl_client 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 143f4ec1982c74d12e16b00bb624f1b2002ce8dc
4
- data.tar.gz: 79e557b77dfe07589dace275a5e15e676d267934
3
+ metadata.gz: 8f3c7b2e6d00eae927b27582c0639e2335f8baaf
4
+ data.tar.gz: 92fab0d74f709dffc8ee74694ba2508caf0e1122
5
5
  SHA512:
6
- metadata.gz: 7a42782c545a694c737a9320c7492d6b19ec727fb463e955affaa19b3fcdf534c372dc584764915378bd80fe2a050fe25e52ae6f9d8c99d2bc3d9bfa9028c4a5
7
- data.tar.gz: ff681713db7ec3b8bf1b6664a916f4ea5223df2ac72971ab7d3540141f62297371e33eacdddfd3ffb65e09742e40686ff2aa225560d8ab792e2cd56804769f9d
6
+ metadata.gz: a4e52c2c6c007ae90725f3dd46bec811e599e446fdfcbdc8598997cf5901c3d5fd8b7161aef6985dab70090a5aa9a5721542c18a7bbdc2f219f29511ea5977bf
7
+ data.tar.gz: 06d31ce69a4f5d0ce1d24de67bd6269a53acc71bcecd969770e9cf2dbcd89653c0f22043af0088d22ce6b215654e33112ab8417d1cfbbfff2406fc7c95c7765c
data/README.md CHANGED
@@ -1,4 +1,11 @@
1
- # Installation
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
2
9
 
3
10
  ```ruby
4
11
 
@@ -9,7 +16,7 @@ gem 'quandl_client'
9
16
 
10
17
 
11
18
 
12
- # Configuration
19
+ ## Configuration
13
20
 
14
21
  ```ruby
15
22
 
@@ -24,10 +31,10 @@ Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN']
24
31
 
25
32
 
26
33
 
27
- # Usage
34
+ ## Usage
28
35
 
29
36
 
30
- ## Quandl::Client::Dataset
37
+ ### Quandl::Client::Dataset
31
38
 
32
39
 
33
40
  #### Search
@@ -151,7 +158,7 @@ d.error_messages
151
158
 
152
159
 
153
160
 
154
- ## Quandl::Client::Source
161
+ ### Quandl::Client::Source
155
162
 
156
163
 
157
164
  #### Search
@@ -214,7 +221,7 @@ Source.destroy_existing(52352)
214
221
 
215
222
 
216
223
 
217
- ## Quandl::Client::Sheet
224
+ ### Quandl::Client::Sheet
218
225
 
219
226
 
220
227
  #### Search
@@ -277,7 +284,7 @@ Quandl::Client::Sheet.destroy_existing(15252)
277
284
 
278
285
 
279
286
 
280
- # Authentication
287
+ ### Authentication
281
288
 
282
289
  ```ruby
283
290
 
data/Rakefile CHANGED
@@ -9,8 +9,8 @@ require "quandl/client"
9
9
 
10
10
  include Quandl::Client
11
11
 
12
- Quandl::Client.use ENV['QUANDL_TEST_URL']
13
- Quandl::Client.token = ENV['QUANDL_TEST_TOKEN']
12
+ Quandl::Client.use ENV['QUANDL_URL']
13
+ Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN']
14
14
 
15
15
  task :default => :spec
16
16
 
data/UPGRADE.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 2.6.1
2
+
3
+ * QUGC-113 fix Dataset#data errors dont propagate to parent object
4
+ * QUGC-113 Write failing specs for Dataset#data errors dont propagate to parent object
5
+
6
+
7
+
1
8
  ## 2.6.0
2
9
 
3
10
  * QUGC-104 Fixes when upload fails output is not json
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.6.1
@@ -7,6 +7,18 @@ module Validation
7
7
 
8
8
  before_save :halt_unless_valid!
9
9
 
10
+ validate :response_errors_should_be_blank!
11
+
12
+ def response_errors_should_be_blank!
13
+ return unless response_errors.respond_to?(:each)
14
+ response_errors.each do |key, messages|
15
+ if messages.respond_to?(:each)
16
+ messages.each{|message| errors.add(key, message) }
17
+ end
18
+ end
19
+ true
20
+ end
21
+
10
22
  def valid_with_server?
11
23
  return false unless valid?
12
24
  return false unless errors_params.blank?
@@ -47,6 +47,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
47
47
  validates :code, presence: true, format: { with: Quandl::Pattern.code, message: "is invalid. Expected format: #{Quandl::Pattern.code.to_example}" }
48
48
  validates :display_url, allow_blank: true, url: true
49
49
  validate :data_should_be_valid!
50
+ validate :dataset_data_should_be_valid!
50
51
  validate :data_row_count_should_match_column_count!
51
52
  validate :data_columns_should_not_exceed_column_names!
52
53
  validate :data_rows_should_have_equal_columns!
@@ -124,6 +125,10 @@ class Quandl::Client::Dataset < Quandl::Client::Base
124
125
  @dataset_data ||= Quandl::Client::Dataset::Data.new( id: id )
125
126
  end
126
127
 
128
+ def dataset_data?
129
+ @dataset_data.is_a?(Quandl::Client::Dataset::Data)
130
+ end
131
+
127
132
  def reload
128
133
  @dataset_data = nil
129
134
  @data_scope = nil
@@ -140,6 +145,14 @@ class Quandl::Client::Dataset < Quandl::Client::Base
140
145
  true
141
146
  end
142
147
 
148
+ def dataset_data_should_be_valid!
149
+ if dataset_data? && !dataset_data.valid?
150
+ dataset_data.errors.each{|k,v| self.errors.add( k,v ) }
151
+ return false
152
+ end
153
+ true
154
+ end
155
+
143
156
  def ambiguous_code_requires_source_code!
144
157
  if code.to_s.numeric? && source_code.blank?
145
158
  message = %Q{Pure numerical codes like "#{code}" are not allowed unless you include a source code. Do this:\nsource_code: <USERNAME>\ncode: #{code}}
@@ -200,7 +213,20 @@ class Quandl::Client::Dataset < Quandl::Client::Base
200
213
  dataset_data.save
201
214
  # update dataset's attributes with dataset_data's attributes
202
215
  attributes.each{|k,v| attributes[k] = dataset_data.attributes[k] if dataset_data.attributes.has_key?(k) }
216
+ # update dataset errors with dataset_data
203
217
  @metadata[:status] = dataset_data.status unless dataset_data.saved?
218
+ # inherit_errors(dataset_data) unless dataset_data.saved?
219
+ end
220
+
221
+ def inherit_errors(object)
222
+ return unless object.respond_to?(:response_errors) && object.response_errors.respond_to?(:each)
223
+ object.response_errors.each do |key, messages|
224
+ if messages.respond_to?(:each)
225
+ messages.each{|message| errors.add(key, message) }
226
+ end
227
+ end
228
+ @metadata[:status] = object.status
229
+ object
204
230
  end
205
231
 
206
232
  def enforce_required_formats
@@ -15,7 +15,8 @@ describe Scraper do
15
15
 
16
16
  context "save" do
17
17
  before(:each){ scraper.save }
18
- its(:error_messages){ should eq( {:response_errors => {"location" => ["You must provide one of: [ scraper_url, git_url ]"]}}) }
18
+ its("error_messages.to_s"){ should match "You must provide one of" }
19
+ its("error_messages.to_s"){ should match "scraper_url, git_url" }
19
20
  end
20
21
 
21
22
  context "scraper= File" do
@@ -49,7 +50,7 @@ describe Scraper do
49
50
  scraper.git_url = "git@github.com:tammer/scrapers.git"
50
51
  scraper.save
51
52
  }
52
- its(:error_messages){ should eq({:response_errors=>{"location.reference"=>["can't be blank"]}}) }
53
+ its("error_messages.to_s"){ should match %Q{can't be blank} }
53
54
  end
54
55
 
55
56
  context "git_url='git@github.com:tammer/scrapers.git' & git_reference='master'" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-05 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: quandl_data