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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 394816fb648167ae3e089e6e16e93c72f985b5eb540182ff026b8bb283bfa8d8
4
- data.tar.gz: a86a22b695b81fcaf0d93e5df2c33dff327c4fe0c2b54a2cc36c8a5c9a5a4eba
3
+ metadata.gz: e1ac2840887dd15ea43114d7b0d25901c05e3288fa10d6cdcd8d00d4dabc8e74
4
+ data.tar.gz: 59ff25b65ad6bd62f1ebc537bc11017da58b6ce6e1f4a74cae9e1c7f35454508
5
5
  SHA512:
6
- metadata.gz: 7d0c19ce26c7e5bf06cd9172b9e257dda0ac87f1dec2b6ba6c2b3ecda3aa26664c2319097dc7cf584e3e59316291ec5b7fef59be33ad0564719e2c59aba41ba9
7
- data.tar.gz: 878e8240c50b77f737df1e0d950a4c74d16f06e5fdcd58edccaf00c8471f4f11d645c3e4f8eb5322a500426b4c259ebb028fb389d96608accc74e570e3843866
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
 
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module RailsTwirp
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
data/rails_twirp.gemspec CHANGED
@@ -14,4 +14,5 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.add_dependency "rails", ">= 6.1.3"
16
16
  spec.add_dependency "twirp", "~> 1.7.2"
17
+ spec.required_ruby_version = ">= 3"
17
18
  end
@@ -0,0 +1,5 @@
1
+ class DummyController < RailsTwirp::Base
2
+ def rpc_name_check
3
+ @rpc_name = rpc_name
4
+ end
5
+ end
@@ -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
@@ -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
+ }
@@ -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.6.0, DO NOT EDIT.
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
@@ -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.8.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-10-18 00:00:00.000000000 Z
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: '0'
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