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 +4 -4
- data/.github/workflows/ruby.yml +40 -0
- data/Gemfile.lock +2 -2
- data/infreemation.gemspec +1 -2
- data/lib/infreemation/api.rb +1 -1
- data/lib/infreemation/errors.rb +25 -10
- data/lib/infreemation/version.rb +1 -1
- metadata +5 -6
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4beac3e0d172b9b23f9c0aef2fe427d68d07bdc022e107072812dbdbc8053f7b
|
4
|
+
data.tar.gz: e6442a04aea433b5db051b48b22ffdbbf7ea8e54f2b7ab593ed10c2f434e0a84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/Gemfile.lock
CHANGED
data/infreemation.gemspec
CHANGED
@@ -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
|
data/lib/infreemation/api.rb
CHANGED
data/lib/infreemation/errors.rb
CHANGED
@@ -9,39 +9,54 @@ module Infreemation
|
|
9
9
|
##
|
10
10
|
# A generic error
|
11
11
|
#
|
12
|
-
GenericError = Class.new(
|
12
|
+
GenericError = Class.new(RuntimeError)
|
13
13
|
|
14
14
|
##
|
15
|
-
# An API
|
15
|
+
# An API authentication error
|
16
16
|
#
|
17
|
-
AuthenticationError = Class.new(
|
17
|
+
AuthenticationError = Class.new(RuntimeError)
|
18
18
|
|
19
19
|
##
|
20
20
|
# A request error
|
21
21
|
#
|
22
|
-
RequestError = Class.new(
|
22
|
+
RequestError = Class.new(RuntimeError)
|
23
23
|
|
24
24
|
##
|
25
25
|
# A response error
|
26
26
|
#
|
27
|
-
ResponseError = Class.new(
|
27
|
+
ResponseError = Class.new(RuntimeError)
|
28
28
|
|
29
29
|
##
|
30
30
|
# A missing parameter error
|
31
31
|
#
|
32
|
-
MissingParameterError = Class.new(
|
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 =>
|
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
|
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
|
59
|
+
# This module is responsible for mapping error codes into the correct type to
|
45
60
|
# exception class
|
46
61
|
#
|
47
62
|
module Errors
|
data/lib/infreemation/version.rb
CHANGED
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.
|
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:
|
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
|
-
|
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.
|