erratum 3.3.0 → 3.4.0

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
  SHA256:
3
- metadata.gz: e3e6c5faf31997ee03d768c4550dbb14d18e7aaa603071bc4cb49f2224fc42e7
4
- data.tar.gz: bd9de11bb451c959ae4de0717f4ad29691bb72a092111180bda53b78e138d3fc
3
+ metadata.gz: 2c03afae3ce08c9038812d6cb19326d2f3c3d0e185062cd94eceeb771c4dc63f
4
+ data.tar.gz: 8fd6c2d638e1ce482539b58ecb255e4c16164d7ca395074b65d24876aa9a1623
5
5
  SHA512:
6
- metadata.gz: f7073c9d975cb2de901082f0b2d64f1d2068ba19d2c9e1a9505ba07ae348e7057848e0964d50ded7c1d55bb8fb3ff6447de567a347e6541c63cd57fb77bdf4ab
7
- data.tar.gz: 5a18d081d56259c87a948a207c29d4952f82426f2dd615deca753900dc077ff19726b8cddbe2fc453d4502f6ceadbac841aba94f5ed6853c4008da7022fe0f15
6
+ metadata.gz: 94c8bc09f9dd42b01803458c44e746ff30750c52963304238e6905dc56f2c4416a72c98032982c2d0da3bdc7c99bd739c15162c98ee1fd570b34222613899cd4
7
+ data.tar.gz: 83298f560fe88d1b7549ab97732a1743594a02f3a2fc626650b7eb0bb09e70c8107f48d0f0370b8a1667e2556f4d6e96435000ef8a85b39277b3d9fe8df4d296
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -15,10 +15,18 @@ module Crud
15
15
  super(**args)
16
16
  end
17
17
 
18
+ def source
19
+ {
20
+ 'action' => action,
21
+ 'resource_name' => resource_name_underscored,
22
+ 'resource_id' => resource_id,
23
+ }
24
+ end
25
+
18
26
  private
19
27
 
20
28
  def resource_name_underscored
21
- @resource_name_underscored ||= resource_name.gsub(/\s/, '_')
29
+ @resource_name_underscored ||= resource_name&.gsub(/\s/, '_')
22
30
  end
23
31
  end
24
32
  end
@@ -51,11 +51,11 @@ class AttributeLength < RuntimeError
51
51
  end
52
52
 
53
53
  def source
54
- {
54
+ super.merge(
55
55
  'pointer' => pointer,
56
56
  'parameter' => attribute,
57
57
  'length' => length,
58
- }
58
+ )
59
59
  end
60
60
  end
61
61
  end
@@ -10,18 +10,18 @@ class InvalidAssociation < RuntimeError
10
10
  include Errors::Crud
11
11
 
12
12
  attr_accessor :association_name,
13
- :association_id,
14
- :attributes
13
+ :association_id
15
14
 
16
15
  def self.convert(original_error, overrides = {})
17
16
  initialization_parameters = {}
18
17
 
19
18
  case original_error.class.name
20
19
  when 'ActiveRecord::InvalidForeignKey'
21
- message_info_pattern = /DETAIL: Key \((.*)_id\)=\(([a-f0-9\-]+)\)/
20
+ message_info_pattern = /DETAIL: Key \((.*?)(?:_id)?\)=\(([a-f0-9\-]+)\)/
22
21
  message_info = original_error
23
22
  .message
24
- .match(message_info_pattern)[1..-1]
23
+ .match(message_info_pattern)
24
+ .captures
25
25
 
26
26
  initialization_parameters = {
27
27
  association_name: message_info[0],
@@ -41,17 +41,24 @@ class InvalidAssociation < RuntimeError
41
41
  end
42
42
 
43
43
  def detail
44
- <<~HEREDOC.chomp.tr("\n", ' ')
45
- The #{association_name} that you attempted to associate with the
46
- #{resource_name} was not valid.
47
- HEREDOC
44
+ if association_name == 'id'
45
+ <<~HEREDOC.chomp.tr("\n", ' ')
46
+ You cannot #{action} this #{resource_name} because its
47
+ #{association_name} is still being referenced by other things.
48
+ HEREDOC
49
+ else
50
+ <<~HEREDOC.chomp.tr("\n", ' ')
51
+ The #{association_name} that you attempted to associate with the
52
+ #{resource_name} was not valid.
53
+ HEREDOC
54
+ end
48
55
  end
49
56
 
50
57
  def source
51
- {
52
- resource_name => attributes,
53
- "#{association_name} id" => association_id,
54
- }
58
+ super.merge(
59
+ 'association' => association_name,
60
+ 'association_id' => association_id,
61
+ )
55
62
  end
56
63
  end
57
64
  end
@@ -9,13 +9,15 @@ class ResourceNotFound < RuntimeError
9
9
  include Error
10
10
  include Errors::Crud
11
11
 
12
+ attr_accessor :missing_ids
13
+
12
14
  def self.convert(original_error, overrides = {})
13
15
  initialization_parameters = {}
14
16
 
15
17
  case original_error.class.name
16
18
  when 'ActiveRecord::RecordNotFound'
17
19
  initialization_parameters = {
18
- resource_id: case original_error.message
20
+ missing_ids: case original_error.message
19
21
  when /\ACouldn't find .* without an ID\z/
20
22
  []
21
23
  when /\ACouldn't find .* with \'.*\'=([a-f0-9\-]+)/
@@ -45,7 +47,9 @@ class ResourceNotFound < RuntimeError
45
47
  end
46
48
 
47
49
  def source
48
- { "#{resource_name_underscored}_id" => resource_id }
50
+ super.merge(
51
+ 'missing_ids' => missing_ids,
52
+ )
49
53
  end
50
54
 
51
55
  def action
@@ -50,11 +50,11 @@ class ResourceNotUnique < RuntimeError
50
50
  end
51
51
 
52
52
  def source
53
- {
53
+ super.merge(
54
54
  'pointer' => pointer,
55
55
  'parameter' => attribute,
56
56
  'value' => value,
57
- }
57
+ )
58
58
  end
59
59
  end
60
60
  end
@@ -62,11 +62,11 @@ class ResourcePersistence < RuntimeError
62
62
  end
63
63
 
64
64
  def source
65
- {
65
+ super.merge(
66
66
  'pointer' => pointer,
67
67
  'parameter' => attribute,
68
68
  'value' => value,
69
- }
69
+ )
70
70
  end
71
71
  end
72
72
  end
@@ -40,9 +40,9 @@ class ParameterMissing < RuntimeError
40
40
  end
41
41
 
42
42
  def source
43
- {
43
+ super.merge(
44
44
  'required_parameter' => parameter,
45
- }
45
+ )
46
46
  end
47
47
  end
48
48
  end
@@ -44,9 +44,9 @@ class UnpermittedParameters < RuntimeError
44
44
  end
45
45
 
46
46
  def source
47
- {
47
+ super.merge(
48
48
  'unpermitted_parameters' => parameters,
49
- }
49
+ )
50
50
  end
51
51
  end
52
52
  end
@@ -20,6 +20,7 @@ module RescuableResource
20
20
  Erratum.build(
21
21
  exception,
22
22
  resource_name: self.class.singular_underscored_base_resource_name,
23
+ resource_id: params[:id],
23
24
  action: action_name,
24
25
  ),
25
26
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Erratum
4
- VERSION = '3.3.0'
4
+ VERSION = '3.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erratum
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -31,7 +31,7 @@ cert_chain:
31
31
  Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
32
32
  iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
33
33
  -----END CERTIFICATE-----
34
- date: 2018-05-26 00:00:00.000000000 Z
34
+ date: 2018-05-27 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: apple_core
metadata.gz.sig CHANGED
Binary file