laa-fee-calculator-client 1.3.1 → 1.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: 846930f03ac36c9166dcba3a25cc3b2b552f32b31861043fa1908741912da754
4
- data.tar.gz: 3b5ec2435a93a7584eff62facedf12a8ab3c754f6f83bcabc625b1ef8fc96c07
3
+ metadata.gz: 5ef6d4916284e517e033ca34430e3159698a99d5839cd8d5da11ad5e6dc78250
4
+ data.tar.gz: ff85257fcd205872dd8ac5c98791a5705818247b5871051319d10116a68af7aa
5
5
  SHA512:
6
- metadata.gz: 953bba0d471745c2502a7dc9b0d7cc21c1a58fae009ce09777d419b4a9cc7177b25593d90476ed3536b2f17092b2f124336090dd6c600b7567021dc0f2d26113
7
- data.tar.gz: 44e1ca22ff932959a6ddfab3046120b8d619647178e9e37957b23539176cee281916e24f23cc6b4fb409b0c58862c0650bf460eb2ee92032c0dbd0a0472e4e25
6
+ metadata.gz: 531ea668cdb58324b8a77c69a4865442473d32bcbb11f88964e5130135eb60a38bc36fed6b339935f7f8f8baad3baa6cc8dfabeb016329e7b9e097a7071621e5
7
+ data.tar.gz: 602b711f8be0b58ec29b0bd695ad93278f1cf0bce962e04c2b35c653b8e5de6b8fd309f283ba0c65584127a20cb31beabe193a258076b10b2ceb1d873f9bd507
data/CHANGELOG.md CHANGED
@@ -13,6 +13,13 @@ Add latest change log entries at top using template:
13
13
  ### Removed
14
14
  -
15
15
  ```
16
+
17
+
18
+ ## Version 1.4.0
19
+
20
+ ### Added
21
+ - New configuration options for caching and logging
22
+
16
23
  ## Version 1.3.1
17
24
 
18
25
  ### Removed
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
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.required_ruby_version = '>= 2.6.0'
27
27
 
28
28
  spec.add_runtime_dependency 'faraday', '~> 1.0'
29
+ spec.add_runtime_dependency 'faraday-http-cache', '~> 2.2'
29
30
 
30
31
  spec.add_development_dependency 'awesome_print'
31
32
  spec.add_development_dependency 'rake', '~> 13.0'
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module LAA
4
4
  module FeeCalculator
5
- VERSION = '1.3.1'
5
+ VERSION = '1.4.0'
6
6
  USER_AGENT = "laa-fee-calculator-client/#{VERSION}"
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.4.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: 2022-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday-http-cache
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.2'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.2'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: awesome_print
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -202,7 +216,7 @@ homepage: https://github.com/ministryofjustice/laa-fee-calculator-client
202
216
  licenses:
203
217
  - MIT
204
218
  metadata: {}
205
- post_install_message:
219
+ post_install_message:
206
220
  rdoc_options: []
207
221
  require_paths:
208
222
  - lib
@@ -217,8 +231,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
231
  - !ruby/object:Gem::Version
218
232
  version: '0'
219
233
  requirements: []
220
- rubygems_version: 3.1.6
221
- signing_key:
234
+ rubygems_version: 3.3.7
235
+ signing_key:
222
236
  specification_version: 4
223
237
  summary: Ruby client for the Legal Aid Agency fee calculator API
224
238
  test_files: []