camille 0.5.6 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +1 -1
- data/lib/camille/controller.rb +33 -13
- data/lib/camille/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60434d249fd905789f0c9fd812d097163cda296655c56fde57569269d8188e39
|
4
|
+
data.tar.gz: 422d993e72473270985d6ade710ae39e3ada83ef85942e83291176dc8bff9dcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6561b6b4c62f85c22d28b27c9693a1dfe8a3cccaaf95251d3995b50b0457363ea82ef971fa03d10959bcf505ee0188b2189b6de5d3cd984930830bc2a9bdcd3e
|
7
|
+
data.tar.gz: 4266ecec3ab26f2e1af40b83fe60d337ed81b8fa6f953200c14f6e1dfb2ffe9519ea2d0519882b4790cc34cc1c7f84b18fb8481d0ec3cba88636c73236998761
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.5.8
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
* `render` call with a status code other than 200 will skip the typecheck
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
* `head 401` will no longer raise Camille::Controller::MissingRenderError
|
12
|
+
|
13
|
+
## 0.5.7
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
* Camille::Controller::MissingRenderError will now be raised if `render json:` is missing in action body
|
18
|
+
* ActionController::MissingExactTemplate is re-raised as Camille::Controller::MissingRenderError
|
19
|
+
|
3
20
|
## 0.5.6
|
4
21
|
|
5
22
|
### Added
|
data/Gemfile.lock
CHANGED
data/lib/camille/controller.rb
CHANGED
@@ -2,6 +2,7 @@ module Camille
|
|
2
2
|
module Controller
|
3
3
|
class TypeError < ::StandardError; end
|
4
4
|
class ArgumentError < ::ArgumentError; end
|
5
|
+
class MissingRenderError < ::StandardError; end
|
5
6
|
|
6
7
|
def camille_schema
|
7
8
|
@camille_schema ||= Camille::Loader.controller_name_to_schema_map[self.class.name]
|
@@ -14,20 +15,25 @@ module Camille
|
|
14
15
|
def render *args
|
15
16
|
if endpoint = camille_endpoint
|
16
17
|
render_options = args.last
|
17
|
-
|
18
|
-
|
19
|
-
if
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
intended_status = render_options[:status] || 200
|
19
|
+
if intended_status == 200 || intended_status == :ok
|
20
|
+
if value = render_options[:json]
|
21
|
+
error, transformed = endpoint.response_type.transform_and_check(value)
|
22
|
+
if error
|
23
|
+
string_io = StringIO.new
|
24
|
+
Camille::TypeErrorPrinter.new(error).print(string_io)
|
25
|
+
raise TypeError.new("\nType check failed for response.\n#{string_io.string}")
|
26
|
+
else
|
27
|
+
if transformed.is_a? Hash
|
28
|
+
transformed.deep_transform_keys!{|k| k.to_s.camelize(:lower)}
|
29
|
+
end
|
30
|
+
super(json: transformed)
|
26
31
|
end
|
27
|
-
|
32
|
+
else
|
33
|
+
raise ArgumentError.new("Expected key :json for `render` call.")
|
28
34
|
end
|
29
35
|
else
|
30
|
-
|
36
|
+
super
|
31
37
|
end
|
32
38
|
else
|
33
39
|
super
|
@@ -37,12 +43,26 @@ module Camille
|
|
37
43
|
def process_action(*)
|
38
44
|
Camille::Loader.check_and_raise_exception
|
39
45
|
if endpoint = camille_endpoint
|
40
|
-
|
41
|
-
|
46
|
+
begin
|
47
|
+
params.deep_transform_keys!{|key| key.to_s.underscore}
|
48
|
+
result = super
|
49
|
+
# When there's no `render` call, Rails will return status 204
|
50
|
+
if response.status == 204
|
51
|
+
raise_missing_render_error
|
52
|
+
end
|
53
|
+
result
|
54
|
+
rescue ActionController::MissingExactTemplate
|
55
|
+
raise_missing_render_error
|
56
|
+
end
|
42
57
|
else
|
43
58
|
super
|
44
59
|
end
|
45
60
|
end
|
46
61
|
|
62
|
+
private
|
63
|
+
def raise_missing_render_error
|
64
|
+
raise MissingRenderError.new("Expected `render json:` call in controller action body.")
|
65
|
+
end
|
66
|
+
|
47
67
|
end
|
48
68
|
end
|
data/lib/camille/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camille
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 辻彩
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|