rails_twirp 0.15 → 0.16

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: 4e1b6e06cf246cc4ab4a639ca805033c8f96a24d2a1f468b733001b5f4ca9732
4
- data.tar.gz: 4e03e912af4c785bbe9852245ed6e763e6d398c335dd63d4d0c4c3751402b814
3
+ metadata.gz: 49a7d34d89a4dac62fb2125561c1b7aa3dc4fcbe429c13eb14d8cadc04d5ba39
4
+ data.tar.gz: '0491bab9e0a82bc44551047c4a1fe5969903e168e66cd1ab98635277a8e94013'
5
5
  SHA512:
6
- metadata.gz: 6cdc2a1d80937bbb85a513cc4807e9a91c5bd0848d5b959e90d226477231387c0e9250ec30bf7ff8da170c8cf64ca7136bcd47deb3fb23206797749bdbe624b8
7
- data.tar.gz: 68c342ad35489011bc921dc4c7529d5ff7a18f47fce4aef9c597cebd2a789bdcec8050b6738cad457bcb54fce0b1c9f262558a964d42b26e1063a34f73f9d250
6
+ metadata.gz: 8320ba3215e7cdea0cf333611f3df86a5a134f8c2d61bac51b75a04cccd3f644f5b4cd690239ce4a4b42ad22429de88aacbfb5b40e8da67844145806625d675f
7
+ data.tar.gz: 0d6a125a57a4b709702c54db8d6ed1339d6f89f6c5e898b12136fb0ec1de3cb8ceeeede9bb9a040193240922fe00666aa5205b50c7075f118d989993c10d9620
data/.standard.yml CHANGED
@@ -1,3 +1 @@
1
- ignore:
2
- - '**/*':
3
- - Lint/RescueException
1
+ ruby_version: 2.7
data/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
- ### 0.15.0
1
+ ### 0.16
2
+
3
+ * Ensure `decode_rack_response` always calls `#close` on the Rack body in tests, as some middleware might be applying a BodyProxy
4
+
5
+ ### 0.15
2
6
 
3
7
  * Exclude versions of Rails 7 which were incompatible with the pbbuilder ActionView handler, as pbbuilder cannot work there at all
4
8
  * Fix decode_rack_response to be compatible with Rack response body wrappers (and conform to the Rack SPEC)
5
9
 
6
- ### 0.14.0
10
+ ### 0.14
7
11
  * Adding frozen_string_literal: true to all files.
8
12
 
9
13
  ### 0.13.2
@@ -18,14 +22,14 @@
18
22
  * Include `ActionController::Caching` with Base controller/helpers
19
23
 
20
24
 
21
- ### 0.12.0
25
+ ### 0.12
22
26
 
23
27
  * Allow a custom exception handling proc to be assigned using `RailsTwirp.unhandled_exception_handler`
24
28
 
25
- ### 0.11.0
29
+ ### 0.11
26
30
 
27
31
  * Update configuration and tests for Rails 7 compatibility
28
32
 
29
- ### 0.10.0
33
+ ### 0.10
30
34
 
31
35
  * Handle exceptions more like the Rails controllers do it, do not capture all of them as if they were Twirp exceptions
@@ -10,7 +10,7 @@ module RailsTwirp
10
10
 
11
11
  def process_action(*)
12
12
  super
13
- rescue Exception => e
13
+ rescue => e
14
14
  # Only the exceptions which are not captured by ActionController-like "rescue_from" end up here.
15
15
  # The idea is that any exception which is rescued by the controller is treated as part of the business
16
16
  # logic, and thus taking action on it is the responsibility of the controller which uses "rescue_from".
@@ -59,10 +59,10 @@ module RailsTwirp
59
59
  @module = nil
60
60
  end
61
61
 
62
- def service(service_definition, **, &block)
62
+ def service(service_definition, **kwargs, &block)
63
63
  service_route_set = @route_set.services[service_definition]
64
64
  service_mapper = ServiceMapper.new(service_route_set, self)
65
- scope(**) { service_mapper.instance_exec(&block) }
65
+ scope(**kwargs) { service_mapper.instance_exec(&block) }
66
66
  end
67
67
 
68
68
  def scope(**options)
@@ -9,8 +9,8 @@ module RailsTwirp
9
9
 
10
10
  def process_action(*)
11
11
  super
12
- rescue Exception => exception
13
- rescue_with_handler(exception) || raise
12
+ rescue => e
13
+ rescue_with_handler(e) || raise
14
14
  end
15
15
  end
16
16
  end
@@ -91,14 +91,17 @@ module RailsTwirp
91
91
  end
92
92
 
93
93
  def decode_rack_response(service, rpc, status, headers, body)
94
- body = Array.wrap(body).join # body is each-able
94
+ body_bytes = StringIO.new("".b)
95
+ body.each { |b| body_bytes << b }
95
96
 
96
97
  if status === 200
97
98
  output_class = service.rpcs[rpc][:output_class]
98
- Twirp::Encoding.decode(body, output_class, headers["Content-Type"])
99
+ Twirp::Encoding.decode(body_bytes.string, output_class, headers["Content-Type"])
99
100
  else
100
- Twirp::Client.error_from_response(Response.new(status, body, headers))
101
+ Twirp::Client.error_from_response(Response.new(status, body_bytes.string, headers))
101
102
  end
103
+ ensure
104
+ body.close if body.respond_to?(:close) # Comply with Rack API
102
105
  end
103
106
 
104
107
  def set_controller_from_rack_env(env)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsTwirp
4
- VERSION = "0.15"
4
+ VERSION = "0.16"
5
5
  end
data/rails_twirp.gemspec CHANGED
@@ -13,10 +13,10 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.files = `git ls-files`.split("\n")
15
15
 
16
- # Rails has shipped an incompatible change in ActiveView, that was reverted in later versions.
16
+ # Rails has shipped an incompatible change in ActiveView, that was reverted in later versions
17
+ # but at this time has not been released as a 7.x version
17
18
  # @see https://github.com/rails/rails/pull/51023
18
- excluded_versions = ["7.1.0", "7.1.1", "7.1.2", "7.1.3"].map { |v| "!= #{v}" }
19
- spec.add_runtime_dependency "rails", ">= 6.1.3", *excluded_versions
19
+ spec.add_runtime_dependency "rails", ">= 6.1.3", " < 7.1"
20
20
  spec.add_runtime_dependency "twirp", ">= 1.9", "< 1.11"
21
21
  spec.required_ruby_version = ">= 3"
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_twirp
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.15'
4
+ version: '0.16'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-13 00:00:00.000000000 Z
11
+ date: 2024-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -17,18 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 6.1.3
20
- - - "!="
21
- - !ruby/object:Gem::Version
22
- version: 7.1.0
23
- - - "!="
24
- - !ruby/object:Gem::Version
25
- version: 7.1.1
26
- - - "!="
27
- - !ruby/object:Gem::Version
28
- version: 7.1.2
29
- - - "!="
20
+ - - "<"
30
21
  - !ruby/object:Gem::Version
31
- version: 7.1.3
22
+ version: '7.1'
32
23
  type: :runtime
33
24
  prerelease: false
34
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -36,18 +27,9 @@ dependencies:
36
27
  - - ">="
37
28
  - !ruby/object:Gem::Version
38
29
  version: 6.1.3
39
- - - "!="
40
- - !ruby/object:Gem::Version
41
- version: 7.1.0
42
- - - "!="
43
- - !ruby/object:Gem::Version
44
- version: 7.1.1
45
- - - "!="
46
- - !ruby/object:Gem::Version
47
- version: 7.1.2
48
- - - "!="
30
+ - - "<"
49
31
  - !ruby/object:Gem::Version
50
- version: 7.1.3
32
+ version: '7.1'
51
33
  - !ruby/object:Gem::Dependency
52
34
  name: twirp
53
35
  requirement: !ruby/object:Gem::Requirement