rails_twirp 0.13.1 → 0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +21 -0
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +2 -0
  5. data/Rakefile +2 -0
  6. data/bin/test +5 -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 +2 -0
  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 +108 -0
  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 +3 -1
  24. data/test/dummy/Rakefile +8 -0
  25. data/test/dummy/app/assets/config/manifest.js +2 -0
  26. data/test/dummy/app/assets/images/.keep +0 -0
  27. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  28. data/test/dummy/app/channels/application_cable/channel.rb +6 -0
  29. data/test/dummy/app/channels/application_cable/connection.rb +6 -0
  30. data/test/dummy/app/controllers/application_controller.rb +4 -0
  31. data/test/dummy/app/controllers/application_twirp_controller.rb +9 -0
  32. data/test/dummy/app/controllers/concerns/.keep +0 -0
  33. data/test/dummy/app/controllers/dummy_controller.rb +7 -0
  34. data/test/dummy/app/controllers/pings_controller.rb +42 -0
  35. data/test/dummy/app/controllers/testmod/nested/other_controller.rb +12 -0
  36. data/test/dummy/app/helpers/application_helper.rb +4 -0
  37. data/test/dummy/app/helpers/random_helper.rb +7 -0
  38. data/test/dummy/app/javascript/packs/application.js +15 -0
  39. data/test/dummy/app/jobs/application_job.rb +9 -0
  40. data/test/dummy/app/mailers/application_mailer.rb +6 -0
  41. data/test/dummy/app/models/application_record.rb +5 -0
  42. data/test/dummy/app/models/concerns/.keep +0 -0
  43. data/test/dummy/app/views/dummy/rpc_name_check.pb.pbbuilder +3 -0
  44. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  45. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  46. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  47. data/test/dummy/app/views/pings/ping_template.pb.pbbuilder +1 -0
  48. data/test/dummy/bin/generate +3 -0
  49. data/test/dummy/bin/rails +4 -0
  50. data/test/dummy/bin/rake +4 -0
  51. data/test/dummy/bin/setup +33 -0
  52. data/test/dummy/config/application.rb +25 -0
  53. data/test/dummy/config/boot.rb +7 -0
  54. data/test/dummy/config/cable.yml +10 -0
  55. data/test/dummy/config/database.yml +25 -0
  56. data/test/dummy/config/environment.rb +7 -0
  57. data/test/dummy/config/environments/development.rb +78 -0
  58. data/test/dummy/config/environments/production.rb +122 -0
  59. data/test/dummy/config/environments/test.rb +61 -0
  60. data/test/dummy/config/initializers/application_controller_renderer.rb +10 -0
  61. data/test/dummy/config/initializers/backtrace_silencers.rb +10 -0
  62. data/test/dummy/config/initializers/content_security_policy.rb +30 -0
  63. data/test/dummy/config/initializers/cookies_serializer.rb +7 -0
  64. data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  65. data/test/dummy/config/initializers/inflections.rb +18 -0
  66. data/test/dummy/config/initializers/mime_types.rb +6 -0
  67. data/test/dummy/config/initializers/permissions_policy.rb +13 -0
  68. data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
  69. data/test/dummy/config/locales/en.yml +33 -0
  70. data/test/dummy/config/puma.rb +45 -0
  71. data/test/dummy/config/routes.rb +5 -0
  72. data/test/dummy/config/storage.yml +34 -0
  73. data/test/dummy/config/twirp/routes.rb +24 -0
  74. data/test/dummy/config.ru +8 -0
  75. data/test/dummy/lib/assets/.keep +0 -0
  76. data/test/dummy/log/.keep +0 -0
  77. data/test/dummy/proto/api.proto +30 -0
  78. data/test/dummy/proto/api_pb.rb +31 -0
  79. data/test/dummy/proto/api_twirp.rb +27 -0
  80. data/test/dummy/public/404.html +67 -0
  81. data/test/dummy/public/422.html +67 -0
  82. data/test/dummy/public/500.html +66 -0
  83. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  84. data/test/dummy/public/apple-touch-icon.png +0 -0
  85. data/test/dummy/public/favicon.ico +0 -0
  86. data/test/dummy_test.rb +12 -0
  87. data/test/other_controller_test.rb +11 -0
  88. data/test/ping_controller_test.rb +116 -0
  89. data/test/rails_twirp_test.rb +9 -0
  90. data/test/test_helper.rb +18 -0
  91. metadata +72 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d04982e98774e2a130671b2729dad6141905df3544c7cfa3900137a7cd553356
4
- data.tar.gz: 650187fd3c34f30ca91885c6c1fa9b1547035a816d088e0b8c583f9ea6a0608e
3
+ metadata.gz: 9b7e742d4821b2a3745b2463d19aae223822eac419bd773d371f379143454d71
4
+ data.tar.gz: 1abf4446ebeea434ecdd7064a19e5ad7375c0e3e8f936af4afaf67a938923844
5
5
  SHA512:
6
- metadata.gz: 4021ee3e130f4647423177456c9ccfb5bcce728874b547f56c2ae52a78fc92a953f6e98e7dee7eb87c78adca37f4f42cd21c7761f3842f20859923a3a8b8096f
7
- data.tar.gz: bcb8240668e0c0d59f63ad7148595fcf15142533bed252e6f55212f51a73df0f31a623ca97f675c1494712631ffb025b20f71956dbfaa71ba61d9d48e12f2512
6
+ metadata.gz: 6dfdf309ddc0f01d4da60b51205de47414fc11aff123a15f1e65fdbbd31d532c9c417fe7e73f5e5a4a9c0fb0d9f030c6a758bae1fc4a40df4f776167a64a2c84
7
+ data.tar.gz: 74840175fc2b2bac370dcddb5c906f89cebf072c7b5f678baca72f4c678d45c87ff15f0cfbe62c9e7d15ac3b8904eedc99ffd4d90fdb632439c18d575ad40a95
@@ -0,0 +1,21 @@
1
+ name: Ruby Test
2
+ on: push
3
+
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Checkout code
9
+ uses: actions/checkout@v3
10
+
11
+ - name: Setup Ruby
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: 3.0.0
15
+ bundler-cache: true
16
+
17
+ - name: Run tests
18
+ run: bin/test
19
+
20
+ - name: Run standardrb
21
+ run: bundle exec standardrb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 0.14.0
2
+ * Adding frozen_string_literal: true to all files.
3
+
4
+ ### 0.13.2
5
+ * revert - include `test/` folder in a final gem distribution
6
+
1
7
  ### 0.13.1
2
8
  * Don't include `test/` folder in a final gem distribution
3
9
  * Format dummy app code with standardrb
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"
data/bin/test ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path("../test", __dir__)
3
+
4
+ require "bundler/setup"
5
+ require "rails/plugin/test"
@@ -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
@@ -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"
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "twirp/encoding"
4
+
5
+ module RailsTwirp
6
+ class IntegrationTest < ActiveSupport::TestCase
7
+ DEFAULT_HOST = "www.example.com"
8
+ Response = Struct.new(:status, :body, :headers)
9
+
10
+ attr_reader :response, :request, :controller
11
+ attr_writer :mount_path
12
+ alias_method :mount_path!, :mount_path=
13
+
14
+ def initialize(name)
15
+ super
16
+ reset!
17
+ @before_rpc = []
18
+ end
19
+
20
+ def host
21
+ @host || DEFAULT_HOST
22
+ end
23
+ attr_writer :host
24
+ alias_method :host!, :host=
25
+
26
+ def https?
27
+ @https
28
+ end
29
+
30
+ def https!(value = true)
31
+ @https = value
32
+ end
33
+
34
+ def reset!
35
+ @request = nil
36
+ @response = nil
37
+ @host = nil
38
+ @host = nil
39
+ @https = false
40
+ @mount_path = "/twirp"
41
+ end
42
+
43
+ def before_rpc(&block)
44
+ @before_rpc << block
45
+ end
46
+
47
+ def rpc(service, rpc, request, headers: nil)
48
+ @request = request
49
+
50
+ env = build_rack_env(service, rpc, request, headers)
51
+ @before_rpc.each do |hook|
52
+ hook.call(env)
53
+ end
54
+
55
+ status, headers, body = app.call(env)
56
+ @response = decode_rack_response(service, rpc, status, headers, body)
57
+ set_controller_from_rack_env(env)
58
+
59
+ @response
60
+ end
61
+
62
+ def app
63
+ RailsTwirp.test_app
64
+ end
65
+
66
+ private
67
+
68
+ def build_rack_env(service, rpc, request, headers)
69
+ env = {
70
+ "CONTENT_TYPE" => request_content_type,
71
+ "HTTPS" => https? ? "on" : "off",
72
+ "HTTP_HOST" => host,
73
+ "PATH_INFO" => "#{@mount_path}/#{service.service_full_name}/#{rpc}",
74
+ "REQUEST_METHOD" => "POST",
75
+ "SERVER_NAME" => host,
76
+ "SERVER_PORT" => https? ? "443" : "80",
77
+ "rack.url_scheme" => https? ? "https" : "http"
78
+ }
79
+ if headers.present?
80
+ http_request = ActionDispatch::Request.new(env)
81
+ http_request.headers.merge! headers
82
+ end
83
+
84
+ input_class = service.rpcs[rpc][:input_class]
85
+ env["rack.input"] = StringIO.new(Twirp::Encoding.encode(request, input_class, request_content_type))
86
+ env
87
+ end
88
+
89
+ def request_content_type
90
+ Twirp::Encoding::PROTO
91
+ end
92
+
93
+ def decode_rack_response(service, rpc, status, headers, body)
94
+ body = body.join # body is an Enumerable
95
+
96
+ if status === 200
97
+ output_class = service.rpcs[rpc][:output_class]
98
+ Twirp::Encoding.decode(body, output_class, headers["Content-Type"])
99
+ else
100
+ Twirp::Client.error_from_response(Response.new(status, body, headers))
101
+ end
102
+ end
103
+
104
+ def set_controller_from_rack_env(env)
105
+ @controller = ActionDispatch::Request.new(env).controller_instance
106
+ end
107
+ end
108
+ end
@@ -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.1"
4
+ VERSION = "0.14"
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|
@@ -9,7 +11,7 @@ Gem::Specification.new do |spec|
9
11
  spec.summary = "Integrate Twirp into Rails"
10
12
  spec.license = "MIT"
11
13
 
12
- spec.files = `git ls-files | grep -v -E "test/*"`.split("\n")
14
+ spec.files = `git ls-files`.split("\n")
13
15
 
14
16
  spec.add_dependency "rails", ">= 6.1.3"
15
17
  spec.add_dependency "twirp", ">= 1.9", "< 1.11"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative "config/application"
7
+
8
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Channel < ActionCable::Channel::Base
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Connection < ActionCable::Connection::Base
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationTwirpController < RailsTwirp::Base
4
+ rescue_from ActiveRecord::RecordNotFound, with: :handle_not_found
5
+
6
+ def handle_not_found
7
+ error :not_found, "Not found"
8
+ end
9
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DummyController < RailsTwirp::Base
4
+ def rpc_name_check
5
+ @rpc_name = rpc_name
6
+ end
7
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PingsController < ApplicationTwirpController
4
+ before_action :respond_error, only: :before_error
5
+
6
+ def ping
7
+ response = RPC::DummyAPI::PingResponse.new(double_name: request.name * 2)
8
+ self.response_body = response
9
+ end
10
+
11
+ def ping_render
12
+ url = rails_twirp_engine_url
13
+ response = RPC::DummyAPI::PingResponse.new(double_name: "#{url} #{helpers.does_this_work(request.name)}")
14
+ render pb: response
15
+ end
16
+
17
+ def ping_template
18
+ @double_name = request.name * 2
19
+ end
20
+
21
+ def error_response
22
+ error :unauthenticated, "You are not authenticated!!"
23
+ end
24
+
25
+ def raise_error
26
+ # This error is rescued in ApplicationTwirpController
27
+ raise ActiveRecord::RecordNotFound, "Not found"
28
+ end
29
+
30
+ def uncaught_raise
31
+ raise StandardError, "Uncaught"
32
+ end
33
+
34
+ def before_error
35
+ # This error won't be reached because of the before_action
36
+ raise NotImplementedError
37
+ end
38
+
39
+ def respond_error
40
+ error :malformed, "yOuR ReQuEsT Is mAlFoRmEd"
41
+ end
42
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Testmod
4
+ module Nested
5
+ class OtherController < ApplicationTwirpController
6
+ def ping
7
+ response = RPC::DummyAPI::PingResponse.new(double_name: request.name * 2)
8
+ self.response_body = response
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RandomHelper
4
+ def does_this_work(n)
5
+ n * 2
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require activestorage
15
+ //= require_tree .
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationJob < ActiveJob::Base
4
+ # Automatically retry jobs that encountered a deadlock
5
+ # retry_on ActiveRecord::Deadlocked
6
+
7
+ # Most jobs are safe to ignore if the underlying records are no longer available
8
+ # discard_on ActiveJob::DeserializationError
9
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: "from@example.com"
5
+ layout "mailer"
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ pb.cache! "rpc-#{@rpc_name}", expire_in: 1.minute do
2
+ pb.rpc_name @rpc_name
3
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+
9
+ <%= stylesheet_link_tag 'application', media: 'all' %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1 @@
1
+ pb.double_name @double_name
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ protoc --twirp_ruby_out=proto/ --ruby_out=proto/ -I proto/ proto/api.proto
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path("..", __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?('config/database.yml')
22
+ # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! "bin/rails db:prepare"
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! "bin/rails log:clear tmp:clear"
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! "bin/rails restart"
33
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "boot"
4
+
5
+ require "rails/all"
6
+
7
+ require "rails_twirp/engine"
8
+
9
+ # Require the gems listed in Gemfile, including any gems
10
+ # you've limited to :test, :development, or :production.
11
+ Bundler.require(*Rails.groups)
12
+
13
+ module Dummy
14
+ class Application < Rails::Application
15
+ config.load_defaults Rails::VERSION::STRING.to_f
16
+
17
+ # Configuration for the application, engines, and railties goes here.
18
+ #
19
+ # These settings can be overridden in specific environments using the files
20
+ # in config/environments, which are processed later.
21
+ #
22
+ # config.time_zone = "Central Time (US & Canada)"
23
+ # config.eager_load_paths << Rails.root.join("extras")
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
5
+
6
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
7
+ $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: dummy_production