quandl_format 0.1.3 → 0.1.4
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 +4 -4
- data/UPGRADE.md +8 -0
- data/lib/quandl/error/column_count_mismatch.rb +7 -0
- data/lib/quandl/error/unknown_attribute.rb +7 -0
- data/lib/quandl/format/dataset/attributes.rb +5 -5
- data/lib/quandl/format/version.rb +1 -1
- data/lib/quandl/format.rb +4 -1
- data/quandl_format.gemspec +1 -0
- data/spec/fixtures/data/annual.qdf +10 -0
- data/spec/lib/quandl/format/dataset/errors_spec.rb +22 -0
- metadata +19 -2
- data/lib/quandl/format/errors.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20078bc556c8155d90a29be038f3963b31167767
|
4
|
+
data.tar.gz: 3b13078bacc4f36a41cb841d7badb831d34738b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88f642d299a714d1b72d8047ee11fbf4f453e0dfd14ebec20d6a0dd92b9d9be45fd0b47c905b1eeae99373d226a96fceb2d6d0f2aa8bd28645959a724fd2d0b3
|
7
|
+
data.tar.gz: b5a488472d4b176a89c71ec0462fe2ac5522cae40854323b543ab119ae859499d440af1633934d67018fd76a41601c008b8269943aec5c64750bcf5f3ae35565
|
data/UPGRADE.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.1.4
|
2
|
+
|
3
|
+
* Add quandl_babelfish as a runtime_dependency
|
4
|
+
* add spec for annual data using Babelfish.clean
|
5
|
+
* refactor errors to be general to Quandl::Error
|
6
|
+
* switch incoming data to use babelfish. column_names come from babelfish.headers
|
7
|
+
|
8
|
+
|
1
9
|
## 0.1.2
|
2
10
|
|
3
11
|
* mismatched columns should raise ColumnCountMismatch
|
@@ -59,8 +59,8 @@ module Attributes
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def data=(rows)
|
62
|
-
|
63
|
-
@data
|
62
|
+
@data = Quandl::Babelfish::Data.new(rows).to_date
|
63
|
+
self.column_names = @data.headers if @data.headers.present?
|
64
64
|
data_row_count_should_match_column_count!
|
65
65
|
data_rows_should_have_equal_columns!
|
66
66
|
@data
|
@@ -104,17 +104,17 @@ module Attributes
|
|
104
104
|
|
105
105
|
def raise_row_column_mismatch!(row, index)
|
106
106
|
m = "ColumnCountMismatch #{full_code} data[0] had #{data[0].count} columns, but data[#{index}] had #{row.count} #{row}"
|
107
|
-
raise Quandl::
|
107
|
+
raise Quandl::Error::ColumnCountMismatch, m
|
108
108
|
end
|
109
109
|
|
110
110
|
def raise_column_count_mismatch!(row, index)
|
111
111
|
m = "ColumnCountMismatch #{full_code} column_names had #{column_names.count} columns, but data[#{index}] had #{row.count} #{row}"
|
112
|
-
raise Quandl::
|
112
|
+
raise Quandl::Error::ColumnCountMismatch, m
|
113
113
|
end
|
114
114
|
|
115
115
|
def raise_unknown_attribute_error!(key)
|
116
116
|
m = "UnknownAttribute #{key} recognized attributes are: #{self.class.attribute_names}"
|
117
|
-
raise Quandl::
|
117
|
+
raise Quandl::Error::UnknownAttribute, m
|
118
118
|
end
|
119
119
|
|
120
120
|
|
data/lib/quandl/format.rb
CHANGED
@@ -5,13 +5,16 @@ require "quandl/format/version"
|
|
5
5
|
require 'csv'
|
6
6
|
|
7
7
|
require 'quandl/client'
|
8
|
+
require 'quandl/babelfish'
|
8
9
|
|
9
10
|
require "active_support"
|
10
11
|
require "active_support/inflector"
|
11
12
|
require "active_support/core_ext/hash"
|
12
13
|
require "active_support/core_ext/object"
|
13
14
|
|
14
|
-
require 'quandl/
|
15
|
+
require 'quandl/error/column_count_mismatch'
|
16
|
+
require 'quandl/error/unknown_attribute'
|
17
|
+
|
15
18
|
require 'quandl/format/dataset'
|
16
19
|
require 'quandl/client/dataset/to_qdf'
|
17
20
|
|
data/quandl_format.gemspec
CHANGED
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Quandl::Format::Dataset do
|
5
5
|
subject{ data }
|
6
|
+
|
6
7
|
context "valid.qdf" do
|
7
8
|
let(:data){ Quandl::Format::Dataset.load( fixtures_data['valid'] ) }
|
8
9
|
|
@@ -18,6 +19,27 @@ describe Quandl::Format::Dataset do
|
|
18
19
|
its(:data){ should eq Quandl::Data.new([['2013-11-22','1252.0','454.95','448.2','450.0','450.0','1354405.0','6099.41'],['2013-11-21','452.25','457.75','449.1','451.2','451.0','218881.0','992.94']]) }
|
19
20
|
end
|
20
21
|
end
|
22
|
+
|
23
|
+
context "annual.qdf" do
|
24
|
+
let(:data){ Quandl::Format::Dataset.load( fixtures_data['annual'] ) }
|
25
|
+
|
26
|
+
it{ should be_a Array }
|
27
|
+
its(:count){ should eq 1 }
|
28
|
+
|
29
|
+
describe "#first" do
|
30
|
+
subject{ data.first }
|
31
|
+
its(:code){ should eq 'ANNUAL_DATA' }
|
32
|
+
its(:name){ should eq 'A new title' }
|
33
|
+
its(:description){ should eq 'Annual Data'}
|
34
|
+
its(:column_names){ should eq ['Date','Open','High']}
|
35
|
+
its(:data){ should eq [
|
36
|
+
[ Date.parse('2013-12-31'), 1252.0, 454.95 ],
|
37
|
+
[ Date.parse('2012-12-31'), 452.25, 457.75 ],
|
38
|
+
[ Date.parse('2011-12-31'), 452.25, 457.75 ],
|
39
|
+
[ Date.parse('2010-12-31'), 452.25, 457.75 ],
|
40
|
+
]}
|
41
|
+
end
|
42
|
+
end
|
21
43
|
|
22
44
|
expected_errors = [
|
23
45
|
{ file: 'invalid_data', error: /Date/ },
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Hilscher
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: quandl_babelfish
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: quandl_client
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,17 +152,19 @@ files:
|
|
138
152
|
- UPGRADE.md
|
139
153
|
- examples/load.rb
|
140
154
|
- lib/quandl/client/dataset/to_qdf.rb
|
155
|
+
- lib/quandl/error/column_count_mismatch.rb
|
156
|
+
- lib/quandl/error/unknown_attribute.rb
|
141
157
|
- lib/quandl/format.rb
|
142
158
|
- lib/quandl/format/dataset.rb
|
143
159
|
- lib/quandl/format/dataset/attributes.rb
|
144
160
|
- lib/quandl/format/dataset/client.rb
|
145
161
|
- lib/quandl/format/dataset/dump.rb
|
146
162
|
- lib/quandl/format/dataset/load.rb
|
147
|
-
- lib/quandl/format/errors.rb
|
148
163
|
- lib/quandl/format/version.rb
|
149
164
|
- quandl_format.gemspec
|
150
165
|
- spec/config/client.rb
|
151
166
|
- spec/config/logger.rb
|
167
|
+
- spec/fixtures/data/annual.qdf
|
152
168
|
- spec/fixtures/data/invalid_data.qdf
|
153
169
|
- spec/fixtures/data/invalid_yaml.qdf
|
154
170
|
- spec/fixtures/data/mismatched_columns.qdf
|
@@ -190,6 +206,7 @@ summary: Quandl Data Format
|
|
190
206
|
test_files:
|
191
207
|
- spec/config/client.rb
|
192
208
|
- spec/config/logger.rb
|
209
|
+
- spec/fixtures/data/annual.qdf
|
193
210
|
- spec/fixtures/data/invalid_data.qdf
|
194
211
|
- spec/fixtures/data/invalid_yaml.qdf
|
195
212
|
- spec/fixtures/data/mismatched_columns.qdf
|