quandl_client 2.10.2 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/UPGRADE.md +3 -19
- data/lib/quandl/client/base.rb +1 -1
- data/lib/quandl/client/base/attributes.rb +12 -12
- data/lib/quandl/client/base/benchmark.rb +39 -39
- data/lib/quandl/client/base/model.rb +37 -37
- data/lib/quandl/client/base/search.rb +67 -68
- data/lib/quandl/client/base/validation.rb +96 -96
- data/lib/quandl/client/middleware.rb +4 -4
- data/lib/quandl/client/middleware/parse_json.rb +77 -79
- data/lib/quandl/client/models/dataset/benchmark.rb +7 -8
- data/lib/quandl/client/models/dataset/validations.rb +121 -121
- data/lib/quandl/client/models/location.rb +5 -7
- data/lib/quandl/client/models/report.rb +9 -11
- data/lib/quandl/client/models/scraper.rb +15 -18
- data/lib/quandl/client/models/sheet.rb +46 -48
- data/lib/quandl/client/models/source.rb +43 -45
- data/lib/quandl/client/version.rb +11 -11
- data/lib/quandl/pattern.rb +32 -32
- data/lib/quandl/pattern/client.rb +7 -7
- data/quandl_client.gemspec +1 -1
- data/spec/config/quandl.rb +4 -4
- data/spec/lib/quandl/client/base_spec.rb +8 -0
- data/spec/lib/quandl/client/dataset_spec.rb +4 -4
- metadata +41 -74
- data/VERSION +0 -1
@@ -1,15 +1,13 @@
|
|
1
1
|
module Quandl
|
2
|
-
module Client
|
2
|
+
module Client
|
3
|
+
class Report < Quandl::Client::Base
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# VALIDATIONS #
|
8
|
-
###############
|
9
|
-
|
10
|
-
validates :message, presence: true
|
11
|
-
|
12
|
-
end
|
5
|
+
###############
|
6
|
+
# VALIDATIONS #
|
7
|
+
###############
|
13
8
|
|
14
|
-
|
9
|
+
validates :message, presence: true
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
15
13
|
end
|
@@ -1,24 +1,21 @@
|
|
1
1
|
module Quandl
|
2
|
-
module Client
|
2
|
+
module Client
|
3
|
+
class Scraper < Quandl::Client::Base
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
has_many :jobs
|
7
|
-
|
8
|
-
attributes :id, :name, :scraper, :scraper_url, :git_url, :git_reference, :created_at, :updated_at,
|
9
|
-
:type, :schedule_at, :schedule_run_time, :schedule_next
|
10
|
-
|
11
|
-
validates :name, presence: true
|
12
|
-
|
13
|
-
def scraper=(value)
|
14
|
-
write_attribute(:scraper, Faraday::UploadIO.new(value, 'text/plain') )
|
15
|
-
end
|
5
|
+
has_many :jobs
|
16
6
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
7
|
+
attributes :id, :name, :scraper, :scraper_url, :git_url, :git_reference, :created_at, :updated_at,
|
8
|
+
:type, :schedule_at, :schedule_run_time, :schedule_next
|
20
9
|
|
21
|
-
|
10
|
+
validates :name, presence: true
|
22
11
|
|
23
|
-
|
12
|
+
def scraper=(value)
|
13
|
+
write_attribute(:scraper, Faraday::UploadIO.new(value, 'text/plain') )
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_now
|
17
|
+
jobs.create
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
24
21
|
end
|
@@ -1,51 +1,49 @@
|
|
1
1
|
module Quandl
|
2
|
-
module Client
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
###############
|
27
|
-
# VALIDATIONS #
|
28
|
-
###############
|
29
|
-
|
30
|
-
validates :title, presence: true
|
31
|
-
|
32
|
-
|
33
|
-
##############
|
34
|
-
# PROPERTIES #
|
35
|
-
##############
|
36
|
-
|
37
|
-
attributes :title, :content, :url_title, :full_url_title, :description, :skip_browse
|
38
|
-
|
39
|
-
def html
|
40
|
-
@html ||= self.attributes[:html] || Quandl::Client::Sheet.find(full_url_title).attributes[:html]
|
41
|
-
end
|
42
|
-
|
43
|
-
def parent_url_title
|
44
|
-
@parent_url_title ||= self.full_url_title.split('/')[0..-2].join()
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
end
|
2
|
+
module Client
|
3
|
+
class Sheet < Quandl::Client::Base
|
4
|
+
|
5
|
+
##########
|
6
|
+
# SCOPES #
|
7
|
+
##########
|
8
|
+
|
9
|
+
scope :query, :page, :parent_url_title
|
10
|
+
|
11
|
+
|
12
|
+
################
|
13
|
+
# ASSOCIATIONS #
|
14
|
+
################
|
15
|
+
|
16
|
+
def parent
|
17
|
+
@parent ||= Quandl::Client::Sheet.find(parent_url_title)
|
18
|
+
end
|
19
|
+
|
20
|
+
def children
|
21
|
+
Quandl::Client::Sheet.parent_url_title(self.full_url_title)
|
22
|
+
end
|
49
23
|
|
50
|
-
|
24
|
+
|
25
|
+
###############
|
26
|
+
# VALIDATIONS #
|
27
|
+
###############
|
28
|
+
|
29
|
+
validates :title, presence: true
|
30
|
+
|
31
|
+
|
32
|
+
##############
|
33
|
+
# PROPERTIES #
|
34
|
+
##############
|
35
|
+
|
36
|
+
attributes :title, :content, :url_title, :full_url_title, :description, :skip_browse
|
37
|
+
|
38
|
+
def html
|
39
|
+
@html ||= self.attributes[:html] || Quandl::Client::Sheet.find(full_url_title).attributes[:html]
|
40
|
+
end
|
41
|
+
|
42
|
+
def parent_url_title
|
43
|
+
@parent_url_title ||= self.full_url_title.split('/')[0..-2].join()
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
51
49
|
end
|
@@ -1,49 +1,47 @@
|
|
1
1
|
module Quandl
|
2
|
-
module Client
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
module Client
|
3
|
+
class Source < Quandl::Client::Base
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def cached
|
8
|
+
@@cached ||= {}
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
##########
|
14
|
+
# SCOPES #
|
15
|
+
##########
|
16
|
+
|
17
|
+
scope :query
|
18
|
+
scope :page, ->(p){ where( page: p.to_i )}
|
19
|
+
scope :code, ->(c){ where( code: c.to_s.upcase )}
|
20
|
+
|
21
|
+
|
22
|
+
###############
|
23
|
+
# ASSOCIATIONS #
|
24
|
+
###############
|
25
|
+
|
26
|
+
def datasets
|
27
|
+
Quandl::Client::Dataset.source_code(code)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
###############
|
32
|
+
# VALIDATIONS #
|
33
|
+
###############
|
34
|
+
|
35
|
+
validates :code, presence: true, length: { minimum: 2 }, format: { with: Quandl::Pattern.code, message: "is invalid. Expected format: #{Quandl::Pattern.code.to_example}" }
|
36
|
+
validates :host, :name, presence: true
|
37
|
+
|
38
|
+
|
39
|
+
##############
|
40
|
+
# PROPERTIES #
|
41
|
+
##############
|
42
|
+
|
43
|
+
attributes :code, :name, :host, :description, :datasets_count, :use_proxy, :type, :concurrency
|
44
|
+
|
10
45
|
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
##########
|
15
|
-
# SCOPES #
|
16
|
-
##########
|
17
|
-
|
18
|
-
scope :query
|
19
|
-
scope :page, ->(p){ where( page: p.to_i )}
|
20
|
-
scope :code, ->(c){ where( code: c.to_s.upcase )}
|
21
|
-
|
22
|
-
|
23
|
-
###############
|
24
|
-
# ASSOCIATIONS #
|
25
|
-
###############
|
26
|
-
|
27
|
-
def datasets
|
28
|
-
Quandl::Client::Dataset.source_code(code)
|
29
46
|
end
|
30
|
-
|
31
|
-
|
32
|
-
###############
|
33
|
-
# VALIDATIONS #
|
34
|
-
###############
|
35
|
-
|
36
|
-
validates :code, presence: true, length: { minimum: 2 }, format: { with: Quandl::Pattern.code, message: "is invalid. Expected format: #{Quandl::Pattern.code.to_example}" }
|
37
|
-
validates :host, :name, presence: true
|
38
|
-
|
39
|
-
|
40
|
-
##############
|
41
|
-
# PROPERTIES #
|
42
|
-
##############
|
43
|
-
|
44
|
-
attributes :code, :name, :host, :description, :datasets_count, :use_proxy, :type, :concurrency
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
47
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module Quandl
|
2
|
-
module Client
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
module Client
|
3
|
+
VERSION = '2.11.0'
|
4
|
+
API_VERSION = 'v2'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def api_version
|
9
|
+
API_VERSION
|
10
|
+
end
|
11
|
+
|
10
12
|
end
|
11
|
-
|
13
|
+
|
12
14
|
end
|
13
|
-
|
14
|
-
end
|
15
15
|
end
|
data/lib/quandl/pattern.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
module Quandl
|
2
|
-
class Pattern < Regexp
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
+
|
10
22
|
end
|
11
|
-
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
raise ArgumentError.new(name), message
|
23
|
+
|
24
|
+
def initialize(*args)
|
25
|
+
@options = args.pop if args.last.is_a?(Hash)
|
26
|
+
super(*args)
|
16
27
|
end
|
17
|
-
|
18
|
-
def
|
19
|
-
|
28
|
+
|
29
|
+
def to_example
|
30
|
+
options[:example]
|
20
31
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
super(*args)
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_example
|
30
|
-
options[:example]
|
31
|
-
end
|
32
|
-
|
33
|
-
def options
|
34
|
-
@options ||= {}
|
32
|
+
|
33
|
+
def options
|
34
|
+
@options ||= {}
|
35
|
+
end
|
36
|
+
|
35
37
|
end
|
36
|
-
|
37
|
-
end
|
38
38
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Quandl
|
2
|
-
class Pattern
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
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_]+/, example: 'ALPHA_NUMERIC_ALL_CAPS'
|
6
|
+
define_pattern :full_code, /(#{code}+)\/?(#{code})?/, example: "(SOURCE_CODE/)#{code.to_example}"
|
7
|
+
|
8
|
+
end
|
9
9
|
end
|
data/quandl_client.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_runtime_dependency "quandl_data", "~> 1.5"
|
21
21
|
s.add_runtime_dependency "activesupport", ">= 3.0.0"
|
22
|
-
s.add_runtime_dependency "her", "~> 0.6"
|
22
|
+
s.add_runtime_dependency "her", "~> 0.6.0"
|
23
23
|
s.add_runtime_dependency 'json', '~> 1.7.7'
|
24
24
|
s.add_runtime_dependency "scope_composer", "~> 0.3"
|
25
25
|
|
data/spec/config/quandl.rb
CHANGED
@@ -2,9 +2,9 @@ require 'ostruct'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module Spec
|
5
|
-
module Config
|
6
|
-
|
7
|
-
end
|
5
|
+
module Config
|
6
|
+
Quandl = OpenStruct.new(YAML.load(File.read(File.join(ENV['HOME'], '.quandl/test'))))
|
7
|
+
end
|
8
8
|
end
|
9
9
|
|
10
10
|
require "quandl/client"
|
@@ -13,4 +13,4 @@ require "quandl/fabricate"
|
|
13
13
|
include Quandl::Client
|
14
14
|
|
15
15
|
Quandl::Client.token = Spec::Config::Quandl.token
|
16
|
-
Quandl::Client.use(
|
16
|
+
Quandl::Client.use(Spec::Config::Quandl.quandl_url)
|
@@ -32,10 +32,10 @@ describe Dataset do
|
|
32
32
|
|
33
33
|
it "should change url" do
|
34
34
|
original_url = Quandl::Client::Base.url
|
35
|
-
Quandl::Client.use('
|
36
|
-
Quandl::Client::Dataset.url.should eq '
|
37
|
-
Quandl::Client.use('
|
38
|
-
Quandl::Client::Dataset.url.should eq '
|
35
|
+
Quandl::Client.use('https://url.com/')
|
36
|
+
Quandl::Client::Dataset.url.should eq 'https://url.com/v2'
|
37
|
+
Quandl::Client.use('https://url.com/2/')
|
38
|
+
Quandl::Client::Dataset.url.should eq 'https://url.com/2/v2'
|
39
39
|
Quandl::Client.use original_url
|
40
40
|
end
|
41
41
|
|