laa-fee-calculator-client 1.3.1 → 1.5.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: 846930f03ac36c9166dcba3a25cc3b2b552f32b31861043fa1908741912da754
4
- data.tar.gz: 3b5ec2435a93a7584eff62facedf12a8ab3c754f6f83bcabc625b1ef8fc96c07
3
+ metadata.gz: 52dad37ddaa604f0310847d554f9b406e43dd9b2153fa6d17a4dbea85762b102
4
+ data.tar.gz: 95a890df3d0845b5221dc665012f8b5871a239b1897821ca7a14ad7d1a9b6bb6
5
5
  SHA512:
6
- metadata.gz: 953bba0d471745c2502a7dc9b0d7cc21c1a58fae009ce09777d419b4a9cc7177b25593d90476ed3536b2f17092b2f124336090dd6c600b7567021dc0f2d26113
7
- data.tar.gz: 44e1ca22ff932959a6ddfab3046120b8d619647178e9e37957b23539176cee281916e24f23cc6b4fb409b0c58862c0650bf460eb2ee92032c0dbd0a0472e4e25
6
+ metadata.gz: eb5410870bc5c8a3e72338abe89dc2c6f17aa40bd5acca6823b8f8253b81d62664723295ea80f75f752c83ade5dae49643faa7cdd1e78359dbdc43697829e276
7
+ data.tar.gz: 247a6c9aadf2b51350a1c0b2521418cbff6d8e4ab2f257d13ce80b608005fc3fdb7fbb570c3b01f383c6d20f742ce8fe73f4c59fa208e28b8b847d5829e60a3b
data/CHANGELOG.md CHANGED
@@ -13,6 +13,20 @@ Add latest change log entries at top using template:
13
13
  ### Removed
14
14
  -
15
15
  ```
16
+
17
+ ## Version 1.5.0
18
+
19
+ ### Added
20
+ - Support for Ruby 3.2 and 3.3
21
+
22
+ ### Removed
23
+ - Support for Ruby 2.6 and 2.7
24
+
25
+ ## Version 1.4.0
26
+
27
+ ### Added
28
+ - New configuration options for caching and logging
29
+
16
30
  ## Version 1.3.1
17
31
 
18
32
  ### Removed
data/Gemfile CHANGED
@@ -6,3 +6,15 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in laa-fee-calculator-client.gemspec
8
8
  gemspec
9
+
10
+ # Gems for development and test
11
+ gem 'awesome_print'
12
+ gem 'rake', '~> 13.0'
13
+ gem 'rb-readline'
14
+ gem 'rspec', '~> 3.0'
15
+ gem 'rubocop', '~> 1.28'
16
+ gem 'rubocop-performance', '~> 1.13'
17
+ gem 'rubocop-rake', '~> 0.6'
18
+ gem 'rubocop-rspec', '~> 2.10'
19
+ gem 'vcr'
20
+ gem 'webmock'
data/README.md CHANGED
@@ -163,6 +163,17 @@ end
163
163
 
164
164
  ```
165
165
 
166
+ ## Caching
167
+
168
+ Caching can be configured, with optional logging, by providing a cache store:
169
+
170
+ ```ruby
171
+ LAA::FeeCalculator.configure do |config|
172
+ config.cache = Rails.cache
173
+ config.logger = Rails.logger
174
+ end
175
+ ```
176
+
166
177
  Note:
167
178
 
168
179
  ## Contributing
@@ -173,7 +184,7 @@ Bug reports and pull requests are welcome on GitHub at [ministryofjustice/laa-fe
173
184
 
174
185
  1. Make required changes, run specs (rerecord vcr cassettes if necessary)
175
186
 
176
- 2. Run `bin/ruby_version_test` to test against ruby versions (2.7+ supported at present)
187
+ 2. Run `bin/ruby_version_test` to test against ruby versions (3.0+ supported at present)
177
188
 
178
189
  3. Update the VERSION in `lib/laa/fee_calculator/version` using [semantic versioning](https://guides.rubygems.org/patterns/#semantic-versioning).
179
190
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e
4
4
 
5
- RUBIES="2.7 3.0 3.1"
5
+ RUBIES="3.0 3.1 3.2 3.3"
6
6
 
7
7
  if [ -e Gemfile.lock ]
8
8
  then
@@ -23,18 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ['lib']
24
24
 
25
25
  # see bin/ruby_version_test
26
- spec.required_ruby_version = '>= 2.6.0'
26
+ spec.required_ruby_version = '>= 3.0.0'
27
27
 
28
28
  spec.add_runtime_dependency 'faraday', '~> 1.0'
29
-
30
- spec.add_development_dependency 'awesome_print'
31
- spec.add_development_dependency 'rake', '~> 13.0'
32
- spec.add_development_dependency 'rb-readline'
33
- spec.add_development_dependency 'rspec', '~> 3.0'
34
- spec.add_development_dependency 'rubocop', '~> 1.28'
35
- spec.add_development_dependency 'rubocop-performance', '~> 1.13'
36
- spec.add_development_dependency 'rubocop-rake', '~> 0.6'
37
- spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
38
- spec.add_development_dependency 'vcr'
39
- spec.add_development_dependency 'webmock'
29
+ spec.add_runtime_dependency 'faraday-http-cache', '~> 2.2'
30
+ spec.metadata['rubygems_mfa_required'] = 'true'
40
31
  end
@@ -8,7 +8,7 @@ module LAA
8
8
 
9
9
  def initialize(scheme_pk, options)
10
10
  @uri = "fee-schemes/#{scheme_pk}/calculate/"
11
- @filtered_params = options.reject { |k, _v| k.eql?(:id) }
11
+ @filtered_params = options.except(:id)
12
12
  end
13
13
 
14
14
  def call
@@ -18,8 +18,7 @@ module LAA
18
18
 
19
19
  def fee_schemes(id = nil, **options)
20
20
  uri = fee_schemes_uri(id || options[:id])
21
- filtered_params = options.reject { |k, _| k.eql?(:id) }
22
- # Ruby 3.0+; filtered_params = options.except(:id)
21
+ filtered_params = options.except(:id)
23
22
 
24
23
  json = get(uri, filtered_params).body
25
24
 
@@ -6,7 +6,7 @@ module LAA
6
6
  LAA_FEE_CALCULATOR_API_V1 = 'https://laa-fee-calculator.service.justice.gov.uk/api/v1'
7
7
  HEADERS = { 'Accept' => 'application/json', 'User-Agent' => USER_AGENT }.freeze
8
8
 
9
- attr_accessor :host, :headers
9
+ attr_accessor :host, :headers, :cache, :logger
10
10
 
11
11
  def initialize
12
12
  @host = host || LAA_FEE_CALCULATOR_API_V1
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'singleton'
4
4
  require 'faraday'
5
+ require 'faraday/http_cache'
5
6
 
6
7
  module LAA
7
8
  module FeeCalculator
@@ -16,6 +17,7 @@ module LAA
16
17
  def initialize
17
18
  @conn = Faraday.new(url: LAA::FeeCalculator.configuration.host, headers: default_headers) do |conn|
18
19
  conn.use LAA::FeeCalculator::RaiseError
20
+ conn.use(:http_cache, store: cache, logger: logger) if cache
19
21
  conn.adapter :net_http
20
22
  end
21
23
  end
@@ -39,6 +41,14 @@ module LAA
39
41
  def default_headers
40
42
  LAA::FeeCalculator.configuration.headers
41
43
  end
44
+
45
+ def cache
46
+ LAA::FeeCalculator.configuration.cache
47
+ end
48
+
49
+ def logger
50
+ LAA::FeeCalculator.configuration.logger
51
+ end
42
52
  end
43
53
  end
44
54
  end
@@ -21,7 +21,7 @@ module LAA
21
21
  def has_many(association)
22
22
  define_method(association) do |id = nil, **options|
23
23
  uri = uri_for(association, id: id || options[:id])
24
- filtered_params = options.reject { |k, _v| k.eql?(:id) }
24
+ filtered_params = options.except(:id)
25
25
 
26
26
  json = get(uri, filtered_params).body
27
27
 
@@ -9,16 +9,16 @@ module LAA
9
9
  # gem specific handlers.
10
10
  #
11
11
  class RaiseError < Faraday::Response::Middleware
12
- CLIENT_ERROR_STATUSES = (400...600).freeze
12
+ CLIENT_ERROR_STATUSES = (400...600)
13
13
 
14
14
  def on_complete(env)
15
15
  case env[:status]
16
16
  when 400
17
- raise LAA::FeeCalculator::ResponseError.new(response_values(env))
17
+ raise LAA::FeeCalculator::ResponseError, response_values(env)
18
18
  when 404
19
- raise LAA::FeeCalculator::ResourceNotFound.new(response_values(env))
19
+ raise LAA::FeeCalculator::ResourceNotFound, response_values(env)
20
20
  when CLIENT_ERROR_STATUSES
21
- raise LAA::FeeCalculator::ClientError.new(response_values(env))
21
+ raise LAA::FeeCalculator::ClientError, response_values(env)
22
22
  end
23
23
  end
24
24
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module LAA
4
4
  module FeeCalculator
5
- VERSION = '1.3.1'
6
- USER_AGENT = "laa-fee-calculator-client/#{VERSION}"
5
+ VERSION = '1.5.0'
6
+ USER_AGENT = "laa-fee-calculator-client/#{VERSION}".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laa-fee-calculator-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katharine Ahern
8
8
  - Ministry of Justice
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-04-29 00:00:00.000000000 Z
12
+ date: 2024-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -26,145 +26,19 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: awesome_print
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: rake
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '13.0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '13.0'
56
- - !ruby/object:Gem::Dependency
57
- name: rb-readline
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: rspec
29
+ name: faraday-http-cache
72
30
  requirement: !ruby/object:Gem::Requirement
73
31
  requirements:
74
32
  - - "~>"
75
33
  - !ruby/object:Gem::Version
76
- version: '3.0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '3.0'
84
- - !ruby/object:Gem::Dependency
85
- name: rubocop
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - "~>"
89
- - !ruby/object:Gem::Version
90
- version: '1.28'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '1.28'
98
- - !ruby/object:Gem::Dependency
99
- name: rubocop-performance
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: '1.13'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '1.13'
112
- - !ruby/object:Gem::Dependency
113
- name: rubocop-rake
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: '0.6'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - "~>"
124
- - !ruby/object:Gem::Version
125
- version: '0.6'
126
- - !ruby/object:Gem::Dependency
127
- name: rubocop-rspec
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - "~>"
131
- - !ruby/object:Gem::Version
132
- version: '2.10'
133
- type: :development
34
+ version: '2.2'
35
+ type: :runtime
134
36
  prerelease: false
135
37
  version_requirements: !ruby/object:Gem::Requirement
136
38
  requirements:
137
39
  - - "~>"
138
40
  - !ruby/object:Gem::Version
139
- version: '2.10'
140
- - !ruby/object:Gem::Dependency
141
- name: vcr
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- version: '0'
147
- type: :development
148
- prerelease: false
149
- version_requirements: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: '0'
154
- - !ruby/object:Gem::Dependency
155
- name: webmock
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: '0'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- version: '0'
41
+ version: '2.2'
168
42
  description: Ruby client for the Ministry of Justices LAA fee calculator API. A simple
169
43
  interface for transparent calling of the API endpoints to query data and return
170
44
  calculated fee amounts.
@@ -201,8 +75,9 @@ files:
201
75
  homepage: https://github.com/ministryofjustice/laa-fee-calculator-client
202
76
  licenses:
203
77
  - MIT
204
- metadata: {}
205
- post_install_message:
78
+ metadata:
79
+ rubygems_mfa_required: 'true'
80
+ post_install_message:
206
81
  rdoc_options: []
207
82
  require_paths:
208
83
  - lib
@@ -210,15 +85,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
85
  requirements:
211
86
  - - ">="
212
87
  - !ruby/object:Gem::Version
213
- version: 2.6.0
88
+ version: 3.0.0
214
89
  required_rubygems_version: !ruby/object:Gem::Requirement
215
90
  requirements:
216
91
  - - ">="
217
92
  - !ruby/object:Gem::Version
218
93
  version: '0'
219
94
  requirements: []
220
- rubygems_version: 3.1.6
221
- signing_key:
95
+ rubygems_version: 3.5.3
96
+ signing_key:
222
97
  specification_version: 4
223
98
  summary: Ruby client for the Legal Aid Agency fee calculator API
224
99
  test_files: []