iron_bank 3.3.4 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dcbe1d65189ca5901e083f5865448fd02a7867d079a476897ed66253838fe48
4
- data.tar.gz: 4bddf6e7bb277eb398b41b643b95c2786c53479e211c6148c7212afae3e9c900
3
+ metadata.gz: 195ba10f5c39626868e1d281972ff45e4618f1e72b0d87684aa9c65d1ed1fa10
4
+ data.tar.gz: acd56eae404df5027aceeb8081b542da811178a71ff56924531b4d2280fa045d
5
5
  SHA512:
6
- metadata.gz: 45f9a859f8981a3f5ff823d9baa458a525fbc01faa93d5e36c065839fa5fcf12ae9cbfe20aa5bf3b840015580c8d124e7aaea480a9ca53910eab84f6829ee591
7
- data.tar.gz: a087ba2703630d7524a7e642f9f6467926d7f9a4d29b115d8e0aa7ad555984ee8f1aaad5dba16de48ac04290b6d022c06cde16a09ae0f3949ef05a18f5aec638
6
+ metadata.gz: 4db1e53ef118e2b496a1ae41ea0f880458386767e57a562de235f0e734416df59f441c7f1928aca06cfa3904c49623985a794f5b3bf72121391488c2dc1a1da4
7
+ data.tar.gz: 25c9457c4716177d3a21d0f6b993a433558a323a6ba8f63e4cca881660ddca92408a16226d6ae4e42f05f6d280c6340c42c2667a8a2c131afc0a3adee9acd05d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iron_bank (3.3.4)
4
+ iron_bank (3.4.0)
5
5
  faraday (~> 0)
6
6
  faraday_middleware (~> 0)
7
7
  nokogiri (~> 1)
@@ -30,8 +30,8 @@ GEM
30
30
  descendants_tracker (0.0.4)
31
31
  thread_safe (~> 0.3, >= 0.3.1)
32
32
  diff-lcs (1.3)
33
- docile (1.3.1)
34
- dotenv (2.7.2)
33
+ docile (1.3.2)
34
+ dotenv (2.7.5)
35
35
  equalizer (0.0.11)
36
36
  factory_bot (5.0.2)
37
37
  activesupport (>= 4.2.0)
@@ -42,7 +42,7 @@ GEM
42
42
  i18n (1.6.0)
43
43
  concurrent-ruby (~> 1.0)
44
44
  ice_nine (0.11.2)
45
- jaro_winkler (1.5.2)
45
+ jaro_winkler (1.5.3)
46
46
  json (2.2.0)
47
47
  kwalify (0.7.2)
48
48
  method_source (0.9.2)
@@ -52,7 +52,7 @@ GEM
52
52
  nokogiri (1.10.4)
53
53
  mini_portile2 (~> 2.4.0)
54
54
  parallel (1.17.0)
55
- parser (2.6.2.1)
55
+ parser (2.6.3.0)
56
56
  ast (~> 2.4.0)
57
57
  pry (0.12.2)
58
58
  coderay (~> 1.1.0)
@@ -62,8 +62,8 @@ GEM
62
62
  pry (~> 0.10)
63
63
  psych (3.1.0)
64
64
  rainbow (3.0.0)
65
- rake (12.3.2)
66
- reek (5.3.2)
65
+ rake (12.3.3)
66
+ reek (5.4.0)
67
67
  codeclimate-engine-rb (~> 0.4.0)
68
68
  kwalify (~> 0.7.0)
69
69
  parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
@@ -73,29 +73,28 @@ GEM
73
73
  rspec-core (~> 3.8.0)
74
74
  rspec-expectations (~> 3.8.0)
75
75
  rspec-mocks (~> 3.8.0)
76
- rspec-core (3.8.0)
76
+ rspec-core (3.8.2)
77
77
  rspec-support (~> 3.8.0)
78
- rspec-expectations (3.8.2)
78
+ rspec-expectations (3.8.4)
79
79
  diff-lcs (>= 1.2.0, < 2.0)
80
80
  rspec-support (~> 3.8.0)
81
- rspec-mocks (3.8.0)
81
+ rspec-mocks (3.8.1)
82
82
  diff-lcs (>= 1.2.0, < 2.0)
83
83
  rspec-support (~> 3.8.0)
84
- rspec-support (3.8.0)
85
- rubocop (0.67.2)
84
+ rspec-support (3.8.2)
85
+ rubocop (0.74.0)
86
86
  jaro_winkler (~> 1.5.1)
87
87
  parallel (~> 1.10)
88
- parser (>= 2.5, != 2.5.1.1)
89
- psych (>= 3.1.0)
88
+ parser (>= 2.6)
90
89
  rainbow (>= 2.2.2, < 4.0)
91
90
  ruby-progressbar (~> 1.7)
92
- unicode-display_width (>= 1.4.0, < 1.6)
93
- rubocop-performance (1.0.0)
94
- rubocop (>= 0.58.0)
95
- ruby-progressbar (1.10.0)
96
- shoulda-matchers (4.0.1)
91
+ unicode-display_width (>= 1.4.0, < 1.7)
92
+ rubocop-performance (1.4.1)
93
+ rubocop (>= 0.71.0)
94
+ ruby-progressbar (1.10.1)
95
+ shoulda-matchers (4.1.2)
97
96
  activesupport (>= 4.2.0)
98
- simplecov (0.16.1)
97
+ simplecov (0.17.0)
99
98
  docile (~> 1.1)
100
99
  json (>= 1.8, < 3)
101
100
  simplecov-html (~> 0.10.0)
@@ -104,7 +103,7 @@ GEM
104
103
  timecop (0.9.1)
105
104
  tzinfo (1.2.5)
106
105
  thread_safe (~> 0.1)
107
- unicode-display_width (1.5.0)
106
+ unicode-display_width (1.6.0)
108
107
  virtus (1.0.5)
109
108
  axiom-types (~> 0.1)
110
109
  coercible (~> 1.0)
@@ -128,7 +127,7 @@ DEPENDENCIES
128
127
  rubocop-performance (~> 1.0)
129
128
  shoulda-matchers (~> 4.0)
130
129
  simplecov (~> 0.15)
131
- timecop (~> 0.9.0)
130
+ timecop (~> 0.9)
132
131
 
133
132
  BUNDLED WITH
134
133
  2.0.2
data/iron_bank.gemspec CHANGED
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency "rubocop-performance", "~> 1.0"
42
42
  spec.add_development_dependency "shoulda-matchers", "~> 4.0"
43
43
  spec.add_development_dependency "simplecov", "~> 0.15"
44
- spec.add_development_dependency "timecop", "~> 0.9.0"
44
+ spec.add_development_dependency "timecop", "~> 0.9"
45
45
 
46
46
  spec.add_runtime_dependency "faraday", "~> 0"
47
47
  spec.add_runtime_dependency "faraday_middleware", "~> 0"
@@ -6,7 +6,14 @@ module IronBank
6
6
  # https://knowledgecenter.zuora.com/DC_Developers/K_Zuora_Object_Query_Language
7
7
  #
8
8
  class Query < Action
9
- def self.call(zoql, limit: 0)
9
+ # Zuora's default is 2,000 records, but we simply use `0` here to not pass
10
+ # the parameter to Zuora APIs during the query call.
11
+ #
12
+ # See https://knowledgecenter.zuora.com/DC_Developers/BC_ZOQL#Limits
13
+ #
14
+ DEFAULT_ZUORA_LIMIT = 0
15
+
16
+ def self.call(zoql, limit: DEFAULT_ZUORA_LIMIT)
10
17
  new(zoql, limit).call
11
18
  end
12
19
 
@@ -32,7 +32,8 @@ module IronBank
32
32
  cache.fetch(id, force: force) { super(id) }
33
33
  end
34
34
 
35
- def where(conditions)
35
+ def where(conditions,
36
+ limit: IronBank::Actions::Query::DEFAULT_ZUORA_LIMIT)
36
37
  # Conditions can be empty when called from #all, it does not make sense
37
38
  # to try to cache all records returned then.
38
39
  return super if conditions.empty?
@@ -19,7 +19,11 @@ module IronBank
19
19
  store.any? ? store.values : super
20
20
  end
21
21
 
22
- def where(conditions)
22
+ def first
23
+ store.any? ? store.values.first : super
24
+ end
25
+
26
+ def where(conditions, limit: IronBank::Actions::Query::DEFAULT_ZUORA_LIMIT)
23
27
  records = store.values.select do |record|
24
28
  conditions.all? { |field, value| record.public_send(field) == value }
25
29
  end
@@ -17,6 +17,9 @@ module IronBank
17
17
 
18
18
  # This methods leverages the fact that Zuora only returns 2,000 records at a
19
19
  # time, hance providing a default batch size
20
+ #
21
+ # See https://knowledgecenter.zuora.com/DC_Developers/BC_ZOQL#Limits
22
+ #
20
23
  def find_each
21
24
  return enum_for(:find_each) unless block_given?
22
25
 
@@ -36,17 +39,17 @@ module IronBank
36
39
  where({})
37
40
  end
38
41
 
39
- def where(conditions)
40
- query_string = IronBank::QueryBuilder.zoql(
41
- object_name,
42
- query_fields,
43
- conditions
44
- )
42
+ def first
43
+ where({}, limit: 1).first
44
+ end
45
+
46
+ def where(conditions, limit: IronBank::Actions::Query::DEFAULT_ZUORA_LIMIT)
47
+ query_string = IronBank::QueryBuilder.
48
+ zoql(object_name, query_fields, conditions)
45
49
 
46
- # FIXME: need to use logger instance instead
47
- # puts "query: #{query_string}"
50
+ IronBank.logger.info "query: #{query_string}"
48
51
 
49
- records = IronBank::Query.call(query_string)[:records]
52
+ records = IronBank::Query.call(query_string, limit: limit)[:records]
50
53
  return [] unless records
51
54
 
52
55
  records.each.with_object([]) do |data, result|
@@ -8,7 +8,7 @@ module IronBank
8
8
 
9
9
  # Inspired from ActiveSupport
10
10
  def underscore(camel_cased_word)
11
- return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
11
+ return camel_cased_word unless /[A-Z-]|::/.match?(camel_cased_word)
12
12
 
13
13
  word = camel_cased_word.to_s.gsub(/::/, "/")
14
14
  word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IronBank
4
- VERSION = "3.3.4"
4
+ VERSION = "3.4.0"
5
5
  API_VERSION = "v1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_bank
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.4
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickael Pham
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2019-08-22 00:00:00.000000000 Z
14
+ date: 2019-09-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bump
@@ -187,14 +187,14 @@ dependencies:
187
187
  requirements:
188
188
  - - "~>"
189
189
  - !ruby/object:Gem::Version
190
- version: 0.9.0
190
+ version: '0.9'
191
191
  type: :development
192
192
  prerelease: false
193
193
  version_requirements: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - "~>"
196
196
  - !ruby/object:Gem::Version
197
- version: 0.9.0
197
+ version: '0.9'
198
198
  - !ruby/object:Gem::Dependency
199
199
  name: faraday
200
200
  requirement: !ruby/object:Gem::Requirement
@@ -349,7 +349,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
349
  - !ruby/object:Gem::Version
350
350
  version: '0'
351
351
  requirements: []
352
- rubygems_version: 3.0.3
352
+ rubygems_version: 3.0.6
353
353
  signing_key:
354
354
  specification_version: 4
355
355
  summary: An opinionated Ruby interface to the Zuora API.