activemodel-errors-tree 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/activemodel-errors-tree.gemspec +11 -11
- data/lib/activemodel/errors/tree.rb +9 -9
- metadata +26 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: babdaf7b363bf59e2de3ede87902a24532581ca24491c7367bb25ca51c6c044d
|
4
|
+
data.tar.gz: 7b340b47e7cc115f03569f3a905182ffb90d504e67f54e0d8efbccef6a86e9df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7159a2dc84e51a7bd9eee07f1eed65fc5f40ae3688ffd447eb6cfacab5f03114253c126dc3a98110deb7f6cc7f67595e61ad70352380f756f0a489d981fc1b91
|
7
|
+
data.tar.gz: 45d46862915b57c4beaedab469d828f8af33197ebf938c73ceab97984e4df133186ecb8325917ef80ac596bccc19f475d04c27f64502bcd42e70af56f0e7b192
|
data/README.md
CHANGED
@@ -71,7 +71,7 @@ the associations, and render out each association's errors.
|
|
71
71
|
|
72
72
|
### errors.details (the recommended way)
|
73
73
|
|
74
|
-
If you use Rails 5 or include the
|
74
|
+
If you use Rails 5 or include the [active_model-errors_details](https://github.com/cowbell/active_model-errors_details) gem, you can use
|
75
75
|
`@record.errors.tree.details` instead of `messages`. This is more API friendly
|
76
76
|
since it let's your client decide on the actual messages.
|
77
77
|
|
@@ -4,28 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "activemodel-errors-tree"
|
7
|
-
spec.version = "0.1
|
7
|
+
spec.version = "0.2.1" # for some reason Rails applications do not like it defined in activemodel/errors/tree/version
|
8
8
|
spec.authors = ["Oded Niv"]
|
9
9
|
spec.email = ["oded.niv@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = %q{ActiveModel errors format actually appropriate for APIs.}
|
12
12
|
spec.description = %q{Builds a tree of errors instead of the 1-dimension one generated by ActiveMode::Base#errors.messages.}
|
13
13
|
spec.homepage = "https://github.com/odedniv/activemodel-errors-tree"
|
14
|
-
spec.license = "
|
14
|
+
spec.license = "Unlicense"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.bindir = "exe"
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.
|
22
|
-
spec.add_runtime_dependency "activemodel", ">= 4.2"
|
21
|
+
spec.required_ruby_version = ">= 3.0"
|
23
22
|
|
24
|
-
spec.
|
25
|
-
spec.
|
26
|
-
|
27
|
-
spec.add_development_dependency "
|
28
|
-
|
29
|
-
spec.add_development_dependency "
|
30
|
-
spec.add_development_dependency "
|
23
|
+
spec.add_runtime_dependency "activesupport", "~> 6.1"
|
24
|
+
spec.add_runtime_dependency "activemodel", "~> 6.1"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.5"
|
27
|
+
spec.add_development_dependency "rake", "~> 13.2"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.13"
|
29
|
+
spec.add_development_dependency "sqlite3", "~> 1.4"
|
30
|
+
spec.add_development_dependency "activerecord", "~> 6.0"
|
31
31
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require "active_model
|
2
|
-
require "active_support
|
1
|
+
require "active_model"
|
2
|
+
require "active_support"
|
3
3
|
|
4
4
|
module ActiveModel
|
5
5
|
class Errors
|
@@ -23,7 +23,7 @@ module ActiveModel
|
|
23
23
|
|
24
24
|
def method_tree(method)
|
25
25
|
result = ActiveSupport::HashWithIndifferentAccess.new
|
26
|
-
@errors.
|
26
|
+
@errors.attribute_names.each do |original_attribute|
|
27
27
|
attribute, sub_attribute = original_attribute.to_s.split(ATTRIBUTE_SEPARATOR, 2) # we really only care about the first one
|
28
28
|
if sub_attribute.nil?
|
29
29
|
result[attribute] = @errors.send(method)[original_attribute]
|
@@ -41,21 +41,21 @@ module ActiveModel
|
|
41
41
|
end
|
42
42
|
|
43
43
|
alias_method :add_without_reset_tree, :add
|
44
|
-
def add(
|
44
|
+
def add(...)
|
45
45
|
@tree = nil
|
46
|
-
add_without_reset_tree(
|
46
|
+
add_without_reset_tree(...)
|
47
47
|
end
|
48
48
|
|
49
49
|
alias_method :delete_without_reset_tree, :delete
|
50
|
-
def delete(
|
50
|
+
def delete(...)
|
51
51
|
@tree = nil
|
52
|
-
delete_without_reset_tree(
|
52
|
+
delete_without_reset_tree(...)
|
53
53
|
end
|
54
54
|
|
55
55
|
alias_method :clear_without_reset_tree, :clear
|
56
|
-
def clear(
|
56
|
+
def clear(...)
|
57
57
|
@tree = nil
|
58
|
-
clear_without_reset_tree(
|
58
|
+
clear_without_reset_tree(...)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
metadata
CHANGED
@@ -1,127 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-errors-tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oded Niv
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '6.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.2'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.13'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.13'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
89
|
+
version: '1.4'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: active_model-errors_details
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.2'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.2'
|
96
|
+
version: '1.4'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: activerecord
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
103
|
+
version: '6.0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
110
|
+
version: '6.0'
|
125
111
|
description: Builds a tree of errors instead of the 1-dimension one generated by ActiveMode::Base#errors.messages.
|
126
112
|
email:
|
127
113
|
- oded.niv@gmail.com
|
@@ -143,9 +129,9 @@ files:
|
|
143
129
|
- lib/activemodel/errors/tree.rb
|
144
130
|
homepage: https://github.com/odedniv/activemodel-errors-tree
|
145
131
|
licenses:
|
146
|
-
-
|
132
|
+
- Unlicense
|
147
133
|
metadata: {}
|
148
|
-
post_install_message:
|
134
|
+
post_install_message:
|
149
135
|
rdoc_options: []
|
150
136
|
require_paths:
|
151
137
|
- lib
|
@@ -153,16 +139,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
139
|
requirements:
|
154
140
|
- - ">="
|
155
141
|
- !ruby/object:Gem::Version
|
156
|
-
version: '0'
|
142
|
+
version: '3.0'
|
157
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
144
|
requirements:
|
159
145
|
- - ">="
|
160
146
|
- !ruby/object:Gem::Version
|
161
147
|
version: '0'
|
162
148
|
requirements: []
|
163
|
-
|
164
|
-
|
165
|
-
signing_key:
|
149
|
+
rubygems_version: 3.5.9
|
150
|
+
signing_key:
|
166
151
|
specification_version: 4
|
167
152
|
summary: ActiveModel errors format actually appropriate for APIs.
|
168
153
|
test_files: []
|