rails_twirp 0.12.0 → 0.13.0

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: '09e97be65f570cd7a2cecaaf0ef83d2ead287fd1fc8c556b833ae45395ee1c2b'
4
- data.tar.gz: 1b30d280c8c724747b0b71ef7996ad23fd0a8e189818156602f284677ac9c637
3
+ metadata.gz: 6af836779332d2bcf1810379884b7ef9e219f63e81b2972b501a45ae1880f1cb
4
+ data.tar.gz: b0a967815e9326fa7889fdf1f3ec77b08f835921b8a919cee5cc95150407aa20
5
5
  SHA512:
6
- metadata.gz: 858ea0680c3efd03f2f1fdc766f6097b6e0a7b19ff39974412207139cd28a432d4c620a7a4f9243b63b9f70eff1919cb5a92d0c3dc6b5cd73ba99eb1349ac870
7
- data.tar.gz: ba6311d0b7cb64755380eff9d1168d24458d5804f36acf21c7fceab2a8b0db305722353d8c5f493bf1692225f973342e3194f825d995df286802da6958631e3a
6
+ metadata.gz: 139e2f8517c0e1b2664b0d264d4722ebdc74fde78bfdb9724ea03d31d80ab99eec66a304a25bfaec23e17ed032b5396406742993ebabc2fc464c3eea338dd5bd
7
+ data.tar.gz: 4df604dc7f1772238a2ea95b3e573aa352b354a58a92f9caa157add1889ba59dd95d8bbab9283dbf9632b807514c28fc21eca913b03f0bb254d57eadfbef200b
@@ -6,7 +6,7 @@ jobs:
6
6
  runs-on: ubuntu-latest
7
7
  steps:
8
8
  - name: Checkout code
9
- uses: actions/checkout@v2
9
+ uses: actions/checkout@v3
10
10
 
11
11
  - name: Setup Ruby
12
12
  uses: ruby/setup-ruby@v1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.13.0
2
+ * Adding #controller_name methods to Metal/Base controller (used for instrumentation)
3
+ * Include `ActionController::Caching` with Base controller/helpers
4
+
5
+
1
6
  ### 0.12.0
2
7
 
3
8
  * Allow a custom exception handling proc to be assigned using `RailsTwirp.unhandled_exception_handler`
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem "sqlite3"
7
- gem "pbbuilder", "~> 0.12.0"
7
+ gem "pbbuilder"
8
8
  gem "standard"
9
9
  gem "pry"
10
10
 
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "abstract_controller/base"
2
4
  require "abstract_controller/rendering"
3
5
  require "action_view/rendering"
4
6
  require "rails_twirp/render_pb"
5
7
  require "rails_twirp/errors"
6
8
  require "abstract_controller/asset_paths"
7
- require "abstract_controller/caching"
8
9
  require "abstract_controller/logger"
9
10
  require "abstract_controller/callbacks"
10
11
  require "action_controller/metal/helpers"
@@ -13,11 +14,10 @@ require "rails_twirp/url_for"
13
14
  require "rails_twirp/implicit_render"
14
15
  require "rails_twirp/instrumentation"
15
16
  require "rails_twirp/exception_handling"
17
+ require "rails_twirp/metal"
16
18
 
17
19
  module RailsTwirp
18
- class Base < AbstractController::Base
19
- abstract!
20
-
20
+ class Base < RailsTwirp::Metal
21
21
  # The order of these includes matter.
22
22
  # The rendering modules extend each other, so need to be in this order.
23
23
  include AbstractController::Rendering
@@ -26,7 +26,6 @@ module RailsTwirp
26
26
  include ActionController::Helpers
27
27
  include UrlFor
28
28
  include AbstractController::AssetPaths
29
- include AbstractController::Caching
30
29
 
31
30
  include ActionView::Rendering
32
31
  include RenderPb
@@ -39,7 +38,14 @@ module RailsTwirp
39
38
  include Instrumentation
40
39
  include ExceptionHandling
41
40
 
42
- attr_internal :request, :env, :response_class, :rpc_name
41
+ ##
42
+ # :attr_reader: request
43
+ #
44
+ # The ActionDispatch::Request instance for the current request.
45
+ attr_internal :request
46
+
47
+ attr_internal :env, :response_class, :rpc_name
48
+
43
49
  def initialize
44
50
  @_request = nil
45
51
  @_env = nil
@@ -34,7 +34,11 @@ module RailsTwirp
34
34
 
35
35
  initializer "rails_twirp.helpers" do |app|
36
36
  ActiveSupport.on_load(:rails_twirp) do
37
- # Load all the application helpers into the controller
37
+ # Load all the application helpers into the controller.
38
+ # Note that helpers need to be set up here, because apparently
39
+ # the AbstractController::Helpers module won't be able to find
40
+ # the _helpers method on a reloaded controller
41
+ include ActionController::Caching
38
42
  include app.routes.mounted_helpers
39
43
  extend ::AbstractController::Railties::RoutesHelpers.with(app.routes, false)
40
44
  extend ::ActionController::Railties::Helpers
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsTwirp
4
+ # This is a simplest possible controller, providing a valid
5
+ # Rack interfacee without the additional niceties provided by RailsTwirp.
6
+ #
7
+ # Idiologially, it's similar to Rails version of ActionController::Metal
8
+ class Metal < AbstractController::Base
9
+ abstract!
10
+
11
+ # Returns the last part of the controller's name, underscored, without the ending
12
+ # <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>.
13
+ # Namespaces are left out, so Admin::PostsController returns <tt>posts</tt> as well.
14
+ #
15
+ # ==== Returns
16
+ # * <tt>string</tt>
17
+ def self.controller_name
18
+ @controller_name ||= (name.demodulize.delete_suffix("Controller").underscore unless anonymous?)
19
+ end
20
+
21
+ # Delegates to the class's ::controller_name.
22
+ def controller_name
23
+ self.class.controller_name
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsTwirp
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
data/rails_twirp.gemspec CHANGED
@@ -10,7 +10,6 @@ Gem::Specification.new do |spec|
10
10
  spec.license = "MIT"
11
11
 
12
12
  spec.files = `git ls-files`.split("\n")
13
- spec.test_files = `git ls-files -- test/*`.split("\n")
14
13
 
15
14
  spec.add_dependency "rails", ">= 6.1.3"
16
15
  spec.add_dependency "twirp", ">= 1.7.2", "~> 1.9.0"
@@ -1 +1,3 @@
1
- pb.rpc_name @rpc_name
1
+ pb.cache! "rpc-#{@rpc_name}", expire_in: 1.minute do
2
+ pb.rpc_name @rpc_name
3
+ 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.12.0
4
+ version: 0.13.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: 2022-01-26 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -73,6 +73,7 @@ files:
73
73
  - lib/rails_twirp/instrumentation.rb
74
74
  - lib/rails_twirp/log_subscriber.rb
75
75
  - lib/rails_twirp/mapper.rb
76
+ - lib/rails_twirp/metal.rb
76
77
  - lib/rails_twirp/render_pb.rb
77
78
  - lib/rails_twirp/rescue.rb
78
79
  - lib/rails_twirp/route_set.rb
@@ -170,71 +171,4 @@ rubygems_version: 3.2.32
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: Integrate Twirp into Rails
173
- test_files:
174
- - test/dummy/Rakefile
175
- - test/dummy/app/assets/config/manifest.js
176
- - test/dummy/app/assets/images/.keep
177
- - test/dummy/app/assets/stylesheets/application.css
178
- - test/dummy/app/channels/application_cable/channel.rb
179
- - test/dummy/app/channels/application_cable/connection.rb
180
- - test/dummy/app/controllers/application_controller.rb
181
- - test/dummy/app/controllers/application_twirp_controller.rb
182
- - test/dummy/app/controllers/concerns/.keep
183
- - test/dummy/app/controllers/dummy_controller.rb
184
- - test/dummy/app/controllers/pings_controller.rb
185
- - test/dummy/app/controllers/testmod/nested/other_controller.rb
186
- - test/dummy/app/helpers/application_helper.rb
187
- - test/dummy/app/helpers/random_helper.rb
188
- - test/dummy/app/javascript/packs/application.js
189
- - test/dummy/app/jobs/application_job.rb
190
- - test/dummy/app/mailers/application_mailer.rb
191
- - test/dummy/app/models/application_record.rb
192
- - test/dummy/app/models/concerns/.keep
193
- - test/dummy/app/views/dummy/rpc_name_check.pb.pbbuilder
194
- - test/dummy/app/views/layouts/application.html.erb
195
- - test/dummy/app/views/layouts/mailer.html.erb
196
- - test/dummy/app/views/layouts/mailer.text.erb
197
- - test/dummy/app/views/pings/ping_template.pb.pbbuilder
198
- - test/dummy/bin/generate
199
- - test/dummy/bin/rails
200
- - test/dummy/bin/rake
201
- - test/dummy/bin/setup
202
- - test/dummy/config.ru
203
- - test/dummy/config/application.rb
204
- - test/dummy/config/boot.rb
205
- - test/dummy/config/cable.yml
206
- - test/dummy/config/database.yml
207
- - test/dummy/config/environment.rb
208
- - test/dummy/config/environments/development.rb
209
- - test/dummy/config/environments/production.rb
210
- - test/dummy/config/environments/test.rb
211
- - test/dummy/config/initializers/application_controller_renderer.rb
212
- - test/dummy/config/initializers/backtrace_silencers.rb
213
- - test/dummy/config/initializers/content_security_policy.rb
214
- - test/dummy/config/initializers/cookies_serializer.rb
215
- - test/dummy/config/initializers/filter_parameter_logging.rb
216
- - test/dummy/config/initializers/inflections.rb
217
- - test/dummy/config/initializers/mime_types.rb
218
- - test/dummy/config/initializers/permissions_policy.rb
219
- - test/dummy/config/initializers/wrap_parameters.rb
220
- - test/dummy/config/locales/en.yml
221
- - test/dummy/config/puma.rb
222
- - test/dummy/config/routes.rb
223
- - test/dummy/config/storage.yml
224
- - test/dummy/config/twirp/routes.rb
225
- - test/dummy/lib/assets/.keep
226
- - test/dummy/log/.keep
227
- - test/dummy/proto/api.proto
228
- - test/dummy/proto/api_pb.rb
229
- - test/dummy/proto/api_twirp.rb
230
- - test/dummy/public/404.html
231
- - test/dummy/public/422.html
232
- - test/dummy/public/500.html
233
- - test/dummy/public/apple-touch-icon-precomposed.png
234
- - test/dummy/public/apple-touch-icon.png
235
- - test/dummy/public/favicon.ico
236
- - test/dummy_test.rb
237
- - test/other_controller_test.rb
238
- - test/ping_controller_test.rb
239
- - test/rails_twirp_test.rb
240
- - test/test_helper.rb
174
+ test_files: []