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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6a154e15469886cd35f5722374918456c299200
4
- data.tar.gz: f5b673bb2619677b9610bd0820feac55c1969bba
3
+ metadata.gz: 20078bc556c8155d90a29be038f3963b31167767
4
+ data.tar.gz: 3b13078bacc4f36a41cb841d7badb831d34738b7
5
5
  SHA512:
6
- metadata.gz: 4dd7857d5d4d3b62ef46e2fbd5951f9e4106c7e47b0b24ff20c19caf66e04b2cecae1a4c39ecbb6fa485badb23262e9b761616596047d38781b4efb0fdd0220d
7
- data.tar.gz: 2b3b289b1db9c084e4edf2b6d00e320c65c5ce4193e1cd7b286aa1fb6adeb6d5d6fb7a50c3006776783a4f7dd0215665a2463f2b8eb886f0f07d8f241b592a6e
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
@@ -0,0 +1,7 @@
1
+ module Quandl
2
+ module Error
3
+
4
+ class ColumnCountMismatch < StandardError; end
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Quandl
2
+ module Error
3
+
4
+ class UnknownAttribute < StandardError; end
5
+
6
+ end
7
+ end
@@ -59,8 +59,8 @@ module Attributes
59
59
  end
60
60
 
61
61
  def data=(rows)
62
- self.column_names = rows.shift unless rows.first.collect{|r| r.to_s.numeric? }.include?(true)
63
- @data = Quandl::Data.new(rows).to_date
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::Format::Errors::ColumnCountMismatch, m
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::Format::Errors::ColumnCountMismatch, m
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::Format::Errors::UnknownAttribute, m
117
+ raise Quandl::Error::UnknownAttribute, m
118
118
  end
119
119
 
120
120
 
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Format
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
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/format/errors'
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
 
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency "guard"
26
26
  s.add_development_dependency "guard-rspec"
27
27
 
28
+ s.add_runtime_dependency "quandl_babelfish", "~> 0.0"
28
29
  s.add_runtime_dependency "quandl_client", "~> 2.3"
29
30
 
30
31
  end
@@ -0,0 +1,10 @@
1
+ code: "ANNUAL_DATA"
2
+ name: "A new title"
3
+ description: "Annual Data"
4
+ private: false
5
+ -
6
+ Date,Open,High
7
+ 2013,1252.0,454.95
8
+ 2012,452.25,457.75
9
+ 2011,452.25,457.75
10
+ 2010,452.25,457.75
@@ -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.3
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
@@ -1,10 +0,0 @@
1
- module Quandl
2
- module Format
3
- module Errors
4
-
5
- class UnknownAttribute < StandardError; end
6
- class ColumnCountMismatch < StandardError; end
7
-
8
- end
9
- end
10
- end