quandl_cassinatra 0.1.11 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/quandl/cassinatra/model/dataset/searchable.rb +15 -14
- data/lib/quandl/cassinatra/version.rb +1 -1
- data/quandl_cassinatra.gemspec +6 -3
- data/spec/quandl/cassinatra/dataset/persistence_spec.rb +30 -0
- data/spec/quandl/cassinatra/dataset/searchable_spec.rb +93 -0
- data/spec/quandl/cassinatra/multiset_spec.rb +30 -25
- metadata +77 -19
- checksums.yaml +0 -7
- data/spec/quandl/cassinatra/dataset_spec.rb +0 -66
@@ -9,14 +9,6 @@ module Searchable
|
|
9
9
|
|
10
10
|
module ClassMethods
|
11
11
|
|
12
|
-
def valid_transformation?(type)
|
13
|
-
Quandl::Operation::Transform.valid_transformation?(type)
|
14
|
-
end
|
15
|
-
|
16
|
-
def valid_transformations
|
17
|
-
Quandl::Operation::Transform.valid_transformations
|
18
|
-
end
|
19
|
-
|
20
12
|
def search_scopes
|
21
13
|
@search_scopes ||+ search_scope.scopes.keys
|
22
14
|
end
|
@@ -49,11 +41,11 @@ module Searchable
|
|
49
41
|
search_scope :trim_start, ->(date) { where( trim_start: format_trim_date(date, :start)) }
|
50
42
|
search_scope :trim_end, ->(date) { where( trim_end: format_trim_date(date, :end)) }
|
51
43
|
search_scope :with_id, ->(value) { where( id: value.to_i )}
|
52
|
-
search_scope :transform, ->(value) { where( transform: value.to_sym ) if
|
44
|
+
search_scope :transform, ->(value) { where( transform: value.to_sym ) if Quandl::Operation::Transform.valid_transformation?( value.try(:to_sym) ) }
|
53
45
|
|
54
|
-
search_scope :collapse, ->(
|
46
|
+
search_scope :collapse, ->(value){
|
55
47
|
# set collapse
|
56
|
-
where( collapse:
|
48
|
+
where( collapse: value ) if Quandl::Operation::Collapse.valid_collapse?( value.try(:to_sym) )
|
57
49
|
# reset trims to force them to edge of frequency
|
58
50
|
trim_start(trim_start) if trim_start
|
59
51
|
trim_end(trim_end) if trim_end
|
@@ -61,9 +53,7 @@ module Searchable
|
|
61
53
|
|
62
54
|
search_helper :format_trim_date, ->( date, start_or_end ){
|
63
55
|
# parse
|
64
|
-
date =
|
65
|
-
date = Date.jd(date) if date.is_a?(Integer)
|
66
|
-
date = Date.parse(date) if date.is_a?(String) && date =~ /^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/
|
56
|
+
date = parse_date(date)
|
67
57
|
# format
|
68
58
|
if date.is_a?(Date)
|
69
59
|
date = date.send("#{start_or_end}_of_frequency", collapse) if collapse.present?
|
@@ -73,6 +63,17 @@ module Searchable
|
|
73
63
|
end
|
74
64
|
}
|
75
65
|
|
66
|
+
search_helper :parse_date, ->( date ){
|
67
|
+
begin
|
68
|
+
date = Date.jd(date.to_i) if date.kind_of?(String) && date.numeric?
|
69
|
+
date = Date.jd(date) if date.is_a?(Integer)
|
70
|
+
date = Date.parse(date) if date.is_a?(String) && date =~ /^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/
|
71
|
+
date
|
72
|
+
rescue
|
73
|
+
nil
|
74
|
+
end
|
75
|
+
}
|
76
|
+
|
76
77
|
search_helper :find, ->(id){
|
77
78
|
begin
|
78
79
|
t1 = Time.now
|
data/quandl_cassinatra.gemspec
CHANGED
@@ -24,10 +24,13 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_development_dependency "pry"
|
25
25
|
|
26
26
|
s.add_runtime_dependency "activesupport", ">= 3.0.0"
|
27
|
-
s.add_runtime_dependency "her", "
|
27
|
+
s.add_runtime_dependency "her", "0.6.7"
|
28
28
|
s.add_runtime_dependency "yajl-ruby", "~> 1.1.0"
|
29
29
|
s.add_runtime_dependency 'json', '~> 1.7.7'
|
30
30
|
|
31
|
-
s.add_runtime_dependency "
|
32
|
-
s.add_runtime_dependency "
|
31
|
+
s.add_runtime_dependency "scope_composer", "~> 0.1"
|
32
|
+
s.add_runtime_dependency "quandl_logger", "~> 0.1"
|
33
|
+
s.add_runtime_dependency "quandl_operation", "~> 0.1"
|
34
|
+
s.add_runtime_dependency "quandl_data", "~> 0.1"
|
35
|
+
|
33
36
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Dataset do
|
5
|
+
subject { Dataset.new }
|
6
|
+
|
7
|
+
it { should respond_to :columns_count }
|
8
|
+
it { should respond_to :data }
|
9
|
+
it { should respond_to :data_table }
|
10
|
+
|
11
|
+
context "create" do
|
12
|
+
|
13
|
+
subject{ build(:dataset) }
|
14
|
+
|
15
|
+
it "should have data" do
|
16
|
+
subject.data_table.count.should eq 730
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have four columns" do
|
20
|
+
subject.data_table[0].count.should eq 4
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should create the dataset" do
|
24
|
+
subject.save
|
25
|
+
Dataset.find(subject.id).data.count.should eq 730
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Dataset do
|
5
|
+
context "searchable" do
|
6
|
+
|
7
|
+
describe "collapse" do
|
8
|
+
|
9
|
+
context "given an invalid collapse" do
|
10
|
+
it "should ignore number" do
|
11
|
+
Dataset.collapse(123).attributes[:collapse].should be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should ignore string" do
|
15
|
+
Dataset.collapse("invalid").attributes[:collapse].should be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should ignore symbol" do
|
19
|
+
Dataset.collapse(:invalid).attributes[:collapse].should be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "given valid collapse" do
|
25
|
+
it "should set daily" do
|
26
|
+
Dataset.collapse(:daily).attributes[:collapse].should eq :daily
|
27
|
+
end
|
28
|
+
it "should set weekly" do
|
29
|
+
Dataset.collapse(:weekly).attributes[:collapse].should eq :weekly
|
30
|
+
end
|
31
|
+
it "should set monthly" do
|
32
|
+
Dataset.collapse(:monthly).attributes[:collapse].should eq :monthly
|
33
|
+
end
|
34
|
+
it "should set quarterly" do
|
35
|
+
Dataset.collapse(:quarterly).attributes[:collapse].should eq :quarterly
|
36
|
+
end
|
37
|
+
it "should set annual" do
|
38
|
+
Dataset.collapse(:annual).attributes[:collapse].should eq :annual
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "trim_start" do
|
45
|
+
|
46
|
+
context "given an invalid date" do
|
47
|
+
|
48
|
+
it "should reject string" do
|
49
|
+
Dataset.trim_start('0000-00-00').attributes[:trim_start].should eq nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should reject invalid date" do
|
53
|
+
Dataset.trim_start("").attributes[:trim_start].should eq nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should reject invalid date" do
|
57
|
+
Dataset.trim_start("asdf").attributes[:trim_start].should eq nil
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should ignore invalid collapse" do
|
61
|
+
Dataset.collapse('yearly').trim_start(Date.today.to_s).attributes[:trim_start].should eq Date.today.jd
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context "given valid date" do
|
67
|
+
|
68
|
+
it "should accept date" do
|
69
|
+
date = Date.today
|
70
|
+
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should accept string date" do
|
74
|
+
date = Date.today.to_s
|
75
|
+
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should accept string julian date" do
|
79
|
+
date = Date.today.jd.to_s
|
80
|
+
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should accept integer" do
|
84
|
+
date = Date.today.jd
|
85
|
+
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
@@ -5,34 +5,39 @@ describe Multiset do
|
|
5
5
|
let(:d1){ create(:dataset, data_table: Quandl::Data::Random.table( rows: 10, columns: 4, nils: false ) ) }
|
6
6
|
let(:d2){ create(:dataset, data_table: Quandl::Data::Random.table( rows: 10, columns: 4, nils: false ) ) }
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
context "given ascending columns" do
|
9
|
+
|
10
|
+
it "should return the expected column_ids" do
|
11
|
+
[d1, d2]
|
12
|
+
sleep 0.2
|
13
|
+
m = Multiset.columns("#{d2.id.to_i}.1,#{d1.id.to_i}.1,#{d2.id.to_i}.3,#{d1.id.to_i}.2").to_dataset
|
14
|
+
m.column_ids.should eq [
|
15
|
+
Dataset.find(d2.id).column_ids[0],
|
16
|
+
Dataset.find(d1.id).column_ids[0],
|
17
|
+
Dataset.find(d2.id).column_ids[2],
|
18
|
+
Dataset.find(d1.id).column_ids[1],
|
19
|
+
]
|
20
|
+
end
|
13
21
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
22
|
+
it "should return the expected columns" do
|
23
|
+
[d1, d2]
|
24
|
+
sleep 1
|
25
|
+
m = Multiset.columns("#{d2.id.to_i}.1,#{d1.id.to_i}.1,#{d2.id.to_i}.3,#{d1.id.to_i}.2").to_dataset
|
26
|
+
m.data_table[0][1].should eq d2.data_table[0][1]
|
27
|
+
m.data_table[0][2].should eq d1.data_table[0][1]
|
28
|
+
m.data_table[0][3].should eq d2.data_table[0][3]
|
29
|
+
m.data_table[0][4].should eq d1.data_table[0][2]
|
30
|
+
end
|
19
31
|
|
20
|
-
it "should be in the right order" do
|
21
|
-
m = Multiset.columns("#{d2.id.to_i}.1,#{d1.id.to_i}.1,#{d2.id.to_i}.3,#{d1.id.to_i}.2").to_dataset
|
22
|
-
m.column_ids.should eq [
|
23
|
-
Dataset.find(d2.id).column_ids[0],
|
24
|
-
Dataset.find(d1.id).column_ids[0],
|
25
|
-
Dataset.find(d2.id).column_ids[2],
|
26
|
-
Dataset.find(d1.id).column_ids[1],
|
27
|
-
]
|
28
32
|
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
context "given descending columns" do
|
35
|
+
|
36
|
+
it "should return the expected columns" do
|
37
|
+
m = Multiset.columns("#{d1.id.to_i}.2,#{d1.id.to_i}.1").to_dataset
|
38
|
+
m.data_table[0][1].should_not eq m.data_table[0][2]
|
39
|
+
end
|
40
|
+
|
36
41
|
end
|
37
|
-
|
42
|
+
|
38
43
|
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_cassinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Blake Hilscher
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rspec
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: factory_girl
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: fivemat
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: pry
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - '>='
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - '>='
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: activesupport
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - '>='
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :runtime
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - '>='
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -97,20 +110,23 @@ dependencies:
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: her
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - '='
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: 0.6.7
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
|
-
- -
|
123
|
+
- - '='
|
109
124
|
- !ruby/object:Gem::Version
|
110
125
|
version: 0.6.7
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
127
|
name: yajl-ruby
|
113
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
114
130
|
requirements:
|
115
131
|
- - ~>
|
116
132
|
- !ruby/object:Gem::Version
|
@@ -118,6 +134,7 @@ dependencies:
|
|
118
134
|
type: :runtime
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
121
138
|
requirements:
|
122
139
|
- - ~>
|
123
140
|
- !ruby/object:Gem::Version
|
@@ -125,6 +142,7 @@ dependencies:
|
|
125
142
|
- !ruby/object:Gem::Dependency
|
126
143
|
name: json
|
127
144
|
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
128
146
|
requirements:
|
129
147
|
- - ~>
|
130
148
|
- !ruby/object:Gem::Version
|
@@ -132,38 +150,75 @@ dependencies:
|
|
132
150
|
type: :runtime
|
133
151
|
prerelease: false
|
134
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
135
154
|
requirements:
|
136
155
|
- - ~>
|
137
156
|
- !ruby/object:Gem::Version
|
138
157
|
version: 1.7.7
|
139
158
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
159
|
+
name: scope_composer
|
141
160
|
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
142
162
|
requirements:
|
143
|
-
- -
|
163
|
+
- - ~>
|
144
164
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.1
|
165
|
+
version: '0.1'
|
146
166
|
type: :runtime
|
147
167
|
prerelease: false
|
148
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
149
170
|
requirements:
|
150
|
-
- -
|
171
|
+
- - ~>
|
151
172
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.1
|
173
|
+
version: '0.1'
|
153
174
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
175
|
+
name: quandl_logger
|
155
176
|
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
156
178
|
requirements:
|
157
|
-
- -
|
179
|
+
- - ~>
|
158
180
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.1
|
181
|
+
version: '0.1'
|
160
182
|
type: :runtime
|
161
183
|
prerelease: false
|
162
184
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
163
186
|
requirements:
|
164
|
-
- -
|
187
|
+
- - ~>
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0.1'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: quandl_operation
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ~>
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0.1'
|
198
|
+
type: :runtime
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ~>
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0.1'
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: quandl_data
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ~>
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0.1'
|
214
|
+
type: :runtime
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ~>
|
165
220
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.1
|
221
|
+
version: '0.1'
|
167
222
|
description: An orm for the cassinatra rest interface.
|
168
223
|
email:
|
169
224
|
- blake@hilscher.ca
|
@@ -198,35 +253,38 @@ files:
|
|
198
253
|
- lib/quandl/her/patch.rb
|
199
254
|
- quandl_cassinatra.gemspec
|
200
255
|
- spec/factories/dataset.rb
|
201
|
-
- spec/quandl/cassinatra/
|
256
|
+
- spec/quandl/cassinatra/dataset/persistence_spec.rb
|
257
|
+
- spec/quandl/cassinatra/dataset/searchable_spec.rb
|
202
258
|
- spec/quandl/cassinatra/multiset_spec.rb
|
203
259
|
- spec/spec_helper.rb
|
204
260
|
homepage: http://blake.hilscher.ca/
|
205
261
|
licenses:
|
206
262
|
- MIT
|
207
|
-
metadata: {}
|
208
263
|
post_install_message:
|
209
264
|
rdoc_options: []
|
210
265
|
require_paths:
|
211
266
|
- lib
|
212
267
|
required_ruby_version: !ruby/object:Gem::Requirement
|
268
|
+
none: false
|
213
269
|
requirements:
|
214
270
|
- - '>='
|
215
271
|
- !ruby/object:Gem::Version
|
216
272
|
version: '0'
|
217
273
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
274
|
+
none: false
|
218
275
|
requirements:
|
219
276
|
- - '>='
|
220
277
|
- !ruby/object:Gem::Version
|
221
278
|
version: '0'
|
222
279
|
requirements: []
|
223
280
|
rubyforge_project:
|
224
|
-
rubygems_version:
|
281
|
+
rubygems_version: 1.8.25
|
225
282
|
signing_key:
|
226
|
-
specification_version:
|
283
|
+
specification_version: 3
|
227
284
|
summary: Cassinatra rest orm.
|
228
285
|
test_files:
|
229
286
|
- spec/factories/dataset.rb
|
230
|
-
- spec/quandl/cassinatra/
|
287
|
+
- spec/quandl/cassinatra/dataset/persistence_spec.rb
|
288
|
+
- spec/quandl/cassinatra/dataset/searchable_spec.rb
|
231
289
|
- spec/quandl/cassinatra/multiset_spec.rb
|
232
290
|
- spec/spec_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 321171d3425874e1162260fa7d05c1e596f3ee4a
|
4
|
-
data.tar.gz: 46359ab27a5299eaa1cf10bbb1c56a45b76f031b
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: f8b2d1bcf69667cb2ac29cead3f0e15b52156518c7dfd22f60ec96a8354ec43a7c3f3f3065f4e14d0772d65638154e8e3b6b00a9868b099587a3be02d3a35c01
|
7
|
-
data.tar.gz: 67d46970e491418b852204319090e30308f8110b4c947737183b868f19bab286f307763f2945e584f6d325c4beee758588584e8fb197871c0c48a2d2bcdd4242
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Dataset do
|
5
|
-
subject { Dataset.new }
|
6
|
-
|
7
|
-
it { should respond_to :columns_count }
|
8
|
-
it { should respond_to :data }
|
9
|
-
it { should respond_to :data_table }
|
10
|
-
|
11
|
-
context "create" do
|
12
|
-
|
13
|
-
subject{ build(:dataset) }
|
14
|
-
|
15
|
-
it "should have data" do
|
16
|
-
subject.data_table.count.should eq 730
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should have four columns" do
|
20
|
-
subject.data_table[0].count.should eq 4
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should create the dataset" do
|
24
|
-
subject.save
|
25
|
-
Dataset.find(subject.id).data.count.should eq 730
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
context "searchable" do
|
31
|
-
|
32
|
-
describe "trim_start" do
|
33
|
-
|
34
|
-
it "should accept date" do
|
35
|
-
date = Date.today
|
36
|
-
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should accept string date" do
|
40
|
-
date = Date.today.to_s
|
41
|
-
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should accept string julian date" do
|
45
|
-
date = Date.today.jd.to_s
|
46
|
-
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should accept integer" do
|
50
|
-
date = Date.today.jd
|
51
|
-
Dataset.trim_start(date).attributes[:trim_start].should eq Date.today.jd
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should reject invalid date" do
|
55
|
-
Dataset.trim_start("").attributes[:trim_start].should eq nil
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should reject invalid date" do
|
59
|
-
Dataset.trim_start("asdf").attributes[:trim_start].should eq nil
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|