quandl_operation 0.1.9 → 0.1.10

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.
data/UPGRADE.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.10
2
+
3
+ * Parse can handle incoming data formatted as a hash of time => [value,value,value]
4
+
1
5
  ## 0.1.9
2
6
 
3
7
  * write failing spec for cumul. make spec pass
@@ -10,12 +10,18 @@ class Parse
10
10
  def perform(data)
11
11
  return [] if data.blank?
12
12
  t1 = Time.now
13
+ data = hash(data)
13
14
  data = csv(data)
14
15
  data = unknown_date_format_to_julian(data)
15
16
  # data = sort(data)
16
17
  Quandl::Logger.debug "#{self.name}.perform (#{t1.elapsed.microseconds}ms)" if t1.elapsed.microseconds > 1
17
18
  data
18
19
  end
20
+
21
+ def hash(data)
22
+ data = data.collect{|k,v| [k] + v } if data.kind_of?(Hash)
23
+ data
24
+ end
19
25
 
20
26
  def csv(data)
21
27
  data = CSV.parse( data ) if data.is_a?(String)
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Operation
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
  end
5
5
  end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Quandl::Operation::Parse do
5
+ subject{ Quandl::Operation::Parse }
6
+ let(:csv_data){ "#{Date.today}, 1.0, 2.0" }
7
+ let(:hash_data){ { Date.today.to_s => [ 1.0, 2.0 ] } }
8
+ let(:array_data){ [[ Date.today.to_s, 1.0, 2.0 ]] }
9
+ let(:julian_data){ [[ Date.today.jd, 1.0, 2.0 ]] }
10
+
11
+ it "#hash outputs array" do
12
+ subject.hash( hash_data ).should eq array_data
13
+ end
14
+
15
+ it "#csv outputs array" do
16
+ subject.csv( csv_data ).should eq array_data
17
+ end
18
+
19
+ describe "#perform" do
20
+ it "should handle csv_data" do
21
+ subject.perform( csv_data ).should eq julian_data
22
+ end
23
+ it "should handle julian_data" do
24
+ subject.perform( julian_data ).should eq julian_data
25
+ end
26
+ it "should handle hash_data" do
27
+ subject.perform( hash_data ).should eq julian_data
28
+ end
29
+ it "should handle array_data" do
30
+ subject.perform( array_data ).should eq julian_data
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-24 00:00:00.000000000 Z
12
+ date: 2013-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -121,6 +121,7 @@ files:
121
121
  - quandl_operation.gemspec
122
122
  - spec/lib/quandl/operation/collapse_spec.rb
123
123
  - spec/lib/quandl/operation/date_spec.rb
124
+ - spec/lib/quandl/operation/parse_spec.rb
124
125
  - spec/lib/quandl/operation/transform_spec.rb
125
126
  - spec/spec_helper.rb
126
127
  homepage: http://blake.hilscher.ca/
@@ -151,5 +152,6 @@ summary: For altering data
151
152
  test_files:
152
153
  - spec/lib/quandl/operation/collapse_spec.rb
153
154
  - spec/lib/quandl/operation/date_spec.rb
155
+ - spec/lib/quandl/operation/parse_spec.rb
154
156
  - spec/lib/quandl/operation/transform_spec.rb
155
157
  - spec/spec_helper.rb