quandl_client 2.5.3 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -1
- data/UPGRADE.md +7 -0
- data/VERSION +1 -0
- data/lib/quandl/client/models/dataset.rb +21 -7
- data/lib/quandl/client/models/dataset/data.rb +4 -4
- data/lib/quandl/client/version.rb +1 -1
- data/quandl_client.gemspec +7 -6
- data/spec/lib/quandl/client/dataset/persistence_spec.rb +1 -1
- data/spec/lib/quandl/client/dataset/validation_spec.rb +15 -2
- metadata +72 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 143f4ec1982c74d12e16b00bb624f1b2002ce8dc
|
4
|
+
data.tar.gz: 79e557b77dfe07589dace275a5e15e676d267934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a42782c545a694c737a9320c7492d6b19ec727fb463e955affaa19b3fcdf534c372dc584764915378bd80fe2a050fe25e52ae6f9d8c99d2bc3d9bfa9028c4a5
|
7
|
+
data.tar.gz: ff681713db7ec3b8bf1b6664a916f4ea5223df2ac72971ab7d3540141f62297371e33eacdddfd3ffb65e09742e40686ff2aa225560d8ab792e2cd56804769f9d
|
data/Rakefile
CHANGED
@@ -21,4 +21,12 @@ end
|
|
21
21
|
|
22
22
|
task :console do |t, args|
|
23
23
|
binding.pry
|
24
|
-
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'quandl/utility/rake_tasks'
|
27
|
+
Quandl::Utility::Tasks.configure do |c|
|
28
|
+
c.name = 'quandl_client'
|
29
|
+
c.version_path = 'VERSION'
|
30
|
+
c.changelog_path = 'UPGRADE.md'
|
31
|
+
c.changelog_matching = ['^QUGC','^WIKI']
|
32
|
+
end
|
data/UPGRADE.md
CHANGED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.0
|
@@ -46,6 +46,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
46
46
|
|
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
|
+
validate :data_should_be_valid!
|
49
50
|
validate :data_row_count_should_match_column_count!
|
50
51
|
validate :data_columns_should_not_exceed_column_names!
|
51
52
|
validate :data_rows_should_have_equal_columns!
|
@@ -88,11 +89,15 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
88
89
|
# DATA
|
89
90
|
|
90
91
|
def data
|
91
|
-
|
92
|
+
defined?(@data) ? @data : data_scope
|
92
93
|
end
|
93
94
|
|
94
95
|
def data=(value)
|
95
|
-
|
96
|
+
@data = Quandl::Data.new(value).sort_descending
|
97
|
+
end
|
98
|
+
|
99
|
+
def data?
|
100
|
+
@data.is_a?(Quandl::Data)
|
96
101
|
end
|
97
102
|
|
98
103
|
def delete_data
|
@@ -127,6 +132,14 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
127
132
|
|
128
133
|
protected
|
129
134
|
|
135
|
+
def data_should_be_valid!
|
136
|
+
if data? && !data.valid?
|
137
|
+
data.errors.each{|k,v| self.errors.add( k,v ) }
|
138
|
+
return false
|
139
|
+
end
|
140
|
+
true
|
141
|
+
end
|
142
|
+
|
130
143
|
def ambiguous_code_requires_source_code!
|
131
144
|
if code.to_s.numeric? && source_code.blank?
|
132
145
|
message = %Q{Pure numerical codes like "#{code}" are not allowed unless you include a source code. Do this:\nsource_code: <USERNAME>\ncode: #{code}}
|
@@ -137,7 +150,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
137
150
|
end
|
138
151
|
|
139
152
|
def data_columns_should_not_exceed_column_names!
|
140
|
-
if errors.size == 0 &&
|
153
|
+
if errors.size == 0 && data? && data.present? && column_names.present? && data.first.count != column_names.count
|
141
154
|
self.errors.add( :data, "You may not change the number of columns in a dataset. This dataset has #{column_names.count} columns but you tried to send #{data.first.count} columns." )
|
142
155
|
return false
|
143
156
|
end
|
@@ -146,7 +159,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
146
159
|
|
147
160
|
def data_rows_should_have_equal_columns!
|
148
161
|
# skip validation unless data is present
|
149
|
-
return true unless
|
162
|
+
return true unless data? && data.present?
|
150
163
|
# use first row as expected column count
|
151
164
|
column_count = data[0].count
|
152
165
|
# check each row
|
@@ -163,7 +176,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
163
176
|
|
164
177
|
def data_row_count_should_match_column_count!
|
165
178
|
# skip validation unless data and column_names present
|
166
|
-
return true unless
|
179
|
+
return true unless data? && data.present? && column_names.present?
|
167
180
|
# count the number of expected columns
|
168
181
|
column_count = column_names.count
|
169
182
|
# check each row
|
@@ -180,13 +193,14 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
180
193
|
|
181
194
|
def save_dataset_data
|
182
195
|
return if (!saved? && id.blank?)
|
183
|
-
return if !
|
196
|
+
return if !data? || data.blank?
|
184
197
|
|
185
198
|
dataset_data.id = id
|
199
|
+
dataset_data.data = data.to_csv
|
186
200
|
dataset_data.save
|
187
201
|
# update dataset's attributes with dataset_data's attributes
|
188
202
|
attributes.each{|k,v| attributes[k] = dataset_data.attributes[k] if dataset_data.attributes.has_key?(k) }
|
189
|
-
@metadata[:status] = dataset_data.status
|
203
|
+
@metadata[:status] = dataset_data.status unless dataset_data.saved?
|
190
204
|
end
|
191
205
|
|
192
206
|
def enforce_required_formats
|
@@ -40,17 +40,17 @@ class Quandl::Client::Dataset::Data < Quandl::Client::Base
|
|
40
40
|
def data
|
41
41
|
read_data
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def data=(value)
|
45
45
|
write_data(value)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
protected
|
49
|
-
|
49
|
+
|
50
50
|
def read_data
|
51
51
|
Quandl::Data.new( read_attribute(:data) )
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def write_data(value )
|
55
55
|
write_attribute(:data, Quandl::Data.new(value).to_csv )
|
56
56
|
end
|
data/quandl_client.gemspec
CHANGED
@@ -17,6 +17,12 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
+
s.add_runtime_dependency "quandl_data", "~> 1.4"
|
21
|
+
s.add_runtime_dependency "activesupport", ">= 3.0.0"
|
22
|
+
s.add_runtime_dependency "her", "~> 0.6"
|
23
|
+
s.add_runtime_dependency 'json', '~> 1.7.7'
|
24
|
+
s.add_runtime_dependency "scope_composer", "~> 0.3"
|
25
|
+
|
20
26
|
s.add_development_dependency "rake", "~> 10.0"
|
21
27
|
s.add_development_dependency "rspec", "~> 2.13"
|
22
28
|
s.add_development_dependency "factory_girl_rails"
|
@@ -24,10 +30,5 @@ Gem::Specification.new do |s|
|
|
24
30
|
s.add_development_dependency "pry"
|
25
31
|
s.add_development_dependency "guard"
|
26
32
|
s.add_development_dependency "guard-rspec"
|
27
|
-
|
28
|
-
s.add_runtime_dependency "quandl_data", "~> 1.3"
|
29
|
-
s.add_runtime_dependency "activesupport", ">= 3.0.0"
|
30
|
-
s.add_runtime_dependency "her", "~> 0.6"
|
31
|
-
s.add_runtime_dependency 'json', '~> 1.7.7'
|
32
|
-
s.add_runtime_dependency "scope_composer", "~> 0.3"
|
33
|
+
s.add_development_dependency "quandl_utility"
|
33
34
|
end
|
@@ -6,6 +6,15 @@ describe Dataset do
|
|
6
6
|
let(:dataset){ build(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE" ) }
|
7
7
|
subject{ dataset }
|
8
8
|
|
9
|
+
context "data='1980,10,20\nASDF,10,30'" do
|
10
|
+
before(:each){
|
11
|
+
dataset.data = '1980,10,20\nASDF,10,30'
|
12
|
+
dataset.valid?
|
13
|
+
}
|
14
|
+
its(:valid?){ should be_false }
|
15
|
+
its('errors.messages'){ should eq({ data: ["Invalid date 'ASDF'"] }) }
|
16
|
+
end
|
17
|
+
|
9
18
|
context "given ambiguous code" do
|
10
19
|
before(:each){
|
11
20
|
dataset.source_code = nil
|
@@ -22,7 +31,9 @@ describe Dataset do
|
|
22
31
|
dataset.valid?
|
23
32
|
}
|
24
33
|
its(:valid?){ should be_false }
|
25
|
-
its('errors.messages'){ should eq({ data:
|
34
|
+
its('errors.messages'){ should eq({ data:
|
35
|
+
["Unexpected number of points in this row:\n2011-12-31,1.0,2.0,3.0\nFound 3 but expected 2 based on precedent from the first row (2012-12-31,1.0,2.0)"]
|
36
|
+
})}
|
26
37
|
end
|
27
38
|
|
28
39
|
context "mismatch column_names count" do
|
@@ -32,7 +43,9 @@ describe Dataset do
|
|
32
43
|
dataset.valid?
|
33
44
|
}
|
34
45
|
its(:valid?){ should be_false }
|
35
|
-
its('errors.messages'){ should eq({ data:
|
46
|
+
its('errors.messages'){ should eq({ data:
|
47
|
+
["Unexpected number of points in this row:\n2012-12-31,18.0,21.0\nFound 2 but expected 1 based on precedent from the header row (Date,Value)"]
|
48
|
+
})}
|
36
49
|
end
|
37
50
|
|
38
51
|
describe "#code" do
|
metadata
CHANGED
@@ -1,101 +1,115 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
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-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: quandl_data
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: her
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ~>
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
47
|
+
version: '0.6'
|
48
|
+
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - ~>
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0.6'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: json
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ~>
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
61
|
+
version: 1.7.7
|
62
|
+
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ~>
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 1.7.7
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: scope_composer
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ~>
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
type: :
|
75
|
+
version: '0.3'
|
76
|
+
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - ~>
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0.3'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ~>
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
89
|
+
version: '10.0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ~>
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
96
|
+
version: '10.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ~>
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '2.13'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ~>
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '2.13'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: factory_girl_rails
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - '>='
|
@@ -109,75 +123,75 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: fivemat
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - ~>
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
118
|
-
type: :
|
131
|
+
version: '1.2'
|
132
|
+
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - ~>
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
138
|
+
version: '1.2'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: pry
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - '>='
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
132
|
-
type: :
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - '>='
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
154
|
+
name: guard
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- -
|
157
|
+
- - '>='
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0
|
146
|
-
type: :
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- -
|
164
|
+
- - '>='
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
168
|
+
name: guard-rspec
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
|
-
- -
|
171
|
+
- - '>='
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
160
|
-
type: :
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
|
-
- -
|
178
|
+
- - '>='
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
182
|
+
name: quandl_utility
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
|
-
- -
|
185
|
+
- - '>='
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0
|
174
|
-
type: :
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
|
-
- -
|
192
|
+
- - '>='
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0
|
194
|
+
version: '0'
|
181
195
|
description: An orm for the cassinatra rest interface.
|
182
196
|
email:
|
183
197
|
- blake@hilscher.ca
|
@@ -195,6 +209,7 @@ files:
|
|
195
209
|
- README.md
|
196
210
|
- Rakefile
|
197
211
|
- UPGRADE.md
|
212
|
+
- VERSION
|
198
213
|
- examples/create.rb
|
199
214
|
- examples/find.rb
|
200
215
|
- examples/login.rb
|