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 +4 -4
- data/.github/workflows/test.yml +1 -1
- data/.ruby-version +1 -1
- data/.standard.yml +1 -3
- data/CHANGELOG.md +13 -4
- data/lib/rails_twirp/exception_handling.rb +1 -1
- data/lib/rails_twirp/mapper.rb +2 -2
- data/lib/rails_twirp/rescue.rb +2 -2
- data/lib/rails_twirp/testing/integration_test.rb +6 -3
- data/lib/rails_twirp/version.rb +1 -1
- data/rails_twirp.gemspec +5 -2
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49a7d34d89a4dac62fb2125561c1b7aa3dc4fcbe429c13eb14d8cadc04d5ba39
|
4
|
+
data.tar.gz: '0491bab9e0a82bc44551047c4a1fe5969903e168e66cd1ab98635277a8e94013'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8320ba3215e7cdea0cf333611f3df86a5a134f8c2d61bac51b75a04cccd3f644f5b4cd690239ce4a4b42ad22429de88aacbfb5b40e8da67844145806625d675f
|
7
|
+
data.tar.gz: 0d6a125a57a4b709702c54db8d6ed1339d6f89f6c5e898b12136fb0ec1de3cb8ceeeede9bb9a040193240922fe00666aa5205b50c7075f118d989993c10d9620
|
data/.github/workflows/test.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0
|
1
|
+
3.3.0
|
data/.standard.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
### 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
|
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
|
29
|
+
### 0.11
|
21
30
|
|
22
31
|
* Update configuration and tests for Rails 7 compatibility
|
23
32
|
|
24
|
-
### 0.10
|
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
|
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".
|
data/lib/rails_twirp/mapper.rb
CHANGED
@@ -59,10 +59,10 @@ module RailsTwirp
|
|
59
59
|
@module = nil
|
60
60
|
end
|
61
61
|
|
62
|
-
def service(service_definition, **
|
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(**
|
65
|
+
scope(**kwargs) { service_mapper.instance_exec(&block) }
|
66
66
|
end
|
67
67
|
|
68
68
|
def scope(**options)
|
data/lib/rails_twirp/rescue.rb
CHANGED
@@ -91,14 +91,17 @@ module RailsTwirp
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def decode_rack_response(service, rpc, status, headers, body)
|
94
|
-
|
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(
|
99
|
+
Twirp::Encoding.decode(body_bytes.string, output_class, headers["Content-Type"])
|
99
100
|
else
|
100
|
-
Twirp::Client.error_from_response(Response.new(status,
|
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)
|
data/lib/rails_twirp/version.rb
CHANGED
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
|
-
|
17
|
-
|
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.
|
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:
|
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.
|
176
|
+
rubygems_version: 3.5.3
|
171
177
|
signing_key:
|
172
178
|
specification_version: 4
|
173
179
|
summary: Integrate Twirp into Rails
|