infreemation 0.1.0 → 0.2.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: ac0ba437d15456f90a07b1d593e7cd27b59b189a5fb341fc36a8f429c61478d6
4
- data.tar.gz: 0beb6bb42829673ed8b7e174b20798d57d6552f3a79ccd0c38f5e9ae957d9332
3
+ metadata.gz: 4beac3e0d172b9b23f9c0aef2fe427d68d07bdc022e107072812dbdbc8053f7b
4
+ data.tar.gz: e6442a04aea433b5db051b48b22ffdbbf7ea8e54f2b7ab593ed10c2f434e0a84
5
5
  SHA512:
6
- metadata.gz: 19cd8059ea1197f3772c200cb92bf6eff2f2109c3e1a9fd70af63195ab385effed9e83b6179fd1210735fe3e4f1d56f1c01698bd6c6b64f313a23b190de51346
7
- data.tar.gz: 88dc1e807c9fd4604188510cc12ad53f3f8b181b6e47e627fc7605d33f72bc2a14406b34eecf04865dc51d173cd9003f01405a173e655203ee3daf2a0b110c4a
6
+ metadata.gz: e4c58d1d3b0c17b3157095fa988c1a725355374e0b5189ba9136cbc39101ac96b0f5e4fe7da8eac43b123aa35611443d928e425d22d0551107aee3a997719299
7
+ data.tar.gz: 9f96a0b6cca8d44d1b23c0a2d9800b4614d731b736d67c018cf53013ee300d252dda38a5ce806da314114a79e4ca12de2d23dfafc6b79ef3f33f9bef38e6f4a8
@@ -0,0 +1,40 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master, develop ]
6
+ pull_request:
7
+ branches: [ master, develop ]
8
+
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby: [2.5, 2.6]
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+
19
+ - uses: actions/cache@v1
20
+ with:
21
+ path: vendor/bundle
22
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
23
+ restore-keys: |
24
+ ${{ runner.os }}-gems-
25
+
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1.29.0
28
+ with:
29
+ ruby-version: ${{ matrix.ruby }}
30
+
31
+ - name: Install gems
32
+ run: |
33
+ bundle config path vendor/bundle
34
+ bundle install --jobs 4 --retry 3
35
+
36
+ - name: Run tests
37
+ env:
38
+ RAILS_ENV: test
39
+ run: |
40
+ bundle exec rake
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- infreemation (0.1.0)
4
+ infreemation (0.2.0)
5
5
  json (~> 2.1.0)
6
6
  rest-client (~> 2.0.2)
7
7
 
@@ -78,4 +78,4 @@ DEPENDENCIES
78
78
  webmock (~> 3.3.0)
79
79
 
80
80
  BUNDLED WITH
81
- 1.16.1
81
+ 1.17.2
@@ -1,4 +1,3 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
3
  lib = File.expand_path('lib', __dir__)
@@ -14,7 +13,7 @@ Gem::Specification.new do |spec|
14
13
  spec.summary = 'Ruby library for the Infreemation API.'
15
14
  spec.description = 'Infreemation is a eCase management software system ' \
16
15
  'built specifically to manage FOI, EIR and SAR requests.'
17
- spec.homepage = 'https://github.com/mysociety/infreemation'
16
+ spec.homepage = 'https://github.com/mysociety/infreemation-ruby'
18
17
  spec.license = 'MIT'
19
18
 
20
19
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the
@@ -47,7 +47,7 @@ module Infreemation
47
47
  raise Errors[data[:ref]], data[:error] if data[:status] == 'ERROR'
48
48
  end
49
49
  rescue JSON::ParserError
50
- raise ResponseError, 'JSON invalid'
50
+ raise ResponseError, "JSON invalid (#{response.body[0...100]})"
51
51
  end
52
52
  end
53
53
  end
@@ -9,39 +9,54 @@ module Infreemation
9
9
  ##
10
10
  # A generic error
11
11
  #
12
- GenericError = Class.new(Exception)
12
+ GenericError = Class.new(RuntimeError)
13
13
 
14
14
  ##
15
- # An API authenication error
15
+ # An API authentication error
16
16
  #
17
- AuthenticationError = Class.new(Exception)
17
+ AuthenticationError = Class.new(RuntimeError)
18
18
 
19
19
  ##
20
20
  # A request error
21
21
  #
22
- RequestError = Class.new(Exception)
22
+ RequestError = Class.new(RuntimeError)
23
23
 
24
24
  ##
25
25
  # A response error
26
26
  #
27
- ResponseError = Class.new(Exception)
27
+ ResponseError = Class.new(RuntimeError)
28
28
 
29
29
  ##
30
30
  # A missing parameter error
31
31
  #
32
- MissingParameterError = Class.new(Exception)
32
+ MissingParameterError = Class.new(RuntimeError)
33
+
34
+ ##
35
+ # An invalid parameter error
36
+ #
37
+ InvalidParameterError = Class.new(RuntimeError)
38
+
39
+ ##
40
+ # A missing or invalid parameter error
41
+ #
42
+ MissingOrInvalidParameterError = Class.new(RuntimeError)
33
43
 
34
44
  ERROR_MAPPINGS = {
35
- 2 => AuthenticationError,
36
- 3 => RequestError,
45
+ 2 => AuthenticationError, # key or username invalid
46
+ 3 => MissingOrInvalidParameterError, # start date
47
+ 4 => InvalidParameterError, # FOI type
37
48
  5 => MissingParameterError, # requester
38
49
  6 => MissingParameterError, # contact
39
50
  7 => MissingParameterError, # contacttype
40
- 8 => MissingParameterError # body
51
+ 8 => MissingParameterError, # body
52
+ 9 => MissingParameterError, # rt
53
+ 10 => AuthenticationError, # key missing
54
+ 11 => AuthenticationError, # username missing
55
+ 12 => RequestError # no data
41
56
  }.freeze
42
57
 
43
58
  ##
44
- # This module is resposible for mapping error codes into the correct type to
59
+ # This module is responsible for mapping error codes into the correct type to
45
60
  # exception class
46
61
  #
47
62
  module Errors
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Infreemation
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infreemation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mySociety
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-09 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -116,9 +116,9 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".github/workflows/ruby.yml"
119
120
  - ".gitignore"
120
121
  - ".rubocop.yml"
121
- - ".travis.yml"
122
122
  - CODE_OF_CONDUCT.md
123
123
  - Gemfile
124
124
  - Gemfile.lock
@@ -133,7 +133,7 @@ files:
133
133
  - lib/infreemation/errors.rb
134
134
  - lib/infreemation/request.rb
135
135
  - lib/infreemation/version.rb
136
- homepage: https://github.com/mysociety/infreemation
136
+ homepage: https://github.com/mysociety/infreemation-ruby
137
137
  licenses:
138
138
  - MIT
139
139
  metadata:
@@ -153,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.7.3
156
+ rubygems_version: 3.0.3
158
157
  signing_key:
159
158
  specification_version: 4
160
159
  summary: Ruby library for the Infreemation API.
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1