quandl_data 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/UPGRADE.md +5 -0
- data/lib/quandl/data/operations.rb +2 -0
- data/lib/quandl/data/version.rb +1 -1
- data/spec/lib/quandl/data_spec.rb +21 -5
- metadata +1 -1
data/UPGRADE.md
CHANGED
@@ -118,6 +118,7 @@ module Quandl::Data::Operations
|
|
118
118
|
self
|
119
119
|
end
|
120
120
|
def transform=(value)
|
121
|
+
return false unless Transform.valid?(value)
|
121
122
|
@transform = value
|
122
123
|
@data_array = Transform.perform( data_array, value )
|
123
124
|
end
|
@@ -128,6 +129,7 @@ module Quandl::Data::Operations
|
|
128
129
|
self
|
129
130
|
end
|
130
131
|
def collapse=(collapse)
|
132
|
+
return false unless Collapse.valid?(collapse)
|
131
133
|
@collapse = collapse
|
132
134
|
@frequency = collapse
|
133
135
|
@data_array = Collapse.perform( data_array, collapse )
|
data/lib/quandl/data/version.rb
CHANGED
@@ -2,11 +2,25 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Quandl::Data do
|
5
|
-
|
5
|
+
let(:data){ Quandl::Fabricate::Data.rand( nils: false, rows: 4, columns: 4 ) }
|
6
|
+
subject { data }
|
6
7
|
|
7
8
|
its(:to_h){ should be_a Hash }
|
8
9
|
its(:count){ should eq 4 }
|
10
|
+
|
11
|
+
describe "#collapse=" do
|
9
12
|
|
13
|
+
it "should collapse to monthly" do
|
14
|
+
subject.collapse(:monthly).count.should eq 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should reject invalid collapse" do
|
18
|
+
subject.collapse(:invalid)
|
19
|
+
subject.collapse.should_not eq :invalid
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
10
24
|
it "should parse csv" do
|
11
25
|
Quandl::Data.new(subject.to_csv).count.should eq 4
|
12
26
|
end
|
@@ -24,6 +38,12 @@ describe Quandl::Data do
|
|
24
38
|
end
|
25
39
|
|
26
40
|
describe "#transform" do
|
41
|
+
|
42
|
+
it "should reject invalid transform" do
|
43
|
+
subject.transform(:invalid)
|
44
|
+
subject.transform.should_not eq :invalid
|
45
|
+
end
|
46
|
+
|
27
47
|
it "should rdiff" do
|
28
48
|
value = subject.first[1]
|
29
49
|
subject.transform(:rdiff).first[1].should_not eq value
|
@@ -38,10 +58,6 @@ describe Quandl::Data do
|
|
38
58
|
end
|
39
59
|
end
|
40
60
|
|
41
|
-
it "should collapse the data" do
|
42
|
-
subject.collapse(:monthly).count.should eq 1
|
43
|
-
end
|
44
|
-
|
45
61
|
it "should limit the data" do
|
46
62
|
subject.limit(2).count.should eq 2
|
47
63
|
end
|