jsonapi_errors_handler 0.5.0 → 0.6.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: 31413f8cbc86bedcb155eb0574b6675ab75133b9ca4fec4721e7fc6b96bce447
4
- data.tar.gz: 4d308a155c082df85e91b35d54f0b0c491e7db6905ef756f73493259223fc6b7
3
+ metadata.gz: 55c2d748b194dae4550d9d144eaea9f160963bf8773899edd3740490a4d5b57a
4
+ data.tar.gz: 2210cb76b5c6ed56679b4400565ff4f22e010d0a32d07a88569613cb988bcbb8
5
5
  SHA512:
6
- metadata.gz: 87a8f68e263dbf1c1c7352ae1c5a9ce3294a4bdf4fe00bf1d60356ace9cea210ebf737047b003c183d22408a44f4e7edfa2bb3183f9df5da3c6d90d18a74f385
7
- data.tar.gz: 25e5082f2cceb2f40c50c8ee3d572312b3f6803d3deb0eb7eccf06875451f74a8765e419ac72ce3175a7c95007014919ab47dccd7c399c0d7ead268833c4b2a7
6
+ metadata.gz: 924c83974e1c29171cb43bda43cd666e12dcfb9711e33ade5743d22c06f8b3a1b2702871e3b3c4cb85fa15970040d1899950a3cd7cd8e6f0fd95a56cf23cf953
7
+ data.tar.gz: 4120713b9650d84d940697d8efaf85f49183e2e5fdcbf64b3e3a7a25f57f92398d4a79e115fc4c8baff0cd28428a0eec198997fb89ea9b526f3506fca58103de
@@ -7,18 +7,21 @@ on:
7
7
  jobs:
8
8
  build:
9
9
  name: Build + Publish
10
- runs-on: ubuntu-latest
11
-
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ os: [ubuntu-latest, macos-latest]
14
+ # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
15
+ ruby: [2.7]
16
+ runs-on: ${{ matrix.os }}
12
17
  steps:
13
18
  - uses: actions/checkout@v2
14
- - name: Set up Ruby 2.7.2
15
- uses: actions/setup-ruby@v1
19
+ - uses: ruby/setup-ruby@v1
16
20
  with:
17
- ruby-version: 2.7.2
21
+ ruby-version: ${{ matrix.ruby }}
22
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
18
23
  - name: Run tests
19
- run: |
20
- bundle install
21
- bundle exec rspec
24
+ run: CI=true bundle exec rspec
22
25
  - name: Publish to RubyGems
23
26
  run: |
24
27
  mkdir -p $HOME/.gem
@@ -9,18 +9,33 @@ on:
9
9
  jobs:
10
10
  build:
11
11
  name: Build + Test
12
- runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest]
15
+ # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
16
+ ruby:
17
+ - 2.7
18
+ - '3.0'
19
+ - 3.1
20
+ - head
21
+ - truffleruby
22
+ - truffleruby-head
23
+ # - jruby
24
+ # - jruby-head
25
+ runs-on: ${{ matrix.os }}
26
+ permissions:
27
+ contents: read
28
+ packages: write
13
29
 
14
30
  steps:
15
- - uses: actions/checkout@v2
16
- - name: Set up Ruby 2.7.2
17
- uses: actions/setup-ruby@v1
31
+ - uses: actions/checkout@v3
32
+ - name: Setup Ruby versions
33
+ uses: ruby/setup-ruby@v1
18
34
  with:
19
- ruby-version: 2.7.2
35
+ ruby-version: ${{ matrix.ruby }}
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
20
37
  - name: Run tests
21
- run: |
22
- bundle install
23
- CI=true bundle exec rspec
38
+ run: CI=true bundle exec rspec
24
39
  - name: Upload report
25
40
  run: |
26
41
  mv ./coverage/coverage.xml cobertura.xml
data/Gemfile.lock CHANGED
@@ -1,14 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jsonapi_errors_handler (0.5.0)
4
+ jsonapi_errors_handler (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.4.4)
10
- docile (1.3.2)
10
+ docile (1.4.0)
11
11
  rake (13.0.1)
12
+ rexml (3.2.5)
12
13
  rspec (3.9.0)
13
14
  rspec-core (~> 3.9.0)
14
15
  rspec-expectations (~> 3.9.0)
@@ -22,12 +23,15 @@ GEM
22
23
  diff-lcs (>= 1.2.0, < 2.0)
23
24
  rspec-support (~> 3.9.0)
24
25
  rspec-support (3.9.3)
25
- simplecov (0.18.5)
26
+ simplecov (0.21.2)
26
27
  docile (~> 1.1)
27
28
  simplecov-html (~> 0.11)
28
- simplecov-cobertura (1.4.0)
29
- simplecov (~> 0.8)
30
- simplecov-html (0.12.2)
29
+ simplecov_json_formatter (~> 0.1)
30
+ simplecov-cobertura (2.1.0)
31
+ rexml
32
+ simplecov (~> 0.19)
33
+ simplecov-html (0.12.3)
34
+ simplecov_json_formatter (0.1.4)
31
35
 
32
36
  PLATFORMS
33
37
  ruby
data/README.md CHANGED
@@ -93,7 +93,8 @@ rescue_from ActiveModel::ValidationError, with: lambda { |e| handle_validation_e
93
93
 
94
94
  def handle_validation_error(error)
95
95
  error_model = error.try(:model) || error.try(:record)
96
- mapped = JsonapiErrorsHandler::Errors::Invalid.new(errors: error_model.errors)
96
+ messages = error_model.errors.messages
97
+ mapped = JsonapiErrorsHandler::Errors::Invalid.new(errors: messages)
97
98
  render_error(mapped)
98
99
  end
99
100
  ```
@@ -108,7 +109,7 @@ something unexpected happened.
108
109
 
109
110
  To do so, just implement the `log_error` method in your controller, that accepts the risen error as an argument.
110
111
 
111
- ```
112
+ ```ruby
112
113
  def log_error(error)
113
114
  #do the fancy logging here
114
115
  end
@@ -129,7 +130,7 @@ If you want to have custom error responses being delivered, just create your own
129
130
 
130
131
  If you want to localize your responses, just create a class:
131
132
 
132
- ```
133
+ ```ruby
133
134
  module Api::Errors
134
135
  class Forbidden < ::JsonapiErrorsHandler::Errors::StandardError
135
136
  def initialize(*)
@@ -14,7 +14,7 @@ module JsonapiErrorsHandler
14
14
  def serializable_hash
15
15
  errors.reduce([]) do |r, (att, msg)|
16
16
  r << {
17
- status: status,
17
+ status: status.to_s,
18
18
  title: title,
19
19
  detail: msg,
20
20
  source: { pointer: "/data/attributes/#{att}" }
@@ -20,7 +20,7 @@ module JsonapiErrorsHandler
20
20
 
21
21
  def serializable_hash
22
22
  {
23
- status: status,
23
+ status: status.to_s,
24
24
  title: title,
25
25
  detail: detail,
26
26
  source: source
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonapiErrorsHandler
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end