rescue_registry 0.2.3 → 1.0.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: 76e7d0f44e4a1b8dc8f91e8b7c33fceac13b70740dfc3452d127a25e59e49be1
4
- data.tar.gz: 78f018ba46f97c5fd6ad04883f83b9755e18d653d9a638ebd0d863d23b49ce26
3
+ metadata.gz: 3575942ac21357ea65531cb89bf233d75a2dc983d220f279cc5c5ebac0c6c3be
4
+ data.tar.gz: c3c3a52aa8fe8ed34d66fe0b03062282793a24c0df69c456ef92afca1e0e7f8d
5
5
  SHA512:
6
- metadata.gz: 853839cefe3949aaf86ba208bb6d65b9d0646399f1ca437110e13dd07faf0939f2abf54a17d161831e8faac5362142776dbdcc2906c15ecc79aaec061304cd54
7
- data.tar.gz: 697b515d046f7b5033790535158a6ce085d10a69ba694a34ea14054441c5d54a6a4349237a2b32e75dcf9c4b0474314a72773b48a0446125053db75acb93d345
6
+ metadata.gz: add3e437decc5c77801e74e2a1d3f5330122a142578c6133e57eae884d638323e35a984dcbcfa0e6e3845d21680675e08a0f5f0d82e4f4cfec8afacb76e08842
7
+ data.tar.gz: 50dc6cc1cdb148cc22590b1854f9f6d285c6a7a693ad4b4fc4e6711e2058632854aad07d0b118e7a0231d514241616faea48296b6c707be71222586e3249c2e2
data/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ ## [1.0.0] - 2022-02-03
11
+ ### Changed
12
+ - Removed upper version bound to support Ruby 3.1. (thanks @nulldotpro)
13
+
14
+ ## [0.3.0] - 2021-05-11
15
+ ### Changed
16
+ - For better JSONAPI spec compliance, errors payloads will not include the `details` key when value is `null`.
17
+ - Error payloads will not include the `meta` key when value is an empty object.
18
+
19
+ ## [0.2.5] - 2021-03-09
20
+ ### Added
21
+ - `code` can now be provided as an argument to `register_exception` - #29 (thanks @amaierhofer)
22
+
23
+ ## [0.2.4] - 2021-01-22
24
+ ### Fixed
25
+ - Support Ruby 3 (thanks @zvkemp and @ef4)
26
+
10
27
  ## [0.2.3] - 2020-09-01
11
28
  ### Fixed
12
29
  - Properly handle exceptions for invalid format types - #25 (thanks @shanet)
data/README.md CHANGED
@@ -58,6 +58,7 @@ class MyController < ActionController::Base
58
58
  register_exception MetaProcError, meta: -> (e) { { class_name: e.class.name.upcase } }
59
59
  register_exception CustomHandlerError, handler: CustomErrorHandler
60
60
  register_exception RailsError, status: 403, handler: RescueRegistry::RailsExceptionHandler
61
+ register_exception CustomStatusError, status: 422, code: :name_invalid
61
62
  end
62
63
  ```
63
64
 
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
+ require 'rails/version'
7
8
  require 'yard'
8
9
  require 'rspec/core/rake_task'
9
10
  require 'bundler/gem_tasks'
@@ -14,7 +15,11 @@ RSpec::Core::RakeTask.new(:spec) do |t|
14
15
  t.rspec_opts = "--order random"
15
16
  end
16
17
 
17
- APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
+ if Rails::VERSION::MAJOR < 7
19
+ APP_RAKEFILE = File.expand_path("spec/rails5/dummy/Rakefile", __dir__)
20
+ else
21
+ APP_RAKEFILE = File.expand_path("spec/rails7/dummy/Rakefile", __dir__)
22
+ end
18
23
  load "rails/tasks/engine.rake"
19
24
 
20
25
  task default: :spec
@@ -21,6 +21,7 @@ module RescueRegistry
21
21
  end
22
22
 
23
23
  @meta = options[:meta]
24
+ @code = options[:code]
24
25
 
25
26
  # TODO: Warn about unrecognized options
26
27
  end
@@ -29,7 +30,7 @@ module RescueRegistry
29
30
  alias_method :status_code, :status
30
31
 
31
32
  def error_code
32
- error_code_from_status
33
+ @code.presence || error_code_from_status
33
34
  end
34
35
 
35
36
  def title
@@ -74,14 +75,20 @@ module RescueRegistry
74
75
  )
75
76
  end
76
77
 
78
+ error_payload = {
79
+ code: error_code,
80
+ status: status_code.to_s,
81
+ title: title
82
+ }
83
+
84
+ if (d = detail)
85
+ error_payload[:detail] = d
86
+ end
87
+
88
+ error_payload[:meta] = payload_meta if payload_meta.any?
89
+
77
90
  {
78
- errors: [
79
- code: error_code,
80
- status: status_code.to_s,
81
- title: title,
82
- detail: detail,
83
- meta: payload_meta
84
- ]
91
+ errors: [error_payload]
85
92
  }
86
93
  end
87
94
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RescueRegistry
4
- VERSION = "0.2.3"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -46,6 +46,18 @@ module RescueRegistry
46
46
  context.rescue_registry.public_send(method, *args)
47
47
  end
48
48
  end
49
+
50
+ # the Module#ruby2_keywords is added starting at ruby 2.7. It lets us mark
51
+ # these methods as using ruby2-style keyword argument semantics. This will
52
+ # keep them working correctly on ruby3, and clears a deprecation that
53
+ # otherwise fires in 2.7+.
54
+ if respond_to?(:ruby2_keywords, true)
55
+ class << self
56
+ REGISTRY_METHODS.each do |method|
57
+ ruby2_keywords(method)
58
+ end
59
+ end
60
+ end
49
61
  end
50
62
 
51
63
  ActiveSupport.on_load(:before_initialize) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rescue_registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Wagenet
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.9'
83
- description:
83
+ description:
84
84
  email:
85
85
  - peter.wagenet@gmail.com
86
86
  executables: []
@@ -114,13 +114,13 @@ metadata:
114
114
  bug_tracker_uri: https://github.com/wagenet/rescue_registry/issues
115
115
  changelog_uri: https://github.com/wagenet/rescue_registry/CHANGELOG.md
116
116
  source_code_uri: https://github.com/wagenet/rescue_registry
117
- post_install_message:
117
+ post_install_message:
118
118
  rdoc_options: []
119
119
  require_paths:
120
120
  - lib
121
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - "~>"
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '2.3'
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -129,8 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.1.2
133
- signing_key:
132
+ rubygems_version: 3.3.3
133
+ signing_key:
134
134
  specification_version: 4
135
135
  summary: Registry for Rails Exceptions
136
136
  test_files: []