laa-fee-calculator-client 1.3.0 → 1.3.1

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: a6720e8d64a0423da427ccaec75a0bbd5bacca65634fca113ff4863a277b0065
4
- data.tar.gz: 8a1e9ad3aca5a391316c5825e8c47296b98fc1d15a96a75cd3ec93087e40c870
3
+ metadata.gz: 846930f03ac36c9166dcba3a25cc3b2b552f32b31861043fa1908741912da754
4
+ data.tar.gz: 3b5ec2435a93a7584eff62facedf12a8ab3c754f6f83bcabc625b1ef8fc96c07
5
5
  SHA512:
6
- metadata.gz: a10006fdb40c4c1749031e500848c349fdc4e24cdc66c71384c1729a2d8ae63a7eaad15ac5ec32888df7ee17c0dc7bd9390a914f14b959f272adc106656cc7e5
7
- data.tar.gz: 85b5c5aeb923f0014fee35043938fea0e239db55334f65bbfda20910202407a4a97ffd4a0cfda8f709e7c21cd28b0e6af6377846d82e6d07684da69309adaf25
6
+ metadata.gz: 953bba0d471745c2502a7dc9b0d7cc21c1a58fae009ce09777d419b4a9cc7177b25593d90476ed3536b2f17092b2f124336090dd6c600b7567021dc0f2d26113
7
+ data.tar.gz: 44e1ca22ff932959a6ddfab3046120b8d619647178e9e37957b23539176cee281916e24f23cc6b4fb409b0c58862c0650bf460eb2ee92032c0dbd0a0472e4e25
data/CHANGELOG.md CHANGED
@@ -12,8 +12,12 @@ Add latest change log entries at top using template:
12
12
  -
13
13
  ### Removed
14
14
  -
15
-
16
15
  ```
16
+ ## Version 1.3.1
17
+
18
+ ### Removed
19
+ - `addressable` gem dependency
20
+
17
21
  ## Version 1.3.0
18
22
 
19
23
  ### Modified
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
data/README.md CHANGED
@@ -177,13 +177,11 @@ Bug reports and pull requests are welcome on GitHub at [ministryofjustice/laa-fe
177
177
 
178
178
  3. Update the VERSION in `lib/laa/fee_calculator/version` using [semantic versioning](https://guides.rubygems.org/patterns/#semantic-versioning).
179
179
 
180
- 4. Update the VERSION_RELEASED in `lib/laa/fee_calculator/version` to the date you intend to publish/release the version.
180
+ 4. Update the `CHANGELOG.md` - format/documentation standards specified at top of file.
181
181
 
182
- 5. Update the `CHANGELOG.md` - format/documentation standards specified at top of file.
182
+ 5. PR the change, code-review, merge.
183
183
 
184
- 6. PR the change, code-review, merge.
185
-
186
- 7. Pull master and run rake task below to publish. Note, you will need a [rubygems](https://rubygems.org/) account with gem owner privileges and have configured your `~/.gem/credentials` in order for this task to complete successfully.
184
+ 6. Pull master and run rake task below to publish. Note, you will need a [rubygems](https://rubygems.org/) account with gem owner privileges and have configured your `~/.gem/credentials` in order for this task to complete successfully.
187
185
 
188
186
  ```bash
189
187
  $ rake release
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
  require 'rubocop/rake_task'
6
6
 
7
7
  RSpec::Core::RakeTask.new(:spec)
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "bundler/setup"
5
- require "laa/fee_calculator"
4
+ require 'bundler/setup'
5
+ require 'laa/fee_calculator'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -16,5 +16,5 @@ LAA::FeeCalculator.configure do |config|
16
16
  config.host = 'http://localhost:8000/api/v1'
17
17
  end
18
18
 
19
- require "irb"
19
+ require 'irb'
20
20
  IRB.start(__FILE__)
@@ -9,12 +9,11 @@ Gem::Specification.new do |spec|
9
9
  spec.version = LAA::FeeCalculator::VERSION
10
10
  spec.authors = ['Katharine Ahern', 'Ministry of Justice']
11
11
  spec.email = ['katharine.ahern@digital.justice.gov.uk', 'joel.sugarman@digital.justice.gov.uk', 'tools@digital.justice.gov.uk']
12
- spec.date = LAA::FeeCalculator::VERSION_RELEASED
13
12
  spec.summary = 'Ruby client for the Legal Aid Agency fee calculator API'
14
- spec.description = "Ruby client for the Ministry of Justices LAA fee calculator API. A simple interface for transparent calling of the API endpoints to query data and return calculated fee amounts."
13
+ spec.description = 'Ruby client for the Ministry of Justices LAA fee calculator API. A simple interface for transparent calling of the API endpoints to query data and return calculated fee amounts.'
15
14
  spec.homepage = 'https://github.com/ministryofjustice/laa-fee-calculator-client'
16
15
  spec.license = 'MIT'
17
- spec.extra_rdoc_files = ["LICENSE", "README.md"]
16
+ spec.extra_rdoc_files = ['LICENSE', 'README.md']
18
17
 
19
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
19
  f.match(%r{^(test/|spec/|features/|\..*)})
@@ -26,14 +25,16 @@ Gem::Specification.new do |spec|
26
25
  # see bin/ruby_version_test
27
26
  spec.required_ruby_version = '>= 2.6.0'
28
27
 
29
- spec.add_runtime_dependency 'addressable', '~> 2.3', '>= 2.3.7'
30
28
  spec.add_runtime_dependency 'faraday', '~> 1.0'
31
29
 
32
30
  spec.add_development_dependency 'awesome_print'
33
31
  spec.add_development_dependency 'rake', '~> 13.0'
34
32
  spec.add_development_dependency 'rb-readline'
35
33
  spec.add_development_dependency 'rspec', '~> 3.0'
36
- spec.add_development_dependency 'rubocop', '~> 0.78'
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'
37
38
  spec.add_development_dependency 'vcr'
38
39
  spec.add_development_dependency 'webmock'
39
40
  end
@@ -6,25 +6,18 @@ module LAA
6
6
  extend Forwardable
7
7
  def_delegators :connection, :get
8
8
 
9
- attr_reader :scheme_pk, :options
10
-
11
9
  def initialize(scheme_pk, options)
12
- @scheme_pk = scheme_pk
13
- @options = options
10
+ @uri = "fee-schemes/#{scheme_pk}/calculate/"
11
+ @filtered_params = options.reject { |k, _v| k.eql?(:id) }
14
12
  end
15
13
 
16
14
  def call
17
- uri.query_values = options.reject { |k, _v| k.eql?(:id) }
18
- json = get(uri).body
15
+ json = get(@uri, @filtered_params).body
19
16
  JSON.parse(json)['amount']
20
17
  end
21
18
 
22
19
  private
23
20
 
24
- def uri
25
- @uri ||= Addressable::URI.parse("fee-schemes/#{scheme_pk}/calculate/")
26
- end
27
-
28
21
  def connection
29
22
  @connection ||= Connection.instance
30
23
  end
@@ -1,4 +1,4 @@
1
- require "addressable/uri"
1
+ # frozen_string_literal: true
2
2
 
3
3
  module LAA
4
4
  module FeeCalculator
@@ -17,13 +17,11 @@ module LAA
17
17
  end
18
18
 
19
19
  def fee_schemes(id = nil, **options)
20
- uri = 'fee-schemes/'
21
- id ||= options.fetch(:id, nil)
22
- uri.concat(id.to_s, "/") if id
23
- uri = Addressable::URI.parse(uri)
24
- uri.query_values = options.reject { |k, _v| k.eql?(:id) }
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)
25
23
 
26
- json = get(uri).body
24
+ json = get(uri, filtered_params).body
27
25
 
28
26
  fstruct = JSON.parse(json, object_class: FeeScheme)
29
27
  return fstruct unless fstruct.respond_to?(:results)
@@ -31,6 +29,14 @@ module LAA
31
29
 
32
30
  fstruct.results
33
31
  end
32
+
33
+ private
34
+
35
+ def fee_schemes_uri(id)
36
+ return "fee-schemes/#{id}/" if id
37
+
38
+ 'fee-schemes/'
39
+ end
34
40
  end
35
41
  end
36
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module LAA
@@ -17,18 +19,11 @@ module LAA
17
19
  end
18
20
 
19
21
  def has_many(association)
20
- define_method("#{association}_uri".to_sym) do |scheme_pk = nil, id = nil|
21
- uri = scheme_pk.nil? ? "#{association.to_s.tr('_', '-')}/" : "fee-schemes/#{scheme_pk}/#{association.to_s.tr('_', '-')}/"
22
- uri = uri.concat(id.to_s, '/') unless id.nil?
23
- Addressable::URI.parse(uri)
24
- end
25
-
26
22
  define_method(association) do |id = nil, **options|
27
- id ||= options&.fetch(:id, nil)
28
- uri = self.send("#{association}_uri", self.id, id)
29
- uri.query_values = options.reject { |k, _v| k.eql?(:id) }
23
+ uri = uri_for(association, id: id || options[:id])
24
+ filtered_params = options.reject { |k, _v| k.eql?(:id) }
30
25
 
31
- json = get(uri).body
26
+ json = get(uri, filtered_params).body
32
27
 
33
28
  ostruct = JSON.parse(json, object_class: OpenStruct)
34
29
  return ostruct unless ostruct.respond_to?(:results)
@@ -37,6 +32,16 @@ module LAA
37
32
  end
38
33
  end
39
34
  end
35
+
36
+ def uri_for(association, id: nil)
37
+ return "#{base_fee_scheme_uri}#{association.to_s.tr('_', '-')}/" if id.nil?
38
+
39
+ "#{base_fee_scheme_uri}#{association.to_s.tr('_', '-')}/#{id}/"
40
+ end
41
+
42
+ def base_fee_scheme_uri
43
+ id ? "fee-schemes/#{id}/" : ''
44
+ end
40
45
  end
41
46
  end
42
47
  end
@@ -2,8 +2,7 @@
2
2
 
3
3
  module LAA
4
4
  module FeeCalculator
5
- VERSION = "1.3.0"
6
- VERSION_RELEASED = "2022-04-21"
5
+ VERSION = '1.3.1'
7
6
  USER_AGENT = "laa-fee-calculator-client/#{VERSION}"
8
7
  end
9
8
  end
@@ -12,7 +12,7 @@ module LAA
12
12
  module FeeCalculator
13
13
  class << self
14
14
  def root
15
- spec = Gem::Specification.find_by_name("laa-fee-calculator-client")
15
+ spec = Gem::Specification.find_by_name('laa-fee-calculator-client')
16
16
  spec.gem_dir
17
17
  end
18
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laa-fee-calculator-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katharine Ahern
@@ -9,28 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-04-21 00:00:00.000000000 Z
12
+ date: 2022-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: addressable
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '2.3'
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.3.7
24
- type: :runtime
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- requirements:
28
- - - "~>"
29
- - !ruby/object:Gem::Version
30
- version: '2.3'
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.3.7
34
14
  - !ruby/object:Gem::Dependency
35
15
  name: faraday
36
16
  requirement: !ruby/object:Gem::Requirement
@@ -107,14 +87,56 @@ dependencies:
107
87
  requirements:
108
88
  - - "~>"
109
89
  - !ruby/object:Gem::Version
110
- version: '0.78'
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'
111
133
  type: :development
112
134
  prerelease: false
113
135
  version_requirements: !ruby/object:Gem::Requirement
114
136
  requirements:
115
137
  - - "~>"
116
138
  - !ruby/object:Gem::Version
117
- version: '0.78'
139
+ version: '2.10'
118
140
  - !ruby/object:Gem::Dependency
119
141
  name: vcr
120
142
  requirement: !ruby/object:Gem::Requirement
@@ -195,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
217
  - !ruby/object:Gem::Version
196
218
  version: '0'
197
219
  requirements: []
198
- rubygems_version: 3.1.4
220
+ rubygems_version: 3.1.6
199
221
  signing_key:
200
222
  specification_version: 4
201
223
  summary: Ruby client for the Legal Aid Agency fee calculator API