quandl_data 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84a332382463958b1b2a0f6b9ce607ef8d8f8ebf
4
- data.tar.gz: 3f0374304cf34fab12e71ff95c5e372e23778cbd
3
+ metadata.gz: 608923f1b4a950abdc530500b439cdfa8c9f649d
4
+ data.tar.gz: fb7e5a87b3f44e967fa9045b01d50af34849666b
5
5
  SHA512:
6
- metadata.gz: c9f922fc3c65f22d813d499470852900ac8929e801db026004b11221945f3e0a67b07547e83fd5279473bffc67be4a6a475e28cf15e209ecce741177c7fc27b2
7
- data.tar.gz: 1018ac95054327e24aa00a1a81e00599a4b58e950cad443a196d7231825d52cc0d8e935f70a0c2e402996098a4665f3797e1129f113424f1ef5707c68cdae18a
6
+ metadata.gz: ab5117d484c093a6b3a84b32a41d8fdb01f08bf5eaff79980ad37c66042668e55dd253feeb9be5c2d5ac49cedc3009eaa3be9186972938c849b6f4b9356920d2
7
+ data.tar.gz: 36efa5f340d054a48f2673c9e11b0ad12e2736d33f84ea83ef78a15f6774d5f620413b44447cbdb93aa45eaa9232383f505e08f20f551cf43abb582357843d61
@@ -31,7 +31,7 @@ module Operations
31
31
 
32
32
  def to_csv
33
33
  return data_array.collect(&:to_csv).join if data_array?
34
- return pristine_data.collect(&:to_csv).join if pristine_data.kind_of?(Array)
34
+ return pristine_data.collect(&:to_csv).join if pristine_data.respond_to?(:collect)
35
35
  return pristine_data if pristine_data.kind_of?(String)
36
36
  return ''
37
37
  end
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Data
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
@@ -3,50 +3,59 @@ require 'spec_helper'
3
3
 
4
4
  describe Quandl::Data::Table do
5
5
  subject { Quandl::Data::Random.table( nils: false, rows: 4, columns: 4 ) }
6
-
7
- its(:to_csv){ should be_a String }
6
+
8
7
  its(:to_h){ should be_a Hash }
9
8
  its(:count){ should eq 4 }
10
-
9
+
11
10
  it "should parse csv" do
12
11
  Quandl::Data::Table.new(subject.to_csv).count.should eq 4
13
12
  end
14
13
 
15
- it "should output csv that is consistent with subject" do
16
- data = CSV.parse( subject.to_csv ).collect{|r| r.collect{|v| v.to_f } }
17
- data.should eq subject
18
- end
19
-
20
14
  it "should convert to julian dates" do
21
15
  data = subject.to_jd
22
16
  data[0][0].should be_a Integer
23
17
  end
24
-
18
+
25
19
  it "should convert to dates" do
26
20
  julian_data = subject.to_jd
27
21
  julian_data.first.first.should be_a Integer
28
22
  date_data = julian_data.to_date
29
23
  date_data.first.first.should be_a Date
30
24
  end
31
-
25
+
32
26
  it "should transform the data" do
33
27
  value = subject.first[1]
34
28
  subject.transform(:rdiff).first[1].should_not eq value
35
29
  end
36
-
30
+
37
31
  it "should transform the data to rdiff from" do
38
32
  data = Quandl::Data::Table.new([[1,3,5],[4,5,4],[5,15,20]])
39
33
  data.transform(:rdiff_from).should eq [[1,4,3],[4,2,4],[5,0,0]]
40
34
  end
41
-
35
+
42
36
  it "should collapse the data" do
43
37
  subject.collapse(:monthly).count.should eq 1
44
38
  end
45
-
39
+
46
40
  it "should limit the data" do
47
41
  subject.limit(2).count.should eq 2
48
42
  end
49
43
 
44
+ describe "to_csv" do
45
+
46
+ its(:to_csv){ should be_a String }
47
+
48
+ it "should output csv that is consistent with subject" do
49
+ data = CSV.parse( subject.to_csv ).collect{|r| r.collect{|v| v.to_f } }
50
+ data.should eq subject
51
+ end
52
+
53
+ it "should output csv when initialized with a Data::Table" do
54
+ Quandl::Data::Table.new( subject ).to_csv.should eq subject.to_csv
55
+ end
56
+
57
+ end
58
+
50
59
  describe "to_date" do
51
60
 
52
61
  it "should convert julian dates to dates" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-23 00:00:00.000000000 Z
11
+ date: 2013-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake