erratum 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/erratum/errors/crud.rb +9 -1
- data/lib/erratum/errors/crud/attribute_length.rb +2 -2
- data/lib/erratum/errors/crud/invalid_association.rb +19 -12
- data/lib/erratum/errors/crud/resource_not_found.rb +6 -2
- data/lib/erratum/errors/crud/resource_not_unique.rb +2 -2
- data/lib/erratum/errors/crud/resource_persistence.rb +2 -2
- data/lib/erratum/errors/request/parameter_missing.rb +2 -2
- data/lib/erratum/errors/request/unpermitted_parameters.rb +2 -2
- data/lib/erratum/rescuable_resource.rb +1 -0
- data/lib/erratum/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c03afae3ce08c9038812d6cb19326d2f3c3d0e185062cd94eceeb771c4dc63f
|
4
|
+
data.tar.gz: 8fd6c2d638e1ce482539b58ecb255e4c16164d7ca395074b65d24876aa9a1623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94c8bc09f9dd42b01803458c44e746ff30750c52963304238e6905dc56f2c4416a72c98032982c2d0da3bdc7c99bd739c15162c98ee1fd570b34222613899cd4
|
7
|
+
data.tar.gz: 83298f560fe88d1b7549ab97732a1743594a02f3a2fc626650b7eb0bb09e70c8107f48d0f0370b8a1667e2556f4d6e96435000ef8a85b39277b3d9fe8df4d296
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/erratum/errors/crud.rb
CHANGED
@@ -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
|
29
|
+
@resource_name_underscored ||= resource_name&.gsub(/\s/, '_')
|
22
30
|
end
|
23
31
|
end
|
24
32
|
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 \((
|
20
|
+
message_info_pattern = /DETAIL: Key \((.*?)(?:_id)?\)=\(([a-f0-9\-]+)\)/
|
22
21
|
message_info = original_error
|
23
22
|
.message
|
24
|
-
.match(message_info_pattern)
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
53
|
-
|
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
|
-
|
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
|
-
|
50
|
+
super.merge(
|
51
|
+
'missing_ids' => missing_ids,
|
52
|
+
)
|
49
53
|
end
|
50
54
|
|
51
55
|
def action
|
data/lib/erratum/version.rb
CHANGED
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.
|
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-
|
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
|