quandl_client 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,12 +44,14 @@ class Dataset
44
44
  ##############
45
45
  # PROPERTIES #
46
46
  ##############
47
+
48
+ attributes :source_code, :code, :name, :urlize_name,
49
+ :description, :updated_at, :frequency,
50
+ :from_date, :to_date, :column_names, :private, :type,
51
+ :display_url, :column_spec, :import_spec, :import_url,
52
+ :locations_attributes, :data
47
53
 
48
- attributes :data, :source_code, :code, :name, :urlize_name,
49
- :description, :updated_at, :frequency, :from_date,
50
- :to_date, :column_names, :private, :type, :display_url
51
-
52
- attributes :locations_attributes
54
+ before_save :ensure_data_is_csv
53
55
 
54
56
  alias_method :locations, :locations_attributes
55
57
  alias_method :locations=, :locations_attributes=
@@ -66,6 +68,12 @@ class Dataset
66
68
  @raw_data ||= (self.data || Dataset.find(full_code).data || [])
67
69
  end
68
70
 
71
+ protected
72
+
73
+ def ensure_data_is_csv
74
+ self.data = Quandl::Data::Table.new(data).to_csv
75
+ end
76
+
69
77
  end
70
78
 
71
79
  end
@@ -1,6 +1,6 @@
1
1
  module Quandl
2
2
  module Client
3
- VERSION = '0.1.7'
3
+ VERSION = '0.1.8'
4
4
  API_VERSION = 'v1'
5
5
 
6
6
  class << self
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Dataset do
5
+ context "when built" do
6
+ subject{ build(:dataset) }
7
+ its(:valid?){ should be_true }
8
+ end
9
+
10
+ context "when created" do
11
+ context "without token" do
12
+
13
+ before(:all){ Quandl::Client.token = '' }
14
+
15
+ let(:dataset){ create(:dataset) }
16
+ subject{ dataset }
17
+
18
+ its(:saved?){ should be_false }
19
+ its(:status){ should eq 401 }
20
+
21
+ end
22
+ context "with token" do
23
+
24
+ before(:all){ Quandl::Client.token = AUTH_TOKEN }
25
+
26
+ let(:source){ create(:source) }
27
+ let(:dataset){ create(:dataset, source_code: source.code ) }
28
+ subject{ dataset }
29
+
30
+ its(:saved?){ should be_true }
31
+ its(:status){ should eq 201 }
32
+
33
+ end
34
+ end
35
+
36
+ context "when updated" do
37
+ before(:all){ Quandl::Client.token = AUTH_TOKEN }
38
+
39
+ let(:source){ create(:source) }
40
+ let(:dataset){ create(:dataset, source_code: source.code, data: Quandl::Data::Random.table(rows: 20, columns: 2).to_csv ) }
41
+
42
+ it "should change data" do
43
+ # update the dataset
44
+ subject = Dataset.find(dataset.id)
45
+ new_row = [ subject.data_table[0][0], 1.0, 2.0]
46
+ subject.data = [ new_row ]
47
+ subject.save
48
+ # check the data
49
+ Dataset.find(dataset.id).data_table.sort_descending[0].should eq new_row
50
+ end
51
+
52
+ it "should change column_spec" do
53
+ subject = Dataset.find(dataset.id)
54
+ subject.column_spec = "[0,[\"Date \\n\",{}],[\"Column 1 \",{}],[\"Column 2 \",{}]]"
55
+ subject.save
56
+ Dataset.find(dataset.id).column_spec.should eq subject.column_spec
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Dataset do
5
+
6
+ before(:all){ Quandl::Client.token = AUTH_TOKEN }
7
+
8
+ let(:source){ create(:source) }
9
+ let(:dataset){ create(:dataset, source_code: source.code ) }
10
+
11
+ it "should find the dataset by id" do
12
+ Dataset.find(dataset.id).id.should eq dataset.id
13
+ end
14
+
15
+ it "should find the dataset by full code" do
16
+ Dataset.find(dataset.full_code).id.should eq dataset.id
17
+ end
18
+
19
+ it "should exclude_data" do
20
+ Dataset.exclude_data(true).find(dataset.id).data.should be_blank
21
+ end
22
+
23
+ end
@@ -2,76 +2,4 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Dataset do
5
-
6
- describe "#update" do
7
-
8
- before(:all){ Quandl::Client.token = AUTH_TOKEN }
9
-
10
- let(:source){ create(:source) }
11
- let(:dataset){ create(:dataset, source_code: source.code ) }
12
-
13
- it "should update with data" do
14
- rdataset = Dataset.find(dataset.id)
15
- data = Quandl::Data::Random.table(rows: 100, columns: 4)
16
- rdataset.data = data.to_csv
17
- rdataset.save
18
- Dataset.find(dataset.id).data_table.to_date.count.should eq data.to_date.count
19
- end
20
-
21
- end
22
-
23
- describe "#find" do
24
-
25
- before(:all){ Quandl::Client.token = AUTH_TOKEN }
26
-
27
- let(:source){ create(:source) }
28
- let(:dataset){ create(:dataset, source_code: source.code ) }
29
-
30
- it "should find the dataset by id" do
31
- Dataset.find(dataset.id).id.should eq dataset.id
32
- end
33
-
34
- it "should find the dataset by full code" do
35
- Dataset.find(dataset.full_code).id.should eq dataset.id
36
- end
37
-
38
- end
39
-
40
- describe "#new" do
41
-
42
- subject{ build(:dataset) }
43
-
44
- its(:valid?){ should be_true }
45
-
46
- end
47
-
48
- describe "#save" do
49
-
50
- context "without token" do
51
-
52
- before(:all){ Quandl::Client.token = '' }
53
-
54
- let(:dataset){ create(:dataset) }
55
- subject{ dataset }
56
-
57
- its(:saved?){ should be_false }
58
- its(:status){ should eq 401 }
59
-
60
- end
61
-
62
- context "with token" do
63
-
64
- before(:all){ Quandl::Client.token = AUTH_TOKEN }
65
-
66
- let(:source){ create(:source) }
67
- let(:dataset){ create(:dataset, source_code: source.code ) }
68
- subject{ dataset }
69
-
70
- its(:saved?){ should be_true }
71
- its(:status){ should eq 201 }
72
-
73
- end
74
-
75
- end
76
-
77
5
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
2
 
3
3
  require "rspec"
4
4
  require 'factory_girl'
5
+ require 'pry'
5
6
 
6
7
  factory_dir = File.join( File.dirname(__FILE__), 'factories/**/*.rb' )
7
8
  Dir.glob( factory_dir ).each{|f| require(f); puts f }
@@ -9,7 +10,7 @@ Dir.glob( factory_dir ).each{|f| require(f); puts f }
9
10
  require "quandl/client"
10
11
 
11
12
  include Quandl::Client
12
- Quandl::Client.use 'http://staging.quandl.com/api/'
13
+ Quandl::Client.use 'http://localhost:3000/api/'
13
14
  AUTH_TOKEN = ENV['QUANDL_AUTH_TOKEN']
14
15
 
15
16
  RSpec.configure do |config|
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
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-07-23 00:00:00.000000000 Z
12
+ date: 2013-08-01 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_rails
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,6 +110,7 @@ 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
@@ -104,6 +118,7 @@ dependencies:
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
@@ -111,6 +126,7 @@ dependencies:
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,6 +150,7 @@ 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
@@ -139,6 +158,7 @@ dependencies:
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: quandl_data
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
163
  - - '>='
144
164
  - !ruby/object:Gem::Version
@@ -146,6 +166,7 @@ dependencies:
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
@@ -153,6 +174,7 @@ dependencies:
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: scope_composer
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
179
  - - '>='
158
180
  - !ruby/object:Gem::Version
@@ -160,6 +182,7 @@ dependencies:
160
182
  type: :runtime
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
187
  - - '>='
165
188
  - !ruby/object:Gem::Version
@@ -197,38 +220,41 @@ files:
197
220
  - quandl_client.gemspec
198
221
  - spec/factories/dataset.rb
199
222
  - spec/factories/source.rb
200
- - spec/quandl/client/client_spec.rb
223
+ - spec/quandl/client/models/dataset/persistence_spec.rb
224
+ - spec/quandl/client/models/dataset/search_spec.rb
201
225
  - spec/quandl/client/models/dataset_spec.rb
202
226
  - spec/quandl/client/models/source_spec.rb
203
227
  - spec/spec_helper.rb
204
228
  homepage: http://blake.hilscher.ca/
205
229
  licenses:
206
230
  - MIT
207
- metadata: {}
208
231
  post_install_message:
209
232
  rdoc_options: []
210
233
  require_paths:
211
234
  - lib
212
235
  required_ruby_version: !ruby/object:Gem::Requirement
236
+ none: false
213
237
  requirements:
214
238
  - - '>='
215
239
  - !ruby/object:Gem::Version
216
240
  version: '0'
217
241
  required_rubygems_version: !ruby/object:Gem::Requirement
242
+ none: false
218
243
  requirements:
219
244
  - - '>='
220
245
  - !ruby/object:Gem::Version
221
246
  version: '0'
222
247
  requirements: []
223
248
  rubyforge_project:
224
- rubygems_version: 2.0.5
249
+ rubygems_version: 1.8.25
225
250
  signing_key:
226
- specification_version: 4
251
+ specification_version: 3
227
252
  summary: Client rest orm.
228
253
  test_files:
229
254
  - spec/factories/dataset.rb
230
255
  - spec/factories/source.rb
231
- - spec/quandl/client/client_spec.rb
256
+ - spec/quandl/client/models/dataset/persistence_spec.rb
257
+ - spec/quandl/client/models/dataset/search_spec.rb
232
258
  - spec/quandl/client/models/dataset_spec.rb
233
259
  - spec/quandl/client/models/source_spec.rb
234
260
  - spec/spec_helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 992e43de8dc3c713b7d9f6e606ed87e70ea1c685
4
- data.tar.gz: 0bb774247bbce2b562d131dc33e76e16d4bf36fb
5
- SHA512:
6
- metadata.gz: ed549aaa6e8fd50cf803291cc3b877ce2372cf49665bef5ff7bdacc73bb173056adfba30cdb231de103f86d045a019e2831b48f544517f23f46c2b4144d01190
7
- data.tar.gz: 028d6e599d518d4febb323651f2d319533038b6c2c565e91852f01c16912c2b5ab33bbfe7604bdca092fd7fd1f2e217c77ace56363428c315c3b7b8af9f55d01
@@ -1,5 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Quandl::Client do
5
- end