quandl_format 0.2.2 → 0.2.3
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 +6 -0
- data/lib/quandl/format/dataset/attributes.rb +6 -1
- data/lib/quandl/format/dataset/client.rb +1 -1
- data/lib/quandl/format/version.rb +1 -1
- data/spec/config/client.rb +1 -1
- data/spec/fixtures/data/metadata_only.qdf +14 -0
- data/spec/lib/quandl/format/dataset/load/errors_spec.rb +13 -15
- data/spec/lib/quandl/format/dataset/load/valid_spec.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8747d31194c3966461bf384e9fa12252a686bac4
|
4
|
+
data.tar.gz: 19255b2e97e72da07ea8f5ebecefc96226327e2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76592d61eee87bb506abd24bdc4e7230b340e98c359ff9a87ab95f8765c41e3f71351e171724bc8c1aabb0409af1738a90ccd891ad73b3e4108a608c227a946f
|
7
|
+
data.tar.gz: e555d771b8d7c7fcd510dc6c48cac1e7a2bbce9fd6410b39a31918daa00ac0ebaa2f484f86bc9e8c989d5096873bc63eb4b32e37a89c2acf29bfd01a38db90ec
|
data/UPGRADE.md
CHANGED
@@ -51,7 +51,7 @@ module Attributes
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def full_code
|
54
|
-
[source_code, code].join('/')
|
54
|
+
[source_code, code].collect{|v| v.blank? ? nil : v }.compact.join('/')
|
55
55
|
end
|
56
56
|
|
57
57
|
def description=(value)
|
@@ -65,6 +65,10 @@ module Attributes
|
|
65
65
|
data_rows_should_have_equal_columns!
|
66
66
|
@data
|
67
67
|
end
|
68
|
+
|
69
|
+
def column_names
|
70
|
+
@column_names ||= []
|
71
|
+
end
|
68
72
|
|
69
73
|
def column_names=(names)
|
70
74
|
@column_names = Array(names).flatten.collect{|n| n.strip.rstrip }
|
@@ -85,6 +89,7 @@ module Attributes
|
|
85
89
|
protected
|
86
90
|
|
87
91
|
def data_rows_should_have_equal_columns!
|
92
|
+
return if data.blank?
|
88
93
|
row_count = data[0].count
|
89
94
|
data.each_with_index do |row, index|
|
90
95
|
raise_row_column_mismatch!(row, index) unless row.count == row_count
|
data/spec/config/client.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
Quandl::Client.token = ENV['QUANDL_AUTH_TOKEN']
|
2
|
-
Quandl::Client.use ENV['
|
2
|
+
Quandl::Client.use ENV['QUANDL_TEST_URL']
|
@@ -0,0 +1,14 @@
|
|
1
|
+
code: "BLAKE_TEST_1"
|
2
|
+
name: "A new title"
|
3
|
+
description: "The description Date, Open, High"
|
4
|
+
private: false
|
5
|
+
-
|
6
|
+
code: "BLAKE_TEST_2"
|
7
|
+
name: "A new title"
|
8
|
+
description: "The description Date, Open, High"
|
9
|
+
private: false
|
10
|
+
-
|
11
|
+
code: "BLAKE_TEST_3"
|
12
|
+
name: "A new title"
|
13
|
+
description: "The description Date, Open, High"
|
14
|
+
private: false
|
@@ -2,22 +2,20 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Quandl::Format::Dataset do
|
5
|
-
|
6
|
-
|
7
|
-
{
|
8
|
-
|
9
|
-
|
10
|
-
{ file: 'invalid_yaml', error: /could not find expected ':'/ },
|
11
|
-
{ file: 'missing_dashes', error: /Attribute parse error at line 28 column 1/ },
|
12
|
-
{ file: 'missing_dashes', error: /Did you forget to delimit the meta data section/ },
|
13
|
-
]
|
14
|
-
|
15
|
-
# run each expectation
|
16
|
-
expected_errors.each do |pair|
|
17
|
-
it "#{pair[:file]}.qdf should error with #{pair[:error]}" do
|
18
|
-
Quandl::Logger.should_receive(:error).at_least(:once).with(pair[:error])
|
19
|
-
Quandl::Format::Dataset.load( fixtures_data[pair[:file]] )
|
5
|
+
|
6
|
+
def self.it_should_expect_error(file, error)
|
7
|
+
it "#{file}.qdf should error with #{error}" do
|
8
|
+
Quandl::Logger.should_receive(:error).at_least(:once).with(error)
|
9
|
+
Quandl::Format::Dataset.load( fixtures_data[file] )
|
20
10
|
end
|
21
11
|
end
|
22
12
|
|
13
|
+
it_should_expect_error 'invalid_data', /Date/
|
14
|
+
it_should_expect_error 'unknown_attribute', /this_attribute_does_not_exist/
|
15
|
+
it_should_expect_error 'mismatched_columns', /Expected 4 but found 5/
|
16
|
+
it_should_expect_error 'mismatched_rows', /Expected 3 but found 4/
|
17
|
+
it_should_expect_error 'invalid_yaml', /could not find expected ':'/
|
18
|
+
it_should_expect_error 'missing_dashes', /Attribute parse error at line 28 column 1/
|
19
|
+
it_should_expect_error 'missing_dashes', /Did you forget to delimit the meta data section/
|
20
|
+
|
23
21
|
end
|
@@ -18,6 +18,22 @@ describe Quandl::Format::Dataset do
|
|
18
18
|
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
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
context "metadata_only.qdf" do
|
23
|
+
let(:data){ Quandl::Format::Dataset.load( fixtures_data['metadata_only'] ) }
|
24
|
+
|
25
|
+
it{ should be_a Array }
|
26
|
+
its(:count){ should eq 3 }
|
27
|
+
|
28
|
+
describe "#first" do
|
29
|
+
subject{ data.first }
|
30
|
+
its(:code){ should eq 'BLAKE_TEST_1' }
|
31
|
+
its(:name){ should eq 'A new title' }
|
32
|
+
its(:description){ should eq 'The description Date, Open, High'}
|
33
|
+
its(:column_names){ should eq [] }
|
34
|
+
its(:data){ should eq [] }
|
35
|
+
end
|
36
|
+
end
|
21
37
|
|
22
38
|
context "annual.qdf" do
|
23
39
|
let(:data){ Quandl::Format::Dataset.load( fixtures_data['annual'] ) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
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-01-
|
11
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- spec/fixtures/data/illegal_colon.qdf
|
155
155
|
- spec/fixtures/data/invalid_data.qdf
|
156
156
|
- spec/fixtures/data/invalid_yaml.qdf
|
157
|
+
- spec/fixtures/data/metadata_only.qdf
|
157
158
|
- spec/fixtures/data/mismatched_columns.qdf
|
158
159
|
- spec/fixtures/data/mismatched_rows.qdf
|
159
160
|
- spec/fixtures/data/missing_dashes.qdf
|
@@ -200,6 +201,7 @@ test_files:
|
|
200
201
|
- spec/fixtures/data/illegal_colon.qdf
|
201
202
|
- spec/fixtures/data/invalid_data.qdf
|
202
203
|
- spec/fixtures/data/invalid_yaml.qdf
|
204
|
+
- spec/fixtures/data/metadata_only.qdf
|
203
205
|
- spec/fixtures/data/mismatched_columns.qdf
|
204
206
|
- spec/fixtures/data/mismatched_rows.qdf
|
205
207
|
- spec/fixtures/data/missing_dashes.qdf
|