quandl_cassinatra 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/UPGRADE.md +9 -0
- data/lib/quandl/cassinatra/model/dataset.rb +10 -1
- data/lib/quandl/cassinatra/version.rb +1 -1
- data/spec/factories/dataset.rb +1 -1
- data/spec/quandl/cassinatra/dataset/delete_spec.rb +32 -0
- data/spec/quandl/cassinatra/multiset_spec.rb +3 -4
- data/spec/spec_helper.rb +4 -6
- metadata +4 -2
data/README.md
CHANGED
@@ -43,7 +43,7 @@ require 'quandl/cassinatra'
|
|
43
43
|
|
44
44
|
d = Quandl::Cassinatra::Model::Dataset.new
|
45
45
|
d.id = 5893853
|
46
|
-
d.data = Quandl::Data::
|
46
|
+
d.data = Quandl::Fabricate::Data::Table.rand(rows: 10, columns: 4, nils: false).to_csv
|
47
47
|
d.save
|
48
48
|
|
49
49
|
d = Quandl::Cassinatra::Model::Dataset.find(5893853)
|
data/UPGRADE.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.2.1
|
2
|
+
|
3
|
+
* add Dataset#delete_rows(*dates)
|
4
|
+
* add Dataset#delete_data
|
5
|
+
* replace Data::Random with Quandl::Fabricate
|
6
|
+
|
7
|
+
|
1
8
|
## 0.2.0
|
2
9
|
|
3
10
|
* add support column Dataset#columns, #column_names, #column_units
|
@@ -7,11 +14,13 @@
|
|
7
14
|
|
8
15
|
* parse_json responds with more informative error
|
9
16
|
|
17
|
+
|
10
18
|
## 0.1.15
|
11
19
|
|
12
20
|
* add status, blank?, saved?, exists?
|
13
21
|
* fail gracefully when parse_json receives nil body due to api throwing 500 error
|
14
22
|
|
23
|
+
|
15
24
|
## 0.1.14
|
16
25
|
|
17
26
|
* add Dataset#trim_start, Dataset#trim_end
|
@@ -27,7 +27,7 @@ class Dataset
|
|
27
27
|
def data_table=(value)
|
28
28
|
self.data = Data::Table.new(value).to_csv
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def dataset_attribute(*args)
|
32
32
|
return @dataset_attribute if @dataset_attribute
|
33
33
|
# options
|
@@ -37,6 +37,15 @@ class Dataset
|
|
37
37
|
@dataset_attribute = DatasetAttribute.where( count: count ).find(id)
|
38
38
|
end
|
39
39
|
|
40
|
+
def delete_data
|
41
|
+
Dataset.delete("/datasets/#{id.to_i}/data").status
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete_rows(*dates)
|
45
|
+
query = { dates: Array(dates).flatten }.to_query
|
46
|
+
Dataset.delete("/datasets/#{id.to_i}/data/rows?#{query}").status
|
47
|
+
end
|
48
|
+
|
40
49
|
end
|
41
50
|
end
|
42
51
|
end
|
data/spec/factories/dataset.rb
CHANGED
@@ -2,7 +2,7 @@ FactoryGirl.define do
|
|
2
2
|
|
3
3
|
factory :dataset do
|
4
4
|
sequence(:id) { |n| (Time.now.to_f * 1000).to_i + n }
|
5
|
-
data_table{ Quandl::Data::
|
5
|
+
data_table{ Quandl::Fabricate::Data::Table.rand( rows: 730, columns: 3, nils: false ) }
|
6
6
|
end
|
7
7
|
|
8
8
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Dataset do
|
5
|
+
|
6
|
+
let(:dataset){ create(:dataset) }
|
7
|
+
subject{ Dataset.find(dataset.id) }
|
8
|
+
|
9
|
+
its(:data){ should be_present }
|
10
|
+
|
11
|
+
describe "#delete_data" do
|
12
|
+
before(:each){ subject.delete_data }
|
13
|
+
it "data should be blank" do
|
14
|
+
Dataset.find(dataset.id).data.should be_blank
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#delete_rows" do
|
19
|
+
|
20
|
+
let(:dates_slice){ dataset.data_table.to_h.keys[10..19] }
|
21
|
+
|
22
|
+
before(:each){ subject.delete_rows( dates_slice ) }
|
23
|
+
|
24
|
+
its(:status){ should eq 200 }
|
25
|
+
|
26
|
+
it "data count should be 720" do
|
27
|
+
Dataset.find( dataset.id ).data_table.count.should eq 720
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -2,14 +2,13 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Multiset do
|
5
|
-
let(:d1){ create(:dataset, data_table: Quandl::Data::
|
6
|
-
let(:d2){ create(:dataset, data_table: Quandl::Data::
|
5
|
+
let(:d1){ create(:dataset, data_table: Quandl::Fabricate::Data::Table.rand( rows: 10, columns: 4, nils: false ) ) }
|
6
|
+
let(:d2){ create(:dataset, data_table: Quandl::Fabricate::Data::Table.rand( rows: 10, columns: 4, nils: false ) ) }
|
7
7
|
|
8
8
|
context "given ascending columns" do
|
9
9
|
|
10
10
|
it "should return the expected column_ids" do
|
11
11
|
[d1, d2]
|
12
|
-
sleep 0.2
|
13
12
|
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
13
|
m.column_ids.should eq [
|
15
14
|
Dataset.find(d2.id).column_ids[0],
|
@@ -18,7 +17,7 @@ describe Multiset do
|
|
18
17
|
Dataset.find(d1.id).column_ids[1],
|
19
18
|
]
|
20
19
|
end
|
21
|
-
|
20
|
+
|
22
21
|
it "should return the expected columns" do
|
23
22
|
[d1, d2]
|
24
23
|
sleep 1
|
data/spec/spec_helper.rb
CHANGED
@@ -11,10 +11,8 @@ RSpec.configure do |config|
|
|
11
11
|
config.include FactoryGirl::Syntax::Methods
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
# LOAD GEM
|
16
|
-
|
14
|
+
require "quandl/fabricate"
|
17
15
|
require "quandl/cassinatra"
|
18
|
-
Quandl::Cassinatra.use 'http://192.168.33.10:8983/wikiposit_cassandra/'
|
19
|
-
|
20
|
-
include Quandl::Cassinatra
|
16
|
+
# Quandl::Cassinatra.use 'http://192.168.33.10:8983/wikiposit_cassandra/'
|
17
|
+
Quandl::Cassinatra.use 'http://localhost:9292/'
|
18
|
+
include Quandl::Cassinatra
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_cassinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
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-10-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -253,6 +253,7 @@ files:
|
|
253
253
|
- lib/quandl/her/patch.rb
|
254
254
|
- quandl_cassinatra.gemspec
|
255
255
|
- spec/factories/dataset.rb
|
256
|
+
- spec/quandl/cassinatra/dataset/delete_spec.rb
|
256
257
|
- spec/quandl/cassinatra/dataset/persistence_spec.rb
|
257
258
|
- spec/quandl/cassinatra/dataset/searchable_spec.rb
|
258
259
|
- spec/quandl/cassinatra/dataset/trim_spec.rb
|
@@ -285,6 +286,7 @@ specification_version: 3
|
|
285
286
|
summary: Cassinatra rest orm.
|
286
287
|
test_files:
|
287
288
|
- spec/factories/dataset.rb
|
289
|
+
- spec/quandl/cassinatra/dataset/delete_spec.rb
|
288
290
|
- spec/quandl/cassinatra/dataset/persistence_spec.rb
|
289
291
|
- spec/quandl/cassinatra/dataset/searchable_spec.rb
|
290
292
|
- spec/quandl/cassinatra/dataset/trim_spec.rb
|