json_apiable 0.5 → 0.6.2
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/json_apiable/filter_matchers.rb +10 -10
- data/lib/json_apiable/json_apiable.rb +1 -0
- data/lib/json_apiable/params_parser.rb +5 -1
- data/lib/json_apiable/renderers.rb +5 -0
- data/lib/json_apiable/version.rb +1 -1
- metadata +3 -3
- data/Gemfile.lock +0 -196
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29bff2e7154441ebe7f91c57312fe056b909aa2bc9915271367488dc19befc22
|
|
4
|
+
data.tar.gz: 1e2d71d8579cb79a5093fe5c20e3d2a66fc1e5bd1c45cf779cf9dcb11748c120
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7771ee1909f4e08fd3d695a6b3ec701152f86f0261a1b5ccff994673fbbf4a9b5b9eb87854eb3f82a3e04f3289392198b0d79c676e27f9b081e9d3efffd675f8
|
|
7
|
+
data.tar.gz: 8aa6522bf45da91e221e9f4b9ac16a52fbb418ef174c108ca38a66232239e2b0cde418c122989793b63ef19add8a9238ab476cb665f1e4a8e29ce46df1008268
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Changelog
|
|
2
|
+
=========
|
|
3
|
+
## 0.6.2 06/02/2021
|
|
4
|
+
* Renaming not_blank_matcher to any_non_blank_matcher
|
|
5
|
+
|
|
6
|
+
## 0.6.1 06/02/2021
|
|
7
|
+
* Adding not_blank_matcher to filter-matchers
|
|
8
|
+
|
|
9
|
+
## 0.6.0 05/15/2021
|
|
10
|
+
* Adding support for "has_many" nested attributes
|
|
11
|
+
* Updating specs
|
|
12
|
+
|
|
13
|
+
## 0.5.2 05/06/2021
|
|
14
|
+
* Updating dependency gems
|
|
@@ -10,15 +10,19 @@ module JsonApiable
|
|
|
10
10
|
|
|
11
11
|
module_function :matches?
|
|
12
12
|
|
|
13
|
+
def any_non_blank_matcher
|
|
14
|
+
proc do |value|
|
|
15
|
+
handle_error(value) do
|
|
16
|
+
value.present?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
13
21
|
# returns true for boolean values, false for any other
|
|
14
22
|
def boolean_matcher
|
|
15
23
|
proc do |value|
|
|
16
24
|
handle_error(value) do
|
|
17
|
-
|
|
18
|
-
true
|
|
19
|
-
else
|
|
20
|
-
false
|
|
21
|
-
end
|
|
25
|
+
true_matcher.call(value) || (value == false || value =~ /^(false|f|0)$/i)
|
|
22
26
|
end
|
|
23
27
|
end
|
|
24
28
|
end
|
|
@@ -27,11 +31,7 @@ module JsonApiable
|
|
|
27
31
|
def true_matcher
|
|
28
32
|
proc do |value|
|
|
29
33
|
handle_error(value) do
|
|
30
|
-
|
|
31
|
-
true
|
|
32
|
-
else
|
|
33
|
-
false
|
|
34
|
-
end
|
|
34
|
+
value == true || value =~ /^(true|t|1)$/i
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -20,6 +20,7 @@ module JsonApiable
|
|
|
20
20
|
|
|
21
21
|
rescue_from ArgumentError, with: :respond_to_bad_argument
|
|
22
22
|
rescue_from ActionController::UnpermittedParameters, with: :respond_to_bad_argument
|
|
23
|
+
rescue_from JSONAPI::Serializer::UnsupportedIncludeError, with: :respond_to_exception_raised
|
|
23
24
|
rescue_from MalformedRequestError, with: :respond_to_malformed_request
|
|
24
25
|
rescue_from UnprocessableEntityError, with: :respond_to_unprocessable_entity
|
|
25
26
|
rescue_from UnauthorizedError, with: :respond_to_unauthorized
|
|
@@ -34,7 +34,7 @@ module JsonApiable
|
|
|
34
34
|
attributes&.each do |key, value|
|
|
35
35
|
next if excluded_attributes&.include?(key.to_sym)
|
|
36
36
|
|
|
37
|
-
new_key =
|
|
37
|
+
new_key = nested_attributes?(value) ? "#{key}_attributes" : key
|
|
38
38
|
attrs_hash[new_key] = value.is_a?(ActionController::Parameters) ? value.to_h : value
|
|
39
39
|
end
|
|
40
40
|
attrs_hash
|
|
@@ -78,5 +78,9 @@ module JsonApiable
|
|
|
78
78
|
def self.hashify(allowed_relationships)
|
|
79
79
|
allowed_relationships.map { |rel| { rel => {} } }
|
|
80
80
|
end
|
|
81
|
+
|
|
82
|
+
def self.nested_attributes?(value)
|
|
83
|
+
value.is_a?(ActionController::Parameters) || value.is_a?(Array)
|
|
84
|
+
end
|
|
81
85
|
end
|
|
82
86
|
end
|
|
@@ -32,6 +32,11 @@ module JsonApiable
|
|
|
32
32
|
json_render_errors json: errors, status: :bad_request
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
def respond_to_exception_raised(err_msg)
|
|
36
|
+
errors = [{ title: 'Invalid Argument', detail: err_msg.message }]
|
|
37
|
+
json_render_errors json: errors, status: :bad_request
|
|
38
|
+
end
|
|
39
|
+
|
|
35
40
|
def respond_to_malformed_request(err_msg = nil)
|
|
36
41
|
errors = [{ title: 'Malformed Request', detail: err_msg.to_s }]
|
|
37
42
|
json_render_errors json: errors, status: :bad_request
|
data/lib/json_apiable/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: json_apiable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Polischuk
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-06-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -203,8 +203,8 @@ files:
|
|
|
203
203
|
- ".rspec"
|
|
204
204
|
- ".rubocop.yml"
|
|
205
205
|
- ".travis.yml"
|
|
206
|
+
- CHANGELOG.md
|
|
206
207
|
- Gemfile
|
|
207
|
-
- Gemfile.lock
|
|
208
208
|
- LICENSE.txt
|
|
209
209
|
- README.md
|
|
210
210
|
- Rakefile
|
data/Gemfile.lock
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
json_apiable (0.5)
|
|
5
|
-
activerecord
|
|
6
|
-
activesupport
|
|
7
|
-
jsonapi-serializer
|
|
8
|
-
|
|
9
|
-
GEM
|
|
10
|
-
remote: https://rubygems.org/
|
|
11
|
-
specs:
|
|
12
|
-
actioncable (6.1.3.1)
|
|
13
|
-
actionpack (= 6.1.3.1)
|
|
14
|
-
activesupport (= 6.1.3.1)
|
|
15
|
-
nio4r (~> 2.0)
|
|
16
|
-
websocket-driver (>= 0.6.1)
|
|
17
|
-
actionmailbox (6.1.3.1)
|
|
18
|
-
actionpack (= 6.1.3.1)
|
|
19
|
-
activejob (= 6.1.3.1)
|
|
20
|
-
activerecord (= 6.1.3.1)
|
|
21
|
-
activestorage (= 6.1.3.1)
|
|
22
|
-
activesupport (= 6.1.3.1)
|
|
23
|
-
mail (>= 2.7.1)
|
|
24
|
-
actionmailer (6.1.3.1)
|
|
25
|
-
actionpack (= 6.1.3.1)
|
|
26
|
-
actionview (= 6.1.3.1)
|
|
27
|
-
activejob (= 6.1.3.1)
|
|
28
|
-
activesupport (= 6.1.3.1)
|
|
29
|
-
mail (~> 2.5, >= 2.5.4)
|
|
30
|
-
rails-dom-testing (~> 2.0)
|
|
31
|
-
actionpack (6.1.3.1)
|
|
32
|
-
actionview (= 6.1.3.1)
|
|
33
|
-
activesupport (= 6.1.3.1)
|
|
34
|
-
rack (~> 2.0, >= 2.0.9)
|
|
35
|
-
rack-test (>= 0.6.3)
|
|
36
|
-
rails-dom-testing (~> 2.0)
|
|
37
|
-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
38
|
-
actiontext (6.1.3.1)
|
|
39
|
-
actionpack (= 6.1.3.1)
|
|
40
|
-
activerecord (= 6.1.3.1)
|
|
41
|
-
activestorage (= 6.1.3.1)
|
|
42
|
-
activesupport (= 6.1.3.1)
|
|
43
|
-
nokogiri (>= 1.8.5)
|
|
44
|
-
actionview (6.1.3.1)
|
|
45
|
-
activesupport (= 6.1.3.1)
|
|
46
|
-
builder (~> 3.1)
|
|
47
|
-
erubi (~> 1.4)
|
|
48
|
-
rails-dom-testing (~> 2.0)
|
|
49
|
-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
50
|
-
activejob (6.1.3.1)
|
|
51
|
-
activesupport (= 6.1.3.1)
|
|
52
|
-
globalid (>= 0.3.6)
|
|
53
|
-
activemodel (6.1.3.1)
|
|
54
|
-
activesupport (= 6.1.3.1)
|
|
55
|
-
activerecord (6.1.3.1)
|
|
56
|
-
activemodel (= 6.1.3.1)
|
|
57
|
-
activesupport (= 6.1.3.1)
|
|
58
|
-
activestorage (6.1.3.1)
|
|
59
|
-
actionpack (= 6.1.3.1)
|
|
60
|
-
activejob (= 6.1.3.1)
|
|
61
|
-
activerecord (= 6.1.3.1)
|
|
62
|
-
activesupport (= 6.1.3.1)
|
|
63
|
-
marcel (~> 1.0.0)
|
|
64
|
-
mini_mime (~> 1.0.2)
|
|
65
|
-
activesupport (6.1.3.1)
|
|
66
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
67
|
-
i18n (>= 1.6, < 2)
|
|
68
|
-
minitest (>= 5.1)
|
|
69
|
-
tzinfo (~> 2.0)
|
|
70
|
-
zeitwerk (~> 2.3)
|
|
71
|
-
builder (3.2.4)
|
|
72
|
-
byebug (11.1.1)
|
|
73
|
-
coderay (1.1.2)
|
|
74
|
-
concurrent-ruby (1.1.8)
|
|
75
|
-
crass (1.0.6)
|
|
76
|
-
diff-lcs (1.3)
|
|
77
|
-
erubi (1.10.0)
|
|
78
|
-
factory_bot (6.1.0)
|
|
79
|
-
activesupport (>= 5.0.0)
|
|
80
|
-
factory_bot_rails (6.1.0)
|
|
81
|
-
factory_bot (~> 6.1.0)
|
|
82
|
-
railties (>= 5.0.0)
|
|
83
|
-
faker (2.10.2)
|
|
84
|
-
i18n (>= 1.6, < 2)
|
|
85
|
-
globalid (0.4.2)
|
|
86
|
-
activesupport (>= 4.2.0)
|
|
87
|
-
i18n (1.8.10)
|
|
88
|
-
concurrent-ruby (~> 1.0)
|
|
89
|
-
jsonapi-serializer (2.2.0)
|
|
90
|
-
activesupport (>= 4.2)
|
|
91
|
-
loofah (2.9.1)
|
|
92
|
-
crass (~> 1.0.2)
|
|
93
|
-
nokogiri (>= 1.5.9)
|
|
94
|
-
mail (2.7.1)
|
|
95
|
-
mini_mime (>= 0.1.1)
|
|
96
|
-
marcel (1.0.1)
|
|
97
|
-
method_source (0.9.2)
|
|
98
|
-
mini_mime (1.0.3)
|
|
99
|
-
mini_portile2 (2.5.1)
|
|
100
|
-
minitest (5.14.4)
|
|
101
|
-
nio4r (2.5.7)
|
|
102
|
-
nokogiri (1.11.3)
|
|
103
|
-
mini_portile2 (~> 2.5.0)
|
|
104
|
-
racc (~> 1.4)
|
|
105
|
-
pry (0.12.2)
|
|
106
|
-
coderay (~> 1.1.0)
|
|
107
|
-
method_source (~> 0.9.0)
|
|
108
|
-
pry-byebug (3.8.0)
|
|
109
|
-
byebug (~> 11.0)
|
|
110
|
-
pry (~> 0.10)
|
|
111
|
-
racc (1.5.2)
|
|
112
|
-
rack (2.2.3)
|
|
113
|
-
rack-test (1.1.0)
|
|
114
|
-
rack (>= 1.0, < 3)
|
|
115
|
-
rails (6.1.3.1)
|
|
116
|
-
actioncable (= 6.1.3.1)
|
|
117
|
-
actionmailbox (= 6.1.3.1)
|
|
118
|
-
actionmailer (= 6.1.3.1)
|
|
119
|
-
actionpack (= 6.1.3.1)
|
|
120
|
-
actiontext (= 6.1.3.1)
|
|
121
|
-
actionview (= 6.1.3.1)
|
|
122
|
-
activejob (= 6.1.3.1)
|
|
123
|
-
activemodel (= 6.1.3.1)
|
|
124
|
-
activerecord (= 6.1.3.1)
|
|
125
|
-
activestorage (= 6.1.3.1)
|
|
126
|
-
activesupport (= 6.1.3.1)
|
|
127
|
-
bundler (>= 1.15.0)
|
|
128
|
-
railties (= 6.1.3.1)
|
|
129
|
-
sprockets-rails (>= 2.0.0)
|
|
130
|
-
rails-controller-testing (1.0.4)
|
|
131
|
-
actionpack (>= 5.0.1.x)
|
|
132
|
-
actionview (>= 5.0.1.x)
|
|
133
|
-
activesupport (>= 5.0.1.x)
|
|
134
|
-
rails-dom-testing (2.0.3)
|
|
135
|
-
activesupport (>= 4.2.0)
|
|
136
|
-
nokogiri (>= 1.6)
|
|
137
|
-
rails-html-sanitizer (1.3.0)
|
|
138
|
-
loofah (~> 2.3)
|
|
139
|
-
railties (6.1.3.1)
|
|
140
|
-
actionpack (= 6.1.3.1)
|
|
141
|
-
activesupport (= 6.1.3.1)
|
|
142
|
-
method_source
|
|
143
|
-
rake (>= 0.8.7)
|
|
144
|
-
thor (~> 1.0)
|
|
145
|
-
rake (13.0.3)
|
|
146
|
-
rspec-core (3.9.1)
|
|
147
|
-
rspec-support (~> 3.9.1)
|
|
148
|
-
rspec-expectations (3.9.0)
|
|
149
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
150
|
-
rspec-support (~> 3.9.0)
|
|
151
|
-
rspec-mocks (3.9.1)
|
|
152
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
153
|
-
rspec-support (~> 3.9.0)
|
|
154
|
-
rspec-rails (3.9.0)
|
|
155
|
-
actionpack (>= 3.0)
|
|
156
|
-
activesupport (>= 3.0)
|
|
157
|
-
railties (>= 3.0)
|
|
158
|
-
rspec-core (~> 3.9.0)
|
|
159
|
-
rspec-expectations (~> 3.9.0)
|
|
160
|
-
rspec-mocks (~> 3.9.0)
|
|
161
|
-
rspec-support (~> 3.9.0)
|
|
162
|
-
rspec-support (3.9.2)
|
|
163
|
-
sprockets (4.0.2)
|
|
164
|
-
concurrent-ruby (~> 1.0)
|
|
165
|
-
rack (> 1, < 3)
|
|
166
|
-
sprockets-rails (3.2.2)
|
|
167
|
-
actionpack (>= 4.0)
|
|
168
|
-
activesupport (>= 4.0)
|
|
169
|
-
sprockets (>= 3.0.0)
|
|
170
|
-
sqlite3 (1.4.2)
|
|
171
|
-
thor (1.1.0)
|
|
172
|
-
tzinfo (2.0.4)
|
|
173
|
-
concurrent-ruby (~> 1.0)
|
|
174
|
-
websocket-driver (0.7.3)
|
|
175
|
-
websocket-extensions (>= 0.1.0)
|
|
176
|
-
websocket-extensions (0.1.5)
|
|
177
|
-
zeitwerk (2.4.2)
|
|
178
|
-
|
|
179
|
-
PLATFORMS
|
|
180
|
-
ruby
|
|
181
|
-
|
|
182
|
-
DEPENDENCIES
|
|
183
|
-
bundler (~> 2.0)
|
|
184
|
-
factory_bot_rails
|
|
185
|
-
faker
|
|
186
|
-
json_apiable!
|
|
187
|
-
pry
|
|
188
|
-
pry-byebug
|
|
189
|
-
rails
|
|
190
|
-
rails-controller-testing
|
|
191
|
-
rake (~> 13.0)
|
|
192
|
-
rspec-rails (~> 3.9)
|
|
193
|
-
sqlite3
|
|
194
|
-
|
|
195
|
-
BUNDLED WITH
|
|
196
|
-
2.1.4
|