camille 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ff47e3a7fdcb5ef28cca7bc5ce3989900c82d7eb0d94af77a00e0b0c4ac9b3d
4
- data.tar.gz: 7885520d31b5b0a4f339cc24e5993ea1d8e1d637029a018b5dcb144060e72965
3
+ metadata.gz: 60434d249fd905789f0c9fd812d097163cda296655c56fde57569269d8188e39
4
+ data.tar.gz: 422d993e72473270985d6ade710ae39e3ada83ef85942e83291176dc8bff9dcc
5
5
  SHA512:
6
- metadata.gz: 5c990d3326e3271092647bd2ccdbc9ddf213e0f6200c872f0d398c4fb5306670c7e9993e4e48c82dab84a97ea4a8b3200ad100475c4a9243758e94ea211df681
7
- data.tar.gz: c21e9542119b194dac81e446574c582fcf16a98a7fbeaeeba33e083518b3070b826a4db20596ff22fb5b18f1b8e64161056e10f71309a3309ab3213c8da9ba4d
6
+ metadata.gz: 6561b6b4c62f85c22d28b27c9693a1dfe8a3cccaaf95251d3995b50b0457363ea82ef971fa03d10959bcf505ee0188b2189b6de5d3cd984930830bc2a9bdcd3e
7
+ data.tar.gz: 4266ecec3ab26f2e1af40b83fe60d337ed81b8fa6f953200c14f6e1dfb2ffe9519ea2d0519882b4790cc34cc1c7f84b18fb8481d0ec3cba88636c73236998761
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## 0.5.7
4
14
 
5
15
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- camille (0.5.7)
4
+ camille (0.5.8)
5
5
  rails (>= 6.1, < 8)
6
6
 
7
7
  GEM
@@ -15,21 +15,25 @@ module Camille
15
15
  def render *args
16
16
  if endpoint = camille_endpoint
17
17
  render_options = args.last
18
- if value = render_options[:json]
19
- error, transformed = endpoint.response_type.transform_and_check(value)
20
- if error
21
- string_io = StringIO.new
22
- Camille::TypeErrorPrinter.new(error).print(string_io)
23
- raise TypeError.new("\nType check failed for response.\n#{string_io.string}")
24
- else
25
- if transformed.is_a? Hash
26
- transformed.deep_transform_keys!{|k| k.to_s.camelize(:lower)}
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)
27
31
  end
28
- @camille_rendered = true
29
- super(json: transformed)
32
+ else
33
+ raise ArgumentError.new("Expected key :json for `render` call.")
30
34
  end
31
35
  else
32
- raise ArgumentError.new("Expected key :json for `render` call.")
36
+ super
33
37
  end
34
38
  else
35
39
  super
@@ -42,7 +46,8 @@ module Camille
42
46
  begin
43
47
  params.deep_transform_keys!{|key| key.to_s.underscore}
44
48
  result = super
45
- unless @camille_rendered
49
+ # When there's no `render` call, Rails will return status 204
50
+ if response.status == 204
46
51
  raise_missing_render_error
47
52
  end
48
53
  result
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Camille
4
- VERSION = "0.5.7"
4
+ VERSION = "0.5.8"
5
5
  end
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.7
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-22 00:00:00.000000000 Z
11
+ date: 2023-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails