rails_twirp 0.14 → 0.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b7e742d4821b2a3745b2463d19aae223822eac419bd773d371f379143454d71
4
- data.tar.gz: 1abf4446ebeea434ecdd7064a19e5ad7375c0e3e8f936af4afaf67a938923844
3
+ metadata.gz: 49a7d34d89a4dac62fb2125561c1b7aa3dc4fcbe429c13eb14d8cadc04d5ba39
4
+ data.tar.gz: '0491bab9e0a82bc44551047c4a1fe5969903e168e66cd1ab98635277a8e94013'
5
5
  SHA512:
6
- metadata.gz: 6dfdf309ddc0f01d4da60b51205de47414fc11aff123a15f1e65fdbbd31d532c9c417fe7e73f5e5a4a9c0fb0d9f030c6a758bae1fc4a40df4f776167a64a2c84
7
- data.tar.gz: 74840175fc2b2bac370dcddb5c906f89cebf072c7b5f678baca72f4c678d45c87ff15f0cfbe62c9e7d15ac3b8904eedc99ffd4d90fdb632439c18d575ad40a95
6
+ metadata.gz: 8320ba3215e7cdea0cf333611f3df86a5a134f8c2d61bac51b75a04cccd3f644f5b4cd690239ce4a4b42ad22429de88aacbfb5b40e8da67844145806625d675f
7
+ data.tar.gz: 0d6a125a57a4b709702c54db8d6ed1339d6f89f6c5e898b12136fb0ec1de3cb8ceeeede9bb9a040193240922fe00666aa5205b50c7075f118d989993c10d9620
@@ -11,7 +11,7 @@ jobs:
11
11
  - name: Setup Ruby
12
12
  uses: ruby/setup-ruby@v1
13
13
  with:
14
- ruby-version: 3.0.0
14
+ ruby-version: 3.3.0
15
15
  bundler-cache: true
16
16
 
17
17
  - name: Run tests
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.3
1
+ 3.3.0
data/.standard.yml CHANGED
@@ -1,3 +1 @@
1
- ignore:
2
- - '**/*':
3
- - Lint/RescueException
1
+ ruby_version: 2.7
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
- ### 0.14.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
6
+
7
+ * Exclude versions of Rails 7 which were incompatible with the pbbuilder ActionView handler, as pbbuilder cannot work there at all
8
+ * Fix decode_rack_response to be compatible with Rack response body wrappers (and conform to the Rack SPEC)
9
+
10
+ ### 0.14
2
11
  * Adding frozen_string_literal: true to all files.
3
12
 
4
13
  ### 0.13.2
@@ -13,14 +22,14 @@
13
22
  * Include `ActionController::Caching` with Base controller/helpers
14
23
 
15
24
 
16
- ### 0.12.0
25
+ ### 0.12
17
26
 
18
27
  * Allow a custom exception handling proc to be assigned using `RailsTwirp.unhandled_exception_handler`
19
28
 
20
- ### 0.11.0
29
+ ### 0.11
21
30
 
22
31
  * Update configuration and tests for Rails 7 compatibility
23
32
 
24
- ### 0.10.0
33
+ ### 0.10
25
34
 
26
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, **options, &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(**options) { 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 = body.join # body is an Enumerable
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.14"
4
+ VERSION = "0.16"
5
5
  end
data/rails_twirp.gemspec CHANGED
@@ -13,7 +13,10 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.files = `git ls-files`.split("\n")
15
15
 
16
- spec.add_dependency "rails", ">= 6.1.3"
17
- spec.add_dependency "twirp", ">= 1.9", "< 1.11"
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
18
+ # @see https://github.com/rails/rails/pull/51023
19
+ spec.add_runtime_dependency "rails", ">= 6.1.3", " < 7.1"
20
+ spec.add_runtime_dependency "twirp", ">= 1.9", "< 1.11"
18
21
  spec.required_ruby_version = ">= 3"
19
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.14'
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: 2023-03-16 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,6 +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'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 6.1.3
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: twirp
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -167,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
173
  - !ruby/object:Gem::Version
168
174
  version: '0'
169
175
  requirements: []
170
- rubygems_version: 3.2.32
176
+ rubygems_version: 3.5.3
171
177
  signing_key:
172
178
  specification_version: 4
173
179
  summary: Integrate Twirp into Rails