rails_twirp 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/rails_twirp/base.rb +5 -4
- data/lib/rails_twirp/route_set.rb +1 -1
- data/lib/rails_twirp/version.rb +1 -1
- data/rails_twirp.gemspec +1 -0
- data/test/dummy/app/controllers/dummy_controller.rb +5 -0
- data/test/dummy/app/views/dummy/rpc_name_check.pb.pbbuilder +1 -0
- data/test/dummy/config/twirp/routes.rb +1 -0
- data/test/dummy/proto/api.proto +6 -0
- data/test/dummy/proto/api_pb.rb +7 -0
- data/test/dummy/proto/api_twirp.rb +2 -1
- data/test/dummy_test.rb +10 -0
- 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: e1ac2840887dd15ea43114d7b0d25901c05e3288fa10d6cdcd8d00d4dabc8e74
|
4
|
+
data.tar.gz: 59ff25b65ad6bd62f1ebc537bc11017da58b6ce6e1f4a74cae9e1c7f35454508
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd193ba67f59a313b463a2745418329d33585505164124810abdbd556ce808717064e6dde4c249cd50865951a9e1155f085adc0b556860eb1a83d5714206833a
|
7
|
+
data.tar.gz: 2795b73a1cf25688ff7abea8db81af893b23374297dbd9128e6d9b642ee3bce4d4026d83d660aa3158367fd0e357987e2d71717e8b4dabe5e2b86720fbd4b74a
|
data/README.md
CHANGED
@@ -21,6 +21,21 @@ Or install it yourself as:
|
|
21
21
|
$ gem install rails_twirp
|
22
22
|
```
|
23
23
|
|
24
|
+
## Installing correct protobuf version for M1 Mac Chips
|
25
|
+
|
26
|
+
If you run into an issue with protobuf universal-darwin version, please paste this in your Gemfile as recommended by @bouke :
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# HACK(bouk): Overwrite Bundler's platform matcher to ignore universal CPU
|
30
|
+
# The protobuf and gRPC 'universal' macOS gems break on M1
|
31
|
+
module Bundler::MatchPlatform
|
32
|
+
def match_platform(p)
|
33
|
+
return false if ::Gem::Platform === platform && platform.cpu == "universal"
|
34
|
+
Bundler::MatchPlatform.platforms_match?(platform, p)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
24
39
|
## Contributing
|
25
40
|
Contribution directions go here.
|
26
41
|
|
data/lib/rails_twirp/base.rb
CHANGED
@@ -37,7 +37,7 @@ module RailsTwirp
|
|
37
37
|
include Rescue
|
38
38
|
include Instrumentation
|
39
39
|
|
40
|
-
attr_internal :request, :env, :response_class
|
40
|
+
attr_internal :request, :env, :response_class, :rpc_name
|
41
41
|
def initialize
|
42
42
|
@_request = nil
|
43
43
|
@_env = nil
|
@@ -49,10 +49,11 @@ module RailsTwirp
|
|
49
49
|
@_http_request ||= ActionDispatch::Request.new(env[:rack_env])
|
50
50
|
end
|
51
51
|
|
52
|
-
def dispatch(action, request, response_class, env = {})
|
52
|
+
def dispatch(action, request, response_class, rpc_name, env = {})
|
53
53
|
self.request = request
|
54
54
|
self.env = env
|
55
55
|
self.response_class = response_class
|
56
|
+
self.rpc_name = rpc_name
|
56
57
|
|
57
58
|
http_request.controller_instance = self
|
58
59
|
|
@@ -61,8 +62,8 @@ module RailsTwirp
|
|
61
62
|
response_body
|
62
63
|
end
|
63
64
|
|
64
|
-
def self.dispatch(action, request, response_class, env = {})
|
65
|
-
new.dispatch(action, request, response_class, env)
|
65
|
+
def self.dispatch(action, request, response_class, rpc_name, env = {})
|
66
|
+
new.dispatch(action, request, response_class, rpc_name, env)
|
66
67
|
end
|
67
68
|
|
68
69
|
# Used by the template renderer to figure out which template to use
|
@@ -57,7 +57,7 @@ module RailsTwirp
|
|
57
57
|
controller_name = mapping.controller.underscore
|
58
58
|
const_name = controller_name.camelize << "Controller"
|
59
59
|
controller_class = const_name.constantize
|
60
|
-
controller_class.dispatch(action_name, req, response_class, env)
|
60
|
+
controller_class.dispatch(action_name, req, response_class, name, env)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
data/lib/rails_twirp/version.rb
CHANGED
data/rails_twirp.gemspec
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
pb.rpc_name @rpc_name
|
@@ -9,6 +9,7 @@ Rails.application.twirp.routes.draw do
|
|
9
9
|
rpc "RaiseError", to: "pings#raise_error"
|
10
10
|
rpc "UncaughtError", to: "pings#uncaught_raise"
|
11
11
|
rpc "BeforeError", to: "pings#before_error"
|
12
|
+
rpc "RpcNameCheck", to: "dummy#rpc_name_check"
|
12
13
|
end
|
13
14
|
|
14
15
|
scope module: :testmod do
|
data/test/dummy/proto/api.proto
CHANGED
@@ -13,6 +13,7 @@ service Dummy {
|
|
13
13
|
rpc UncaughtError(PingRequest) returns (PingResponse);
|
14
14
|
rpc BeforeError(PingRequest) returns (PingResponse);
|
15
15
|
rpc Nested(PingRequest) returns (PingResponse);
|
16
|
+
rpc RpcNameCheck(RpcNameCheckRequest) returns (RpcNameCheckResponse);
|
16
17
|
}
|
17
18
|
|
18
19
|
message PingRequest {
|
@@ -22,3 +23,8 @@ message PingRequest {
|
|
22
23
|
message PingResponse {
|
23
24
|
string double_name = 2;
|
24
25
|
}
|
26
|
+
|
27
|
+
message RpcNameCheckRequest{}
|
28
|
+
message RpcNameCheckResponse{
|
29
|
+
string rpc_name = 1;
|
30
|
+
}
|
data/test/dummy/proto/api_pb.rb
CHANGED
@@ -11,6 +11,11 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
11
11
|
add_message "dummy.api.PingResponse" do
|
12
12
|
optional :double_name, :string, 2
|
13
13
|
end
|
14
|
+
add_message "dummy.api.RpcNameCheckRequest" do
|
15
|
+
end
|
16
|
+
add_message "dummy.api.RpcNameCheckResponse" do
|
17
|
+
optional :rpc_name, :string, 1
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
@@ -18,5 +23,7 @@ module RPC
|
|
18
23
|
module DummyAPI
|
19
24
|
PingRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.PingRequest").msgclass
|
20
25
|
PingResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.PingResponse").msgclass
|
26
|
+
RpcNameCheckRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.RpcNameCheckRequest").msgclass
|
27
|
+
RpcNameCheckResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.RpcNameCheckResponse").msgclass
|
21
28
|
end
|
22
29
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Code generated by protoc-gen-twirp_ruby 1.
|
1
|
+
# Code generated by protoc-gen-twirp_ruby 1.8.0, DO NOT EDIT.
|
2
2
|
require 'twirp'
|
3
3
|
require_relative 'api_pb.rb'
|
4
4
|
|
@@ -15,6 +15,7 @@ module RPC
|
|
15
15
|
rpc :UncaughtError, PingRequest, PingResponse, :ruby_method => :uncaught_error
|
16
16
|
rpc :BeforeError, PingRequest, PingResponse, :ruby_method => :before_error
|
17
17
|
rpc :Nested, PingRequest, PingResponse, :ruby_method => :nested
|
18
|
+
rpc :RpcNameCheck, RpcNameCheckRequest, RpcNameCheckResponse, :ruby_method => :rpc_name_check
|
18
19
|
end
|
19
20
|
|
20
21
|
class DummyClient < Twirp::Client
|
data/test/dummy_test.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class DummyControllerTest < RailsTwirp::IntegrationTest
|
4
|
+
test "controller gets rpc name" do
|
5
|
+
req = RPC::DummyAPI::RpcNameCheckRequest.new
|
6
|
+
rpc RPC::DummyAPI::DummyService, "RpcNameCheck", req
|
7
|
+
assert_instance_of RPC::DummyAPI::RpcNameCheckResponse, response
|
8
|
+
assert_equal "RpcNameCheck", response.rpc_name
|
9
|
+
end
|
10
|
+
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.9.0
|
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: 2021-
|
11
|
+
date: 2021-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- test/dummy/app/controllers/application_controller.rb
|
80
80
|
- test/dummy/app/controllers/application_twirp_controller.rb
|
81
81
|
- test/dummy/app/controllers/concerns/.keep
|
82
|
+
- test/dummy/app/controllers/dummy_controller.rb
|
82
83
|
- test/dummy/app/controllers/pings_controller.rb
|
83
84
|
- test/dummy/app/controllers/testmod/nested/other_controller.rb
|
84
85
|
- test/dummy/app/helpers/application_helper.rb
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- test/dummy/app/mailers/application_mailer.rb
|
89
90
|
- test/dummy/app/models/application_record.rb
|
90
91
|
- test/dummy/app/models/concerns/.keep
|
92
|
+
- test/dummy/app/views/dummy/rpc_name_check.pb.pbbuilder
|
91
93
|
- test/dummy/app/views/layouts/application.html.erb
|
92
94
|
- test/dummy/app/views/layouts/mailer.html.erb
|
93
95
|
- test/dummy/app/views/layouts/mailer.text.erb
|
@@ -131,6 +133,7 @@ files:
|
|
131
133
|
- test/dummy/public/apple-touch-icon-precomposed.png
|
132
134
|
- test/dummy/public/apple-touch-icon.png
|
133
135
|
- test/dummy/public/favicon.ico
|
136
|
+
- test/dummy_test.rb
|
134
137
|
- test/other_controller_test.rb
|
135
138
|
- test/ping_controller_test.rb
|
136
139
|
- test/rails_twirp_test.rb
|
@@ -147,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
150
|
requirements:
|
148
151
|
- - ">="
|
149
152
|
- !ruby/object:Gem::Version
|
150
|
-
version: '
|
153
|
+
version: '3'
|
151
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
155
|
requirements:
|
153
156
|
- - ">="
|
@@ -168,6 +171,7 @@ test_files:
|
|
168
171
|
- test/dummy/app/controllers/application_controller.rb
|
169
172
|
- test/dummy/app/controllers/application_twirp_controller.rb
|
170
173
|
- test/dummy/app/controllers/concerns/.keep
|
174
|
+
- test/dummy/app/controllers/dummy_controller.rb
|
171
175
|
- test/dummy/app/controllers/pings_controller.rb
|
172
176
|
- test/dummy/app/controllers/testmod/nested/other_controller.rb
|
173
177
|
- test/dummy/app/helpers/application_helper.rb
|
@@ -177,6 +181,7 @@ test_files:
|
|
177
181
|
- test/dummy/app/mailers/application_mailer.rb
|
178
182
|
- test/dummy/app/models/application_record.rb
|
179
183
|
- test/dummy/app/models/concerns/.keep
|
184
|
+
- test/dummy/app/views/dummy/rpc_name_check.pb.pbbuilder
|
180
185
|
- test/dummy/app/views/layouts/application.html.erb
|
181
186
|
- test/dummy/app/views/layouts/mailer.html.erb
|
182
187
|
- test/dummy/app/views/layouts/mailer.text.erb
|
@@ -220,6 +225,7 @@ test_files:
|
|
220
225
|
- test/dummy/public/apple-touch-icon-precomposed.png
|
221
226
|
- test/dummy/public/apple-touch-icon.png
|
222
227
|
- test/dummy/public/favicon.ico
|
228
|
+
- test/dummy_test.rb
|
223
229
|
- test/other_controller_test.rb
|
224
230
|
- test/ping_controller_test.rb
|
225
231
|
- test/rails_twirp_test.rb
|