quandl_client 2.3.2 → 2.4.0
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/examples/create.rb +6 -2
- data/lib/quandl/client/models/dataset.rb +4 -7
- data/lib/quandl/client/models/source.rb +1 -1
- data/lib/quandl/client/version.rb +1 -1
- data/lib/quandl/client.rb +3 -0
- data/lib/quandl/pattern/client.rb +9 -0
- data/lib/quandl/pattern.rb +38 -0
- data/quandl_client.gemspec +1 -1
- data/spec/lib/quandl/client/dataset/attributes_spec.rb +8 -6
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bdbf7c4522f4761addb5805c1ff9f7933021ee8
|
4
|
+
data.tar.gz: 26ed1147332cde5d16d202662bfda14b784e46db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f06923fbaafc6eb86326796a3355b09a3e25214ccd4626ec3d5bcff7549439483283fb26713ca297da2da14d7fcc86b427333d762b9ad0a1858de179409d0bd4
|
7
|
+
data.tar.gz: 68ee14e21b88d24f9d3a89a2703ee1c6a8a5a3031c13ecc9b3c84fc797636cd6f4b7dbdeed37b62b4e9ae8a818bc62e973a7afd96ed7f631763861395cc96c19
|
data/UPGRADE.md
CHANGED
data/examples/create.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
2
2
|
|
3
|
-
|
3
|
+
# load quandl api client
|
4
4
|
require "quandl/client"
|
5
|
+
|
6
|
+
# tools for debugging
|
5
7
|
require "quandl/fabricate"
|
6
8
|
require 'securerandom'
|
9
|
+
require 'pry'
|
7
10
|
|
11
|
+
# Make Dataset available in global namespace
|
8
12
|
include Quandl::Client
|
9
13
|
|
14
|
+
# configure quandl client
|
10
15
|
Quandl::Client.use ENV['QUANDL_API_HOST']
|
11
16
|
Quandl::Client.token = ENV['QUANDL_USER_TOKEN']
|
12
|
-
# Quandl::Client.use 'http://quandl.com/api/'
|
13
17
|
|
14
18
|
binding.pry
|
@@ -2,9 +2,6 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
2
2
|
|
3
3
|
require 'quandl/client/models/dataset/data'
|
4
4
|
|
5
|
-
# parse_root_in_json true
|
6
|
-
# root_element :docs
|
7
|
-
|
8
5
|
##########
|
9
6
|
# SCOPES #
|
10
7
|
##########
|
@@ -30,10 +27,9 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
30
27
|
# VALIDATIONS #
|
31
28
|
###############
|
32
29
|
|
33
|
-
validates :code, presence: true, format: { with:
|
30
|
+
validates :code, presence: true, format: { with: Quandl::Pattern.code, message: "is invalid. Expected format: #{Quandl::Pattern.code.to_example}" }
|
34
31
|
validates :display_url, allow_blank: true, url: true
|
35
32
|
|
36
|
-
|
37
33
|
##############
|
38
34
|
# PROPERTIES #
|
39
35
|
##############
|
@@ -46,6 +42,8 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
46
42
|
|
47
43
|
before_save :enforce_required_formats
|
48
44
|
|
45
|
+
after_save :save_dataset_data
|
46
|
+
|
49
47
|
alias_method :locations, :locations_attributes
|
50
48
|
alias_method :locations=, :locations_attributes=
|
51
49
|
|
@@ -53,6 +51,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
53
51
|
self.display_url
|
54
52
|
end
|
55
53
|
def reference_url=(value)
|
54
|
+
value = "http://#{value}" if value.present? && !(value =~ /http:\/\//)
|
56
55
|
self.display_url = value
|
57
56
|
end
|
58
57
|
|
@@ -104,8 +103,6 @@ class Quandl::Client::Dataset < Quandl::Client::Base
|
|
104
103
|
@full_code = nil
|
105
104
|
end
|
106
105
|
|
107
|
-
after_save :save_dataset_data
|
108
|
-
|
109
106
|
protected
|
110
107
|
|
111
108
|
def save_dataset_data
|
@@ -25,7 +25,7 @@ class Source < Quandl::Client::Base
|
|
25
25
|
# VALIDATIONS #
|
26
26
|
###############
|
27
27
|
|
28
|
-
validates :code, presence: true, length: { minimum: 2 }, format: { with:
|
28
|
+
validates :code, presence: true, length: { minimum: 2 }, format: { with: Quandl::Pattern.code, message: "is invalid. Expected format: #{Quandl::Pattern.code.to_example}" }
|
29
29
|
validates :host, :name, presence: true
|
30
30
|
|
31
31
|
|
data/lib/quandl/client.rb
CHANGED
@@ -6,6 +6,9 @@ require 'quandl/her/remove_method_data'
|
|
6
6
|
require 'quandl/logger'
|
7
7
|
require "quandl/data"
|
8
8
|
|
9
|
+
require 'quandl/pattern'
|
10
|
+
require 'quandl/pattern/client'
|
11
|
+
|
9
12
|
require 'quandl/client/middleware'
|
10
13
|
require 'quandl/client/base'
|
11
14
|
require 'quandl/client/models/dataset'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Quandl
|
2
|
+
class Pattern
|
3
|
+
|
4
|
+
define_pattern :dataset_date, /[0-9]{4}\-[0-9]{2}\-[0-9]{2}/, example: "yyyy-mm-dd"
|
5
|
+
define_pattern :code, /[A-Z0-9_]{3,}+/, example: 'ALPHA_NUMERIC_1024'
|
6
|
+
define_pattern :full_code, /(#{code}\/)?(#{code})/, example: "(SOURCE_CODE/)#{code.to_example}"
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Quandl
|
2
|
+
class Pattern < Regexp
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def define_pattern(name, pattern, options={})
|
7
|
+
assert_unique_pattern!(name, pattern)
|
8
|
+
patterns << name
|
9
|
+
define_singleton_method(name){ Quandl::Pattern.new( pattern, options ) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def assert_unique_pattern!(name, pattern)
|
13
|
+
return false unless self.respond_to?(name)
|
14
|
+
message = "Attempted to redefine previously defined pattern! '#{name}', /#{pattern}/"
|
15
|
+
raise ArgumentError.new(name), message
|
16
|
+
end
|
17
|
+
|
18
|
+
def patterns
|
19
|
+
@patterns ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(*args)
|
25
|
+
@options = args.pop if args.last.is_a?(Hash)
|
26
|
+
super(*args)
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_example
|
30
|
+
options[:example]
|
31
|
+
end
|
32
|
+
|
33
|
+
def options
|
34
|
+
@options ||= {}
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/quandl_client.gemspec
CHANGED
@@ -10,6 +10,12 @@ describe Dataset do
|
|
10
10
|
}
|
11
11
|
subject{ create(:dataset, source_code: source.code, private: true ) }
|
12
12
|
|
13
|
+
describe "#name" do
|
14
|
+
subject{ create(:dataset, source_code: source.code, private: true, name: '' ) }
|
15
|
+
|
16
|
+
its(:name){ should match /Untitled Dataset #{Date.today}/ }
|
17
|
+
end
|
18
|
+
|
13
19
|
describe "#reference_url" do
|
14
20
|
let(:url){ "http://website.com/path/to/reference" }
|
15
21
|
let(:dataset){ Dataset.new( reference_url: url, code: "VALID" ) }
|
@@ -20,12 +26,8 @@ describe Dataset do
|
|
20
26
|
|
21
27
|
context "partial url" do
|
22
28
|
let(:url){ "website.com/path/to/reference" }
|
23
|
-
its(:
|
24
|
-
|
25
|
-
|
26
|
-
context "invalid url" do
|
27
|
-
let(:url){ "website" }
|
28
|
-
its(:valid?){ should be_false }
|
29
|
+
its(:reference_url){ should eq "http://website.com/path/to/reference" }
|
30
|
+
its(:valid?){ should be_true }
|
29
31
|
end
|
30
32
|
|
31
33
|
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
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Hilscher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -228,6 +228,8 @@ files:
|
|
228
228
|
- lib/quandl/client/models/user.rb
|
229
229
|
- lib/quandl/client/version.rb
|
230
230
|
- lib/quandl/her/remove_method_data.rb
|
231
|
+
- lib/quandl/pattern.rb
|
232
|
+
- lib/quandl/pattern/client.rb
|
231
233
|
- quandl_client.gemspec
|
232
234
|
- spec/factories/dataset.rb
|
233
235
|
- spec/factories/sheet.rb
|