rails_twirp 0.13.2 → 0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +8 -0
  5. data/Gemfile +2 -0
  6. data/Rakefile +2 -0
  7. data/lib/commands/twirp/routes_command.rb +2 -0
  8. data/lib/rails_twirp/application.rb +2 -0
  9. data/lib/rails_twirp/engine.rb +2 -0
  10. data/lib/rails_twirp/errors.rb +2 -0
  11. data/lib/rails_twirp/exception_handling.rb +2 -0
  12. data/lib/rails_twirp/implicit_render.rb +2 -0
  13. data/lib/rails_twirp/instrumentation.rb +2 -0
  14. data/lib/rails_twirp/log_subscriber.rb +2 -0
  15. data/lib/rails_twirp/mapper.rb +4 -2
  16. data/lib/rails_twirp/render_pb.rb +2 -0
  17. data/lib/rails_twirp/rescue.rb +2 -0
  18. data/lib/rails_twirp/route_set.rb +2 -0
  19. data/lib/rails_twirp/testing/integration_test.rb +3 -1
  20. data/lib/rails_twirp/url_for.rb +2 -0
  21. data/lib/rails_twirp/version.rb +3 -1
  22. data/lib/rails_twirp.rb +2 -0
  23. data/rails_twirp.gemspec +7 -2
  24. data/test/dummy/Rakefile +2 -0
  25. data/test/dummy/app/channels/application_cable/channel.rb +2 -0
  26. data/test/dummy/app/channels/application_cable/connection.rb +2 -0
  27. data/test/dummy/app/controllers/application_controller.rb +2 -0
  28. data/test/dummy/app/controllers/application_twirp_controller.rb +2 -0
  29. data/test/dummy/app/controllers/dummy_controller.rb +2 -0
  30. data/test/dummy/app/controllers/pings_controller.rb +2 -0
  31. data/test/dummy/app/controllers/testmod/nested/other_controller.rb +2 -0
  32. data/test/dummy/app/helpers/application_helper.rb +2 -0
  33. data/test/dummy/app/helpers/random_helper.rb +2 -0
  34. data/test/dummy/app/jobs/application_job.rb +2 -0
  35. data/test/dummy/app/mailers/application_mailer.rb +2 -0
  36. data/test/dummy/app/models/application_record.rb +2 -0
  37. data/test/dummy/config/application.rb +2 -0
  38. data/test/dummy/config/boot.rb +2 -0
  39. data/test/dummy/config/environment.rb +2 -0
  40. data/test/dummy/config/environments/development.rb +2 -0
  41. data/test/dummy/config/environments/production.rb +2 -0
  42. data/test/dummy/config/environments/test.rb +2 -0
  43. data/test/dummy/config/initializers/application_controller_renderer.rb +2 -0
  44. data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
  45. data/test/dummy/config/initializers/content_security_policy.rb +2 -0
  46. data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
  47. data/test/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  48. data/test/dummy/config/initializers/inflections.rb +2 -0
  49. data/test/dummy/config/initializers/mime_types.rb +2 -0
  50. data/test/dummy/config/initializers/permissions_policy.rb +2 -0
  51. data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
  52. data/test/dummy/config/puma.rb +4 -2
  53. data/test/dummy/config/routes.rb +2 -0
  54. data/test/dummy/config/twirp/routes.rb +2 -0
  55. data/test/dummy/config.ru +2 -0
  56. data/test/dummy/proto/api_pb.rb +2 -0
  57. data/test/dummy/proto/api_twirp.rb +2 -0
  58. data/test/dummy_test.rb +2 -0
  59. data/test/other_controller_test.rb +2 -0
  60. data/test/ping_controller_test.rb +2 -0
  61. data/test/rails_twirp_test.rb +2 -0
  62. data/test/test_helper.rb +2 -0
  63. metadata +27 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46c49b6df28547639b8c56395dfb5c9f327a4ec4b0c2b73b14cdf6b6594f1e17
4
- data.tar.gz: f232e0c6f6eac4d4034050cf6cc38a8c6bdfa6a77b260fe54a2d4473a0512350
3
+ metadata.gz: 4e1b6e06cf246cc4ab4a639ca805033c8f96a24d2a1f468b733001b5f4ca9732
4
+ data.tar.gz: 4e03e912af4c785bbe9852245ed6e763e6d398c335dd63d4d0c4c3751402b814
5
5
  SHA512:
6
- metadata.gz: e788cdd4ca43c5524ecc34f3dd43dbbbf7081689e0154133def3fcefd92955a46a3aa5abe280a44b51faef30b630f651bdcdbb00b5cade1194e83d969ddfac95
7
- data.tar.gz: 1bb844a44698a1a9d1c85f80a555191f8ce5d43a8212e5629b4bdd657b3f908a37b6b50a65d1f28913015bfb477d984c40a09a6a4ba3bf86b20f0da4914c89ae
6
+ metadata.gz: 6cdc2a1d80937bbb85a513cc4807e9a91c5bd0848d5b959e90d226477231387c0e9250ec30bf7ff8da170c8cf64ca7136bcd47deb3fb23206797749bdbe624b8
7
+ data.tar.gz: 68c342ad35489011bc921dc4c7529d5ff7a18f47fce4aef9c597cebd2a789bdcec8050b6738cad457bcb54fce0b1c9f262558a964d42b26e1063a34f73f9d250
@@ -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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.15.0
2
+
3
+ * Exclude versions of Rails 7 which were incompatible with the pbbuilder ActionView handler, as pbbuilder cannot work there at all
4
+ * Fix decode_rack_response to be compatible with Rack response body wrappers (and conform to the Rack SPEC)
5
+
6
+ ### 0.14.0
7
+ * Adding frozen_string_literal: true to all files.
8
+
1
9
  ### 0.13.2
2
10
  * revert - include `test/` folder in a final gem distribution
3
11
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in rails_twirp.gemspec.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/setup"
2
4
  require "bundler/gem_tasks"
3
5
  require "rake/testtask"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsTwirp
2
4
  module Command
3
5
  class RoutesCommand < Rails::Command::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rails_twirp/route_set"
2
4
 
3
5
  module RailsTwirp
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rails_twirp/application"
2
4
  require "rails_twirp/route_set"
3
5
  require "rails/railtie"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "twirp/error"
2
4
 
3
5
  module RailsTwirp
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "twirp/error"
2
4
 
3
5
  module RailsTwirp
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "action_controller/metal/basic_implicit_render"
2
4
 
3
5
  module RailsTwirp
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsTwirp
2
4
  module Instrumentation
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/log_subscriber"
2
4
 
3
5
  module RailsTwirp
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
 
3
5
  module RailsTwirp
@@ -57,10 +59,10 @@ module RailsTwirp
57
59
  @module = nil
58
60
  end
59
61
 
60
- def service(service_definition, **options, &block)
62
+ def service(service_definition, **, &block)
61
63
  service_route_set = @route_set.services[service_definition]
62
64
  service_mapper = ServiceMapper.new(service_route_set, self)
63
- scope(**options) { service_mapper.instance_exec(&block) }
65
+ scope(**) { service_mapper.instance_exec(&block) }
64
66
  end
65
67
 
66
68
  def scope(**options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsTwirp
2
4
  # RenderPb makes it possible to do 'render pb: <proto object>', skipping templates
3
5
  # The way this module is written is inspired by ActionController::Renderers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsTwirp
2
4
  module Rescue
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Most of this logic is stolen from Rails ActionDispatch::Routing::RouteSet
2
4
 
3
5
  require "rails_twirp/mapper"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "twirp/encoding"
2
4
 
3
5
  module RailsTwirp
@@ -89,7 +91,7 @@ module RailsTwirp
89
91
  end
90
92
 
91
93
  def decode_rack_response(service, rpc, status, headers, body)
92
- body = body.join # body is an Enumerable
94
+ body = Array.wrap(body).join # body is each-able
93
95
 
94
96
  if status === 200
95
97
  output_class = service.rpcs[rpc][:output_class]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "abstract_controller/url_for"
2
4
 
3
5
  module RailsTwirp
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsTwirp
2
- VERSION = "0.13.2"
4
+ VERSION = "0.15"
3
5
  end
data/lib/rails_twirp.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rails_twirp/version"
2
4
 
3
5
  require "rails_twirp/application"
data/rails_twirp.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "lib/rails_twirp/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -11,7 +13,10 @@ Gem::Specification.new do |spec|
11
13
 
12
14
  spec.files = `git ls-files`.split("\n")
13
15
 
14
- spec.add_dependency "rails", ">= 6.1.3"
15
- spec.add_dependency "twirp", ">= 1.9", "< 1.11"
16
+ # Rails has shipped an incompatible change in ActiveView, that was reverted in later versions.
17
+ # @see https://github.com/rails/rails/pull/51023
18
+ excluded_versions = ["7.1.0", "7.1.1", "7.1.2", "7.1.3"].map { |v| "!= #{v}" }
19
+ spec.add_runtime_dependency "rails", ">= 6.1.3", *excluded_versions
20
+ spec.add_runtime_dependency "twirp", ">= 1.9", "< 1.11"
16
21
  spec.required_ruby_version = ">= 3"
17
22
  end
data/test/dummy/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
4
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationCable
2
4
  class Channel < ActionCable::Channel::Base
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationCable
2
4
  class Connection < ActionCable::Connection::Base
3
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationController < ActionController::Base
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationTwirpController < RailsTwirp::Base
2
4
  rescue_from ActiveRecord::RecordNotFound, with: :handle_not_found
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DummyController < RailsTwirp::Base
2
4
  def rpc_name_check
3
5
  @rpc_name = rpc_name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PingsController < ApplicationTwirpController
2
4
  before_action :respond_error, only: :before_error
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Testmod
2
4
  module Nested
3
5
  class OtherController < ApplicationTwirpController
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationHelper
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RandomHelper
2
4
  def does_this_work(n)
3
5
  n * 2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationJob < ActiveJob::Base
2
4
  # Automatically retry jobs that encountered a deadlock
3
5
  # retry_on ActiveRecord::Deadlocked
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationMailer < ActionMailer::Base
2
4
  default from: "from@example.com"
3
5
  layout "mailer"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationRecord < ActiveRecord::Base
2
4
  self.abstract_class = true
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "boot"
2
4
 
3
5
  require "rails/all"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Set up gems listed in the Gemfile.
2
4
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the Rails application.
2
4
  require_relative "application"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/integer/time"
2
4
 
3
5
  Rails.application.configure do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/integer/time"
2
4
 
3
5
  Rails.application.configure do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/integer/time"
2
4
 
3
5
  # The test environment is used exclusively to run your application's
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # ActiveSupport::Reloader.to_prepare do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Define an application-wide content security policy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Specify a serializer for the signed and encrypted cookie jars.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new mime types for use in respond_to blocks:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Define an application-wide HTTP permissions policy. For further
2
4
  # information see https://developers.google.com/web/updates/2018/06/feature-policy
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Puma can serve each request in a thread from an internal thread pool.
2
4
  # The `threads` method setting takes two numbers: a minimum and maximum.
3
5
  # Any libraries that use thread pools should be configured to match
@@ -19,10 +21,10 @@ port ENV.fetch("PORT", 3000)
19
21
 
20
22
  # Specifies the `environment` that Puma will run in.
21
23
  #
22
- environment ENV.fetch("RAILS_ENV") { "development" }
24
+ environment ENV.fetch("RAILS_ENV", "development")
23
25
 
24
26
  # Specifies the `pidfile` that Puma will use.
25
- pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
27
+ pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")
26
28
 
27
29
  # Specifies the number of `workers` to boot in clustered mode.
28
30
  # Workers are forked web server processes. If using threads and workers together
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  mount RailsTwirp::Engine => "/twirp"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../../proto/api_twirp"
2
4
 
3
5
  Rails.application.twirp.routes.draw do
data/test/dummy/config.ru CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is used by Rack-based servers to start the application.
2
4
 
3
5
  require_relative "config/environment"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: api.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Code generated by protoc-gen-twirp_ruby 1.8.0, DO NOT EDIT.
2
4
  require "twirp"
3
5
  require_relative "api_pb"
data/test/dummy_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class DummyControllerTest < RailsTwirp::IntegrationTest
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class OtherControllerTest < RailsTwirp::IntegrationTest
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class PingControllerTest < RailsTwirp::IntegrationTest
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class RailsTwirpTest < ActiveSupport::TestCase
data/test/test_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Configure Rails Environment
2
4
  ENV["RAILS_ENV"] = "test"
3
5
 
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.13.2
4
+ version: '0.15'
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-01-25 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -17,6 +17,18 @@ 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.0
23
+ - - "!="
24
+ - !ruby/object:Gem::Version
25
+ version: 7.1.1
26
+ - - "!="
27
+ - !ruby/object:Gem::Version
28
+ version: 7.1.2
29
+ - - "!="
30
+ - !ruby/object:Gem::Version
31
+ version: 7.1.3
20
32
  type: :runtime
21
33
  prerelease: false
22
34
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +36,18 @@ dependencies:
24
36
  - - ">="
25
37
  - !ruby/object:Gem::Version
26
38
  version: 6.1.3
39
+ - - "!="
40
+ - !ruby/object:Gem::Version
41
+ version: 7.1.0
42
+ - - "!="
43
+ - !ruby/object:Gem::Version
44
+ version: 7.1.1
45
+ - - "!="
46
+ - !ruby/object:Gem::Version
47
+ version: 7.1.2
48
+ - - "!="
49
+ - !ruby/object:Gem::Version
50
+ version: 7.1.3
27
51
  - !ruby/object:Gem::Dependency
28
52
  name: twirp
29
53
  requirement: !ruby/object:Gem::Requirement
@@ -167,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
191
  - !ruby/object:Gem::Version
168
192
  version: '0'
169
193
  requirements: []
170
- rubygems_version: 3.2.32
194
+ rubygems_version: 3.5.3
171
195
  signing_key:
172
196
  specification_version: 4
173
197
  summary: Integrate Twirp into Rails