tarquinn 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +85 -0
  3. data/.gitignore +10 -0
  4. data/.rubocop.yml +29 -0
  5. data/.rubocop_todo.yml +13 -0
  6. data/Dockerfile +21 -0
  7. data/Gemfile +16 -2
  8. data/README.md +16 -0
  9. data/Rakefile +8 -3
  10. data/config/check_specs.yml +3 -0
  11. data/config/rubycritc.rb +12 -0
  12. data/config/yardstick.rb +13 -0
  13. data/config/yardstick.yml +33 -0
  14. data/docker-compose.yml +23 -0
  15. data/lib/tarquinn/class_methods.rb +43 -12
  16. data/lib/tarquinn/condition/action_checker.rb +24 -7
  17. data/lib/tarquinn/condition/method_caller.rb +25 -8
  18. data/lib/tarquinn/condition/proc_runner.rb +18 -7
  19. data/lib/tarquinn/condition.rb +57 -4
  20. data/lib/tarquinn/controller.rb +56 -13
  21. data/lib/tarquinn/redirection_config.rb +92 -0
  22. data/lib/tarquinn/redirection_handler.rb +97 -0
  23. data/lib/tarquinn/request_handler.rb +61 -0
  24. data/lib/tarquinn/request_handler_builder.rb +84 -0
  25. data/lib/tarquinn/version.rb +3 -1
  26. data/lib/tarquinn.rb +74 -8
  27. data/spec/dummy/Rakefile +8 -0
  28. data/spec/dummy/app/assets/images/.keep +0 -0
  29. data/spec/dummy/app/assets/stylesheets/application.css +1 -0
  30. data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
  31. data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
  32. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  33. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  34. data/spec/dummy/app/controllers/tarquinn/dummy_controller.rb +43 -0
  35. data/spec/dummy/app/controllers/tarquinn/dummy_route_controller.rb +37 -0
  36. data/spec/dummy/app/helpers/application_helper.rb +4 -0
  37. data/spec/dummy/app/jobs/application_job.rb +9 -0
  38. data/spec/dummy/app/mailers/application_mailer.rb +6 -0
  39. data/spec/dummy/app/models/application_record.rb +5 -0
  40. data/spec/dummy/app/models/concerns/.keep +0 -0
  41. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  42. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  43. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  44. data/spec/dummy/app/views/tarquinn/dummy_route/index.html +0 -0
  45. data/spec/dummy/app/views/tarquinn/dummy_route/new.html +0 -0
  46. data/spec/dummy/bin/rails +6 -0
  47. data/spec/dummy/bin/rake +6 -0
  48. data/spec/dummy/bin/setup +35 -0
  49. data/spec/dummy/config/application.rb +24 -0
  50. data/spec/dummy/config/boot.rb +7 -0
  51. data/spec/dummy/config/cable.yml +10 -0
  52. data/spec/dummy/config/database.yml +25 -0
  53. data/spec/dummy/config/environment.rb +7 -0
  54. data/spec/dummy/config/environments/development.rb +69 -0
  55. data/spec/dummy/config/environments/production.rb +89 -0
  56. data/spec/dummy/config/environments/test.rb +62 -0
  57. data/spec/dummy/config/initializers/content_security_policy.rb +26 -0
  58. data/spec/dummy/config/initializers/filter_parameter_logging.rb +10 -0
  59. data/spec/dummy/config/initializers/inflections.rb +17 -0
  60. data/spec/dummy/config/initializers/permissions_policy.rb +12 -0
  61. data/spec/dummy/config/locales/en.yml +33 -0
  62. data/spec/dummy/config/puma.rb +45 -0
  63. data/spec/dummy/config/routes.rb +8 -0
  64. data/spec/dummy/config/storage.yml +34 -0
  65. data/spec/dummy/config.ru +8 -0
  66. data/spec/dummy/db/schema.rb +16 -0
  67. data/spec/dummy/lib/assets/.keep +0 -0
  68. data/spec/dummy/log/.keep +0 -0
  69. data/spec/dummy/public/404.html +67 -0
  70. data/spec/dummy/public/422.html +67 -0
  71. data/spec/dummy/public/500.html +66 -0
  72. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  73. data/spec/dummy/public/apple-touch-icon.png +0 -0
  74. data/spec/dummy/public/favicon.ico +0 -0
  75. data/spec/dummy/storage/.keep +0 -0
  76. data/spec/dummy/tmp/.keep +0 -0
  77. data/spec/dummy/tmp/pids/.keep +0 -0
  78. data/spec/dummy/tmp/storage/.keep +0 -0
  79. data/spec/lib/tarquinn/condition/action_checker_spec.rb +4 -2
  80. data/spec/lib/tarquinn/condition/method_caller_spec.rb +5 -3
  81. data/spec/lib/tarquinn/condition/proc_runner_spec.rb +56 -4
  82. data/spec/lib/tarquinn/condition_spec.rb +53 -0
  83. data/spec/lib/tarquinn/controller_spec.rb +83 -10
  84. data/spec/lib/tarquinn/{config_spec.rb → redirection_config_spec.rb} +3 -1
  85. data/spec/lib/tarquinn/{handler_spec.rb → redirection_handler_spec.rb} +21 -3
  86. data/spec/lib/tarquinn/request_handler_builder_spec.rb +15 -0
  87. data/spec/lib/tarquinn/{engine_spec.rb → request_handler_spec.rb} +5 -3
  88. data/spec/lib/tarquinn_spec.rb +176 -13
  89. data/spec/spec_helper.rb +17 -7
  90. data/spec/support/shared_examples/config.rb +5 -4
  91. data/tarquinn.gemspec +10 -14
  92. data/tarquinn.jpg +0 -0
  93. metadata +83 -107
  94. data/Gemfile.lock +0 -58
  95. data/lib/tarquinn/builder.rb +0 -28
  96. data/lib/tarquinn/concern.rb +0 -17
  97. data/lib/tarquinn/config.rb +0 -39
  98. data/lib/tarquinn/engine.rb +0 -31
  99. data/lib/tarquinn/handler.rb +0 -49
  100. data/spec/lib/tarquinn/builder_spec.rb +0 -13
  101. data/spec/support/models/tarquinn/dummy_controller.rb +0 -43
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tarquinn
4
+ # @api private
5
+ #
6
+ # Redirection configuration
7
+ #
8
+ # @see Tarquinn::RequestHandler
9
+ class RedirectionConfig
10
+ attr_reader :redirect
11
+
12
+ # @param redirect [Symbol] redirection name and redirection method
13
+ def initialize(redirect)
14
+ @redirect = redirect
15
+ end
16
+
17
+ # Adds conditions to the rule
18
+ #
19
+ # The rule name defines which method will be called when checking the path of redirection
20
+ #
21
+ # @param methods [Array<Symbol>] Methods that tell that a redirection should be applied
22
+ # @param block [Proc] block that tells if a the redirection should be applied
23
+ #
24
+ # @return [Array<Tarquinn::Condition>] Current registered conditions
25
+ def add_redirection_rules(*methods, &block)
26
+ redirect_on method_caller(methods)
27
+ redirect_on proc_runner(&block)
28
+ end
29
+
30
+ # Add rule for skipping on some actions / routes
31
+ #
32
+ # @param actions [Array<Symbol>] actions / routes to be skipped by redirection rule
33
+ #
34
+ # @return [Array<Tarquinn::Condition>]
35
+ def add_skip_action(*actions)
36
+ skip action_checker(actions)
37
+ end
38
+
39
+ # Attaches conditions to skip a redirection
40
+ #
41
+ # Methods and blocks are ran and if any returns true, the redirec is skipped
42
+ #
43
+ # @param methods [Array<Symbol>] Methods that tell that a redirection should be skipped
44
+ # @param block [Proc] block that tells if a the redirection should be skipped
45
+ #
46
+ # @return [Array] Current registered conditions
47
+ def add_skip_rules(*methods, &block)
48
+ skip method_caller(methods)
49
+ skip proc_runner(&block)
50
+ end
51
+
52
+ # All blocks that indicate a redirection
53
+ #
54
+ # @return [Array<Tarquinn::Condition>]
55
+ def redirection_blocks
56
+ @redirection_blocks ||= []
57
+ end
58
+
59
+ # All blocks that indicate a redirection should be skipped
60
+ #
61
+ # @return [Array<Tarquinn::Condition>]
62
+ def skip_blocks
63
+ @skip_blocks ||= []
64
+ end
65
+
66
+ private
67
+
68
+ delegate :method_caller, :action_checker, :proc_runner, to: Tarquinn::Condition
69
+
70
+ # @private
71
+ #
72
+ # Adds a condition to skip a redirection
73
+ #
74
+ # @return (see #skip_blocks)
75
+ def skip(condition)
76
+ return skip_blocks unless condition
77
+
78
+ skip_blocks << condition
79
+ end
80
+
81
+ # @private
82
+ #
83
+ # Adds a condition to a redirection
84
+ #
85
+ # @return (see #redirection_blocks)
86
+ def redirect_on(condition)
87
+ return redirection_blocks unless condition
88
+
89
+ redirection_blocks << condition
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tarquinn
4
+ # @api private
5
+ #
6
+ # Redirect config handler
7
+ #
8
+ # Checks if one redirection rule should or should not be applied
9
+ class RedirectionHandler
10
+ # @param config [Tarquinn::RedirectionConfig] redirection configuration
11
+ # @param controller [Tarquinn::Controller] controller interface
12
+ def initialize(config, controller)
13
+ @config = config
14
+ @controller = controller
15
+ end
16
+
17
+ # Checks if redirection should be performd
18
+ #
19
+ # @return [TrueClass] when redirection should be performed
20
+ # @return [FalseClass] when redirection should not be performed
21
+ def perform_redirect?
22
+ return perform_redirect if instance_variable_defined?(:@perform_redirect)
23
+
24
+ @perform_redirect = redirect?
25
+ end
26
+
27
+ # Performs redirction to a new route
28
+ #
29
+ # @return [String] redirection body
30
+ def redirect
31
+ controller.call(:redirect_to, redirect_path)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :config, :controller, :perform_redirect
37
+
38
+ delegate :redirection_blocks, :skip_blocks, to: :config
39
+
40
+ # Returns method in the controller that returns the redirection path
41
+ #
42
+ # @return [Symbol] method name
43
+ def redirect_method
44
+ config.redirect
45
+ end
46
+
47
+ # Returns the redirection path
48
+ #
49
+ # when redirection path method does not exist, then then
50
+ # the redirection name is used
51
+ #
52
+ # @return [String]
53
+ def redirect_path
54
+ return redirect_method unless controller.method?(redirect_method)
55
+
56
+ controller.call redirect_method
57
+ end
58
+
59
+ # Checks if a redirection should be performd
60
+ #
61
+ # @return [TrueClass]
62
+ # @return [FalseClass]
63
+ def redirect?
64
+ return false if blocks_skip_redirect?
65
+
66
+ blocks_require_redirect?
67
+ end
68
+
69
+ # Checks if redirection should be skipped
70
+ #
71
+ # @return [TrueClass]
72
+ # @return [FalseClass]
73
+ def blocks_skip_redirect?
74
+ check_blocks(skip_blocks)
75
+ end
76
+
77
+ # Checks if redirection should be applied (not concerning the skip blocks)
78
+ #
79
+ # @return [TrueClass]
80
+ # @return [FalseClass]
81
+ def blocks_require_redirect?
82
+ return true if redirection_blocks.empty?
83
+
84
+ check_blocks(redirection_blocks)
85
+ end
86
+
87
+ # Check if any condition returns positive
88
+ #
89
+ # @return [TrueClass]
90
+ # @return [FalseClass]
91
+ def check_blocks(blocks)
92
+ blocks.any? do |block|
93
+ block.check?(controller)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tarquinn
4
+ # @api private
5
+ #
6
+ # RequestHandler processing a request defining the flow
7
+ class RequestHandler
8
+ # @method configs
9
+ # @api private
10
+ #
11
+ # All redirect configs
12
+ #
13
+ # @return [Hash<Symbol,Tarquinn::RedirectionConfig>]
14
+
15
+ # @method controller
16
+ #
17
+ # Controller interface
18
+ #
19
+ # @return [Tarquinn::Controller]
20
+
21
+ # @param configs [Hash<Symbol,Tarquinn::RedirectionConfig>] All redirect configs
22
+ # @param controller [Tarquinn::Controller] Controller interface
23
+ def initialize(configs, controller)
24
+ @configs = configs
25
+ @controller = controller
26
+ end
27
+
28
+ # Performs redirection if enabled / needed
29
+ #
30
+ # The rules / configuratons are processed in order
31
+ # and if any is positive, it will be processed
32
+ #
33
+ # @return [NilClass] Nothing when no redirection is performed
34
+ # @return [String] The result of the redirection
35
+ def perform_redirect
36
+ return unless perform_redirect?
37
+
38
+ handler_redirector.redirect
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :configs, :controller
44
+
45
+ def perform_redirect?
46
+ handler_redirector.present?
47
+ end
48
+
49
+ def handler_redirector
50
+ @handler_redirector ||= handlers.find(&:perform_redirect?)
51
+ end
52
+
53
+ def handlers
54
+ @handlers ||= build_handlers
55
+ end
56
+
57
+ def build_handlers
58
+ configs.values.map { |config| Tarquinn::RedirectionHandler.new(config, controller) }
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tarquinn
4
+ # @api private
5
+ #
6
+ # Redirections rules builder
7
+ #
8
+ # @see Tarquinn::RedirectionConfig
9
+ # @see Tarquinn::RequestHandler
10
+ # @see Tarquinn::Controller
11
+ class RequestHandlerBuilder
12
+ # Creates a redirection rule
13
+ #
14
+ # The rule name defines which method will be called when checking the path of redirection
15
+ #
16
+ # @param redirection [Symbol] Rule name and method with redirection path
17
+ # @param (see Tarquinn::RedirectionConfig#add_redirection_rules)
18
+ #
19
+ # @return (see Tarquinn::RedirectionConfig#add_redirection_rules)
20
+ def add_redirection_config(redirection, *methods, &block)
21
+ config_for(redirection).add_redirection_rules(*methods, &block)
22
+ end
23
+
24
+ # Attaches a condition to skip a redirection based on route (controller action)
25
+ #
26
+ # When any of the skip rules is met the redirection is skipped
27
+ #
28
+ # @param redirection [Symbol] Rule name to attach the skip condition
29
+ # @param (see Tarquinn::RedirectionConfig#add_skip_action)
30
+ #
31
+ # @return (see Tarquinn::RedirectionConfig#add_skip_action)
32
+ def add_skip_action(redirection, *actions)
33
+ config_for(redirection).add_skip_action(*actions)
34
+ end
35
+
36
+ # Attaches conditions to skip a redirection
37
+ #
38
+ # Methods and blocks are ran and if any returns true, the redirec is skipped
39
+ #
40
+ # @param redirection [Symbol] Rule name to attach the skip condition
41
+ # @param (see Tarquinn::RedirectionConfig#add_skip_rules)
42
+ #
43
+ # @return (see Tarquinn::RedirectionConfig#add_skip_rules)
44
+ def add_skip_config(redirection, *methods, block)
45
+ config_for(redirection).add_skip_rules(*methods, &block)
46
+ end
47
+
48
+ # Builds a new engine to process a request
49
+ #
50
+ # @param controller [ActionController::Base] Controller handling the request
51
+ #
52
+ # @return [Tarquinn::RequestHandler]
53
+ def build(controller)
54
+ controller = Tarquinn::Controller.new(controller)
55
+ Tarquinn::RequestHandler.new(configs, controller)
56
+ end
57
+
58
+ private
59
+
60
+ # @api private
61
+ # @private
62
+ #
63
+ # Returns the configuration for one redirection
64
+ #
65
+ # When none is configured, a new one is created
66
+ #
67
+ # @param redirection [Symbol] redirection_name
68
+ #
69
+ # @return [Tarquinn::RedirectionConfig]
70
+ def config_for(redirection)
71
+ configs[redirection.to_sym] ||= Tarquinn::RedirectionConfig.new(redirection)
72
+ end
73
+
74
+ # @api private
75
+ # @private
76
+ #
77
+ # Returns all configurations for all redirections for the controller
78
+ #
79
+ # @return [Hash<Symbol,Tarquinn::RedirectionConfig>]
80
+ def configs
81
+ @configs ||= {}
82
+ end
83
+ end
84
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tarquinn
2
- VERSION = '0.1.0'
4
+ VERSION = '0.3.0'
3
5
  end
data/lib/tarquinn.rb CHANGED
@@ -1,14 +1,80 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'active_support/core_ext'
3
5
 
6
+ # @api public
7
+ #
8
+ # Concern adding methods for easy redirection controll
4
9
  module Tarquinn
5
- require 'tarquinn/version'
6
- require 'tarquinn/handler'
7
- require 'tarquinn/controller'
8
- require 'tarquinn/condition'
9
- require 'tarquinn/config'
10
- require 'tarquinn/engine'
11
- require 'tarquinn/builder'
10
+ extend ActiveSupport::Concern
11
+
12
+ autoload :Version, 'tarquinn/version'
13
+ autoload :RedirectionHandler, 'tarquinn/redirection_handler'
14
+ autoload :Controller, 'tarquinn/controller'
15
+ autoload :Condition, 'tarquinn/condition'
16
+ autoload :RedirectionConfig, 'tarquinn/redirection_config'
17
+ autoload :RequestHandler, 'tarquinn/request_handler'
18
+ autoload :RequestHandlerBuilder, 'tarquinn/request_handler_builder'
19
+
12
20
  require 'tarquinn/class_methods'
13
- require 'tarquinn/concern'
21
+
22
+ # @method self.redirection_rule(redirection, *methods, &block)
23
+ #
24
+ # Creates a redirection rule
25
+ #
26
+ # The rule name defines which method will be called when checking the path of redirection
27
+ #
28
+ # @param (see Tarquinn::ClassMethods#redirection_rule)
29
+ # @return (see Tarquinn::ClassMethods#redirection_rule)
30
+
31
+ # @method self.skip_redirection(redirection, *actions)
32
+ #
33
+ # Attaches a condition to skip a redirection based on route (controller action)
34
+ #
35
+ # When any of the skip rules is met the redirection is skipped
36
+ #
37
+ # @param (see Tarquinn::ClassMethods#skip_redirection)
38
+ # @return (see Tarquinn::ClassMethods#skip_redirection)
39
+
40
+ # @method self.skip_redirection_rule(redirection, *methods, &block)
41
+ #
42
+ # Attaches conditions to skip a redirection
43
+ #
44
+ # Methods and blocks are ran and if any returns true, the redirec is skipped
45
+ #
46
+ # @param (see Tarquinn::ClassMethods#skip_redirection)
47
+ # @return (see Tarquinn::ClassMethods#skip_redirection)
48
+
49
+ # @method self.redirector_builder
50
+ #
51
+ # Retruns the RequestHandlerBuilder
52
+ #
53
+ # RequestHandlerBuilder will Carry all the configurations and will create
54
+ # one {RequestHandler} for each request
55
+ #
56
+ # @return (see Tarquinn::ClassMethods#redirector_builder)
57
+ included do
58
+ before_action :perform_redirection
59
+ end
60
+
61
+ private
62
+
63
+ # @api private
64
+ # private
65
+ #
66
+ # @return [Tarquinn::RequestHandler] an engine for the controller
67
+ def redirector_engine
68
+ self.class.redirector_builder.build(self)
69
+ end
70
+
71
+ # Performs redirection if enabled / needed
72
+ #
73
+ # The rules / configuratons are processed in order
74
+ # and if any is positive, it will be processed
75
+ #
76
+ # @return (see Tarquinn::RequestHandler#perform_redirect)
77
+ def perform_redirection
78
+ redirector_engine.perform_redirect
79
+ end
14
80
  end
@@ -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
File without changes
@@ -0,0 +1 @@
1
+ /* Application styles */
@@ -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
File without changes
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tarquinn
4
+ class DummyController < ApplicationController
5
+ include Tarquinn
6
+
7
+ skip_redirection :redirection_path, :route_method
8
+ redirection_rule :redirection_path, :should_redirect?
9
+ skip_redirection_rule :redirection_path, :should_skip_redirect?
10
+
11
+ def parse_request
12
+ perform_redirection
13
+ end
14
+
15
+ private
16
+
17
+ def params
18
+ ActionController::Parameters.new({ action: 'show' })
19
+ end
20
+
21
+ def true
22
+ true
23
+ end
24
+
25
+ def false
26
+ false
27
+ end
28
+
29
+ def redirection_path
30
+ '/path'
31
+ end
32
+
33
+ def redirect_to(_); end
34
+
35
+ def should_redirect?
36
+ true
37
+ end
38
+
39
+ def should_skip_redirect?
40
+ false
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tarquinn
4
+ class DummyRouteController < ApplicationController
5
+ include Tarquinn
6
+
7
+ def index; end
8
+
9
+ def new; end
10
+
11
+ private
12
+
13
+ def redirection
14
+ '/path'
15
+ end
16
+
17
+ def should_redirect?
18
+ params[:should_redirect]
19
+ end
20
+
21
+ def condition2
22
+ params[:redirect]
23
+ end
24
+
25
+ def should_skip?
26
+ params[:should_skip]
27
+ end
28
+
29
+ def do_skip?
30
+ params[:skip]
31
+ end
32
+
33
+ def always_redirect
34
+ true
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ end
@@ -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
+ primary_abstract_class
5
+ end
File without changes
@@ -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" %>
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,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require_relative '../config/boot'
6
+ require 'rails/commands'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../config/boot'
5
+ require 'rake'
6
+ Rake.application.run
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'fileutils'
5
+
6
+ # path to your application root.
7
+ APP_ROOT = File.expand_path('..', __dir__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ FileUtils.chdir APP_ROOT do
14
+ # This script is a way to set up or update your development environment automatically.
15
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
16
+ # Add necessary setup steps to this file.
17
+
18
+ puts '== Installing dependencies =='
19
+ system! 'gem install bundler --conservative'
20
+ system('bundle check') || system!('bundle install')
21
+
22
+ # puts "\n== Copying sample files =="
23
+ # unless File.exist?("config/database.yml")
24
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
25
+ # end
26
+
27
+ puts "\n== Preparing database =="
28
+ system! 'bin/rails db:prepare'
29
+
30
+ puts "\n== Removing old logs and tempfiles =="
31
+ system! 'bin/rails log:clear tmp:clear'
32
+
33
+ puts "\n== Restarting application server =="
34
+ system! 'bin/rails restart'
35
+ end