quandl_client 2.4.4 → 2.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/UPGRADE.md +6 -0
- data/lib/quandl/client/models/dataset.rb +14 -1
- data/lib/quandl/client/models/user.rb +1 -0
- data/lib/quandl/client/version.rb +1 -1
- data/spec/factories/dataset.rb +1 -1
- data/spec/lib/quandl/client/dataset/data_spec.rb +5 -1
- data/spec/lib/quandl/client/dataset/persistence_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7125726d7cceeb967eeea4dee62a6defd9609ac3
|
4
|
+
data.tar.gz: 019a336addadb9238b9290054730b926cf7ba1ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 287b3674ebd754821827d74d044b5362af1af32eb68967c980fb25d6638227f21183dd7b6007de54d16569025566abb6c8ec75e163a221ab325cb68f5ceaba4f
|
7
|
+
data.tar.gz: 670806360ff1824f7c9963daa6d1fdde4a24e3599e3baeac17d3a4d1a7aba980813af601236b7b6cf41a16be19c47b0d79ba437238e312987cf56d03307fcd40
|
data/UPGRADE.md
CHANGED
@@ -11,6 +11,8 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def find(value)
|
14
|
+
# ensure slashes are forward facing
|
15
|
+
value = value.gsub("\\","/") if value.is_a?(String)
|
14
16
|
# short-circuit if value is illegal
|
15
17
|
return nil unless value.is_a?(Integer) || value.to_s =~ %r{^#{Quandl::Pattern.full_code}$}
|
16
18
|
super(value)
|
@@ -37,6 +39,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
37
39
|
|
38
40
|
validates :code, presence: true, format: { with: Quandl::Pattern.code, message: "is invalid. Expected format: #{Quandl::Pattern.code.to_example}" }
|
39
41
|
validates :display_url, allow_blank: true, url: true
|
42
|
+
validate :data_columns_should_not_exceed_column_names!
|
40
43
|
|
41
44
|
##############
|
42
45
|
# PROPERTIES #
|
@@ -113,13 +116,23 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
113
116
|
|
114
117
|
protected
|
115
118
|
|
119
|
+
def data_columns_should_not_exceed_column_names!
|
120
|
+
if dataset_data.data? && column_names.present? && data.first.count != column_names.count
|
121
|
+
self.errors.add( :data, "You may not change the number of columns in a dataset!" )
|
122
|
+
return false
|
123
|
+
end
|
124
|
+
true
|
125
|
+
end
|
126
|
+
|
116
127
|
def save_dataset_data
|
117
|
-
return if !saved? && id.blank?
|
128
|
+
return if (!saved? && id.blank?)
|
129
|
+
return if !dataset_data.data?
|
118
130
|
|
119
131
|
dataset_data.id = id
|
120
132
|
dataset_data.save
|
121
133
|
# update dataset's attributes with dataset_data's attributes
|
122
134
|
attributes.each{|k,v| attributes[k] = dataset_data.attributes[k] if dataset_data.attributes.has_key?(k) }
|
135
|
+
@metadata[:status] = dataset_data.status
|
123
136
|
end
|
124
137
|
|
125
138
|
def enforce_required_formats
|
data/spec/factories/dataset.rb
CHANGED
@@ -5,7 +5,7 @@ FactoryGirl.define do
|
|
5
5
|
sequence(:code) { |n| "QUANDL_CLIENT_#{(Time.now.to_f * 1000).to_i}_#{n}" }
|
6
6
|
name "Quandl Client Dataset"
|
7
7
|
description "Quandl Client Dataset Spec"
|
8
|
-
|
8
|
+
# column_names ['Date', "Column 1", "Column 2"]
|
9
9
|
end
|
10
10
|
|
11
11
|
end
|
@@ -4,8 +4,11 @@ require 'spec_helper'
|
|
4
4
|
describe Quandl::Client::Dataset::Data do
|
5
5
|
|
6
6
|
let(:dataset){
|
7
|
-
create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", data: Quandl::Fabricate::Data.rand( rows: 10, columns: 4 ) )
|
7
|
+
create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", data: Quandl::Fabricate::Data.rand( rows: 10, columns: 4 ), column_names: ["Date", "C1", 'c2', 'c3', 'c4'] )
|
8
8
|
}
|
9
|
+
subject{ dataset }
|
10
|
+
|
11
|
+
its(:valid?){ should be_true }
|
9
12
|
|
10
13
|
describe ".with_id('NSE/OIL')" do
|
11
14
|
let(:id){ Dataset.find("NSE/OIL").id }
|
@@ -27,6 +30,7 @@ describe Quandl::Client::Dataset::Data do
|
|
27
30
|
|
28
31
|
describe "#data" do
|
29
32
|
subject{ Dataset.find( dataset.id ).data }
|
33
|
+
|
30
34
|
its(:count){ should eq 10 }
|
31
35
|
its(:to_h){ should be_a Hash }
|
32
36
|
end
|
@@ -41,9 +41,9 @@ describe Dataset do
|
|
41
41
|
|
42
42
|
let(:dataset){ create(:dataset, source_code: "QUANDL_CLIENT_TEST_SOURCE", data: Quandl::Fabricate::Data.rand(rows: 20, columns: 2, nils: false) ) }
|
43
43
|
subject{ dataset }
|
44
|
-
|
44
|
+
|
45
45
|
its(:saved?){ should be_true }
|
46
|
-
its(:status){ should eq
|
46
|
+
its(:status){ should eq 200 }
|
47
47
|
|
48
48
|
end
|
49
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Hilscher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|