glimr-api-client 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d090c08e733fa1980327591baf348705a15ef1a
4
- data.tar.gz: 7f0fc6d4e7940a860a92e7b551520a29c7692b35
3
+ metadata.gz: a95379c7f68eb8bfdfa5a18fe3d28d1f540bdfd0
4
+ data.tar.gz: da42193aea4ccd8b6488f4170890a7ae63a4e273
5
5
  SHA512:
6
- metadata.gz: 3f3bd5682bec9f2c78a9c299b22847532d93f0dd35c2a43891d9e9b3a4811fb99b117f232f4dde2a0cf93c274e229ab091a3c90c87a7b5b5aab05998c272ca9c
7
- data.tar.gz: 489f72535fda5e5e17f8ea2a8040690df0c0bc23091bdb1e31625ba8fcb02d0346865f0f25ba67a245b8afa65f0ba0877befa9c7db026a98b70ebe7957c0999d
6
+ metadata.gz: 4b883fe2a22fa59cde745fa11c8b18131b45d73fe4e2bcabf2bbcc1ffa729a3985f8115c8d36558803328093e6ba99a34b230da1c15021959c1c1160921f5708
7
+ data.tar.gz: 25564435a7cfe5f88e7dfef8e2a5e61912b2749282d66a7ab15479407ef4b17deb0752a5094d6e194c89c6c1426449e6f8943843df8b158ed4de220265fc8574
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- glimr-api-client (0.1.3)
4
+ glimr-api-client (0.1.4)
5
+ activesupport (~> 5.0)
5
6
  excon (~> 0.51)
6
7
 
7
8
  GEM
@@ -75,7 +76,7 @@ GEM
75
76
  docile (1.1.5)
76
77
  equalizer (0.0.11)
77
78
  erubis (2.7.0)
78
- excon (0.52.0)
79
+ excon (0.54.0)
79
80
  fuubar (2.0.0)
80
81
  rspec (~> 3.0)
81
82
  ruby-progressbar (~> 1.4)
@@ -249,4 +250,4 @@ DEPENDENCIES
249
250
  sqlite3 (~> 1.3)
250
251
 
251
252
  BUNDLED WITH
252
- 1.12.5
253
+ 1.13.3
data/README.md CHANGED
@@ -7,6 +7,12 @@ use in various UK tribunals.
7
7
 
8
8
  ## Usage
9
9
 
10
+ ### Configuration
11
+
12
+ The gem expects a `GLIMR_API_URL` environment variable, providing the endpoint at which the API can be found. This will be something like; `https://glimr-api.taxtribunals.dsd.io`
13
+
14
+ This URL must be accessible from wherever your code is running.
15
+
10
16
  ### Check Availablity
11
17
 
12
18
  ```ruby
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'sqlite3', '~> 1.3'
28
28
 
29
29
  spec.add_dependency 'excon', '~> 0.51'
30
+ spec.add_dependency 'activesupport', '~> 5.0'
30
31
  end
@@ -1,3 +1,7 @@
1
+ require 'excon'
2
+ require 'active_support'
3
+ require 'active_support/core_ext/object/to_query'
4
+
1
5
  module GlimrApiClient
2
6
  module Api
3
7
 
@@ -7,13 +11,12 @@ module GlimrApiClient
7
11
  # Only timeouts and network issues raise errors.
8
12
  handle_response_errors(resp)
9
13
  @body = resp.body
10
- @status = resp.status
11
14
  }
12
15
  rescue Excon::Error => e
13
- if endpoint == '/paymenttaken'
14
- raise GlimrApiClient::PaymentNotificationFailure, e
16
+ if endpoint.eql?('/paymenttaken')
17
+ raise PaymentNotificationFailure, e
15
18
  else
16
- raise GlimrApiClient::Unavailable, e
19
+ raise Unavailable, e
17
20
  end
18
21
  end
19
22
 
@@ -24,12 +27,14 @@ module GlimrApiClient
24
27
  private
25
28
 
26
29
  def handle_response_errors(resp)
27
- if resp.status == 404
28
- raise GlimrApiClient::CaseNotFound
29
- elsif (400..599).cover?(resp.status) && endpoint == '/paymenttaken'
30
- raise GlimrApiClient::PaymentNotificationFailure, resp.status
30
+ if (!endpoint.eql?('/paymenttaken') && resp.status.equal?(404))
31
+ raise CaseNotFound, resp.status
31
32
  elsif (400..599).cover?(resp.status)
32
- raise GlimrApiClient::Unavailable, resp.status
33
+ if endpoint.eql?('/paymenttaken')
34
+ raise PaymentNotificationFailure, resp.status
35
+ else
36
+ raise Unavailable, resp.status
37
+ end
33
38
  end
34
39
  end
35
40
 
@@ -40,7 +45,8 @@ module GlimrApiClient
40
45
  'Content-Type' => 'application/json',
41
46
  'Accept' => 'application/json'
42
47
  },
43
- persistent: true
48
+ persistent: true,
49
+ connect_timeout: 15
44
50
  )
45
51
  end
46
52
  end
@@ -1,10 +1,9 @@
1
1
  module GlimrApiClient
2
2
  class Available
3
3
  include GlimrApiClient::Api
4
+ extend SingleForwardable
4
5
 
5
- class << self
6
- delegate :call, to: :new
7
- end
6
+ def_delegator :new, :call
8
7
 
9
8
  def call
10
9
  post
@@ -1,3 +1,3 @@
1
1
  module GlimrApiClient
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -1,49 +1,9 @@
1
1
  task :mutant do
2
- classes_to_mutate.each do |klass|
3
- vars = 'NOCOVERAGE=true'
4
- flags = '--include lib --use rspec'
5
- unless system("#{vars} mutant #{flags} #{klass}")
6
- raise 'Mutation testing failed'
7
- end
2
+ vars = 'NOCOVERAGE=true'
3
+ flags = '--include lib --use rspec --fail-fast'
4
+ unless system("#{vars} mutant #{flags} GlimrApiClient*")
5
+ raise 'Mutation testing failed'
8
6
  end
9
7
  end
10
8
 
11
9
  task(:default).prerequisites << task(:mutant)
12
-
13
- private
14
-
15
- def classes_to_mutate
16
- files = grep_files_for_classes
17
- klasses = extract_classes_for_mutation(files)
18
- klasses.map { |k|
19
- setup_class_for_run(k)
20
- }
21
- end
22
-
23
- # This is a nasty hack because we’re using POROs; otherwise, we could just use
24
- # ApplicationRecord.descendants...
25
- #
26
- # Grepping through the source code seemed to be the most pragmatic solution
27
- # so that developers don’t need to remember to add new classes to a list for
28
- # mutation testing, but it’s not ideal
29
- def grep_files_for_classes
30
- Dir.glob('lib/**/*.rb').
31
- map { |f|
32
- # There are some examples of `class << self` in codebase.
33
- File.readlines(f).grep(/\bclass(?!\s<<)/)
34
- }.flatten
35
- end
36
-
37
- def extract_classes_for_mutation(files)
38
- re = /class (?<klass>\w+)/
39
-
40
- files.map { |s|
41
- re.match(s)[:klass]
42
- }.compact
43
- end
44
-
45
- def setup_class_for_run(klass)
46
- Object.const_get(klass)
47
- rescue NameError
48
- Object.const_get("GlimrApiClient::#{klass}")
49
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimr-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Tyree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-12 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.51'
181
+ - !ruby/object:Gem::Dependency
182
+ name: activesupport
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '5.0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '5.0'
181
195
  description:
182
196
  email:
183
197
  - todd.tyree@digital.justice.gov.uk
@@ -225,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
239
  version: '0'
226
240
  requirements: []
227
241
  rubyforge_project:
228
- rubygems_version: 2.6.6
242
+ rubygems_version: 2.5.1
229
243
  signing_key:
230
244
  specification_version: 4
231
245
  summary: Easy integration with the glimr case management system