quandl_client 2.7.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/UPGRADE.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.7.2
2
+
3
+
4
+
5
+
6
+
1
7
  ## 2.7.1
2
8
 
3
9
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
@@ -4,6 +4,7 @@ module Search
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  module ClassMethods
7
+
7
8
  def forwardable_scope_methods
8
9
  @forwardable_scope_methods ||= Array.forwardable_methods.reject{|m| [:find, :fetch].include?(m) }
9
10
  end
@@ -11,6 +11,15 @@ class Quandl::Client::Dataset < Quandl::Client::Base
11
11
  end
12
12
 
13
13
  def find(value)
14
+ # preformat
15
+ value = format_id(value)
16
+ # short-circuit if value is illegal
17
+ return nil unless value.is_a?(Integer) || value.to_s =~ %r{^#{Quandl::Pattern.full_code}$}
18
+ # search
19
+ super(value)
20
+ end
21
+
22
+ def format_id(value)
14
23
  # enforce code formatting
15
24
  if value.is_a?(String)
16
25
  # strip extra whitespace
@@ -20,9 +29,7 @@ class Quandl::Client::Dataset < Quandl::Client::Base
20
29
  # ensure uppercase
21
30
  value = value.upcase
22
31
  end
23
- # short-circuit if value is illegal
24
- return nil unless value.is_a?(Integer) || value.to_s =~ %r{^#{Quandl::Pattern.full_code}$}
25
- super(value)
32
+ value
26
33
  end
27
34
 
28
35
  end
@@ -10,8 +10,16 @@ class Quandl::Client::Superset < Quandl::Client::Base
10
10
  validates :column_codes, presence: true
11
11
  validate :column_codes_should_be_valid!
12
12
 
13
+ def self.find_or_build( attributes={} )
14
+ record = self.find(attributes[:id]) if attributes[:id].present?
15
+ record = self.where( attributes.slice(:code, :source_code).merge( owner: 'myself' ) ).first unless record.try(:exists?)
16
+ record = self.new unless record.try(:exists?)
17
+ record.assign_attributes(attributes)
18
+ record
19
+ end
20
+
13
21
  def self.example
14
- self.new( code: "EXAMPLE", name: "Superset Name", description: "Superset description", column_codes: ['SOURCE.DATASET.1'], column_names: ['Column Name'] )
22
+ self.new( code: "SUPERSET_EXAMPLE", name: "Superset Name", description: "Superset description", column_codes: ['NSE.OIL.1'], column_names: ['Column Name'] )
15
23
  end
16
24
 
17
25
  def data
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -296,7 +296,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
296
296
  version: '0'
297
297
  segments:
298
298
  - 0
299
- hash: -507232308785809062
299
+ hash: -1884002126048003470
300
300
  required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  none: false
302
302
  requirements:
@@ -305,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
305
  version: '0'
306
306
  segments:
307
307
  - 0
308
- hash: -507232308785809062
308
+ hash: -1884002126048003470
309
309
  requirements: []
310
310
  rubyforge_project:
311
311
  rubygems_version: 1.8.23