letter_opener_web_wally 2.0.1

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.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/brakeman-analysis.yml +36 -0
  3. data/.github/workflows/main.yml +29 -0
  4. data/.github/workflows/release-gem.yml +32 -0
  5. data/.gitignore +20 -0
  6. data/.rspec +4 -0
  7. data/.rubocop.yml +29 -0
  8. data/.rubocop_todo.yml +19 -0
  9. data/CHANGELOG.md +95 -0
  10. data/Gemfile +8 -0
  11. data/LICENSE.txt +0 -0
  12. data/README.md +176 -0
  13. data/Rakefile +10 -0
  14. data/app/controllers/letter_opener_web/application_controller.rb +7 -0
  15. data/app/controllers/letter_opener_web/letters_controller.rb +77 -0
  16. data/app/models/letter_opener_web/aws_letter.rb +98 -0
  17. data/app/models/letter_opener_web/base_letter.rb +93 -0
  18. data/app/models/letter_opener_web/letter.rb +54 -0
  19. data/app/models/letter_opener_web/s3_message.rb +25 -0
  20. data/app/views/layouts/letter_opener_web/_javascripts.html.erb +31 -0
  21. data/app/views/layouts/letter_opener_web/_styles.html.erb +3 -0
  22. data/app/views/layouts/letter_opener_web/js/_favcount.html.erb +104 -0
  23. data/app/views/layouts/letter_opener_web/js/_jquery.html.erb +7 -0
  24. data/app/views/layouts/letter_opener_web/letters.html.erb +15 -0
  25. data/app/views/layouts/letter_opener_web/styles/_bootstrap.html.erb +9 -0
  26. data/app/views/layouts/letter_opener_web/styles/_icon.html.erb +2 -0
  27. data/app/views/layouts/letter_opener_web/styles/_letters.html.erb +70 -0
  28. data/app/views/letter_opener_web/letters/_item.html.erb +10 -0
  29. data/app/views/letter_opener_web/letters/index.html.erb +24 -0
  30. data/bin/setup +6 -0
  31. data/config/routes.rb +9 -0
  32. data/letter_opener_web.gemspec +35 -0
  33. data/lib/letter_opener_web/delivery_method.rb +29 -0
  34. data/lib/letter_opener_web/engine.rb +20 -0
  35. data/lib/letter_opener_web/version.rb +5 -0
  36. data/lib/letter_opener_web.rb +52 -0
  37. data/script/pre-push +2 -0
  38. data/spec/controllers/letter_opener_web/letters_controller_spec.rb +282 -0
  39. data/spec/dummy/Rakefile +8 -0
  40. data/spec/dummy/app/assets/config/manifest.js +3 -0
  41. data/spec/dummy/app/assets/images/.keep +0 -0
  42. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  43. data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
  44. data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
  45. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  46. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  47. data/spec/dummy/app/helpers/application_helper.rb +4 -0
  48. data/spec/dummy/app/javascript/packs/application.js +15 -0
  49. data/spec/dummy/app/jobs/application_job.rb +9 -0
  50. data/spec/dummy/app/mailers/application_mailer.rb +6 -0
  51. data/spec/dummy/app/models/application_record.rb +5 -0
  52. data/spec/dummy/app/models/concerns/.keep +0 -0
  53. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  54. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  55. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  56. data/spec/dummy/bin/rails +4 -0
  57. data/spec/dummy/bin/rake +4 -0
  58. data/spec/dummy/bin/setup +33 -0
  59. data/spec/dummy/config/application.rb +37 -0
  60. data/spec/dummy/config/boot.rb +7 -0
  61. data/spec/dummy/config/environment.rb +7 -0
  62. data/spec/dummy/config/environments/development.rb +78 -0
  63. data/spec/dummy/config/environments/production.rb +122 -0
  64. data/spec/dummy/config/environments/test.rb +61 -0
  65. data/spec/dummy/config/initializers/application_controller_renderer.rb +10 -0
  66. data/spec/dummy/config/initializers/assets.rb +14 -0
  67. data/spec/dummy/config/initializers/backtrace_silencers.rb +10 -0
  68. data/spec/dummy/config/initializers/content_security_policy.rb +30 -0
  69. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  70. data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  71. data/spec/dummy/config/initializers/inflections.rb +18 -0
  72. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  73. data/spec/dummy/config/initializers/permissions_policy.rb +13 -0
  74. data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
  75. data/spec/dummy/config/locales/en.yml +33 -0
  76. data/spec/dummy/config/puma.rb +45 -0
  77. data/spec/dummy/config/routes.rb +5 -0
  78. data/spec/dummy/config.ru +8 -0
  79. data/spec/dummy/lib/assets/.keep +0 -0
  80. data/spec/dummy/log/.keep +0 -0
  81. data/spec/dummy/public/404.html +67 -0
  82. data/spec/dummy/public/422.html +67 -0
  83. data/spec/dummy/public/500.html +66 -0
  84. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  85. data/spec/dummy/public/apple-touch-icon.png +0 -0
  86. data/spec/dummy/public/favicon.ico +0 -0
  87. data/spec/dummy/storage/.keep +0 -0
  88. data/spec/letter_opener_web_spec.rb +47 -0
  89. data/spec/models/letter_opener_web/aws_letter_spec.rb +196 -0
  90. data/spec/models/letter_opener_web/letter_spec.rb +184 -0
  91. data/spec/rails_helper.rb +8 -0
  92. data/spec/spec_helper.rb +8 -0
  93. metadata +291 -0
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'letter_opener'
4
+ require 'letter_opener_web/delivery_method'
5
+
6
+ module LetterOpenerWeb
7
+ class Engine < ::Rails::Engine
8
+ isolate_namespace LetterOpenerWeb
9
+
10
+ initializer 'letter_opener_web.add_delivery_method' do
11
+ ActiveSupport.on_load :action_mailer do
12
+ ActionMailer::Base.add_delivery_method(
13
+ :letter_opener_web,
14
+ LetterOpenerWeb::DeliveryMethod,
15
+ location: LetterOpenerWeb.config.letters_location
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LetterOpenerWeb
4
+ VERSION = '2.0.1'
5
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'letter_opener_web/version'
4
+ require 'letter_opener_web/engine'
5
+ require 'rexml/document'
6
+ require 'aws-sdk-s3'
7
+
8
+ module LetterOpenerWeb
9
+ class Config
10
+ attr_accessor(
11
+ :letters_storage,
12
+ :aws_access_key_id,
13
+ :aws_secret_access_key,
14
+ :aws_region,
15
+ :aws_bucket
16
+ )
17
+
18
+ def letters_location
19
+ @letters_location ||=
20
+ case LetterOpenerWeb.config.letters_storage
21
+ when :local
22
+ Rails.root.join('tmp', 'letter_opener')
23
+ end
24
+ end
25
+
26
+ attr_writer :letters_location
27
+ end
28
+
29
+ def self.config
30
+ @config ||= Config.new.tap do |conf|
31
+ conf.letters_storage = :local
32
+ end
33
+ end
34
+
35
+ def self.configure
36
+ yield config if block_given?
37
+ end
38
+
39
+ def self.reset!
40
+ @config = nil
41
+ @aws_client = nil
42
+ @letters_location = nil
43
+ end
44
+
45
+ def self.aws_client
46
+ @aws_client ||= ::Aws::S3::Client.new(
47
+ access_key_id: LetterOpenerWeb.config.aws_access_key_id,
48
+ secret_access_key: LetterOpenerWeb.config.aws_secret_access_key,
49
+ region: LetterOpenerWeb.config.aws_region
50
+ )
51
+ end
52
+ end
data/script/pre-push ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ # bundle exec rubocop -a
@@ -0,0 +1,282 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe LetterOpenerWeb::LettersController do
6
+ routes { LetterOpenerWeb::Engine.routes }
7
+
8
+ after(:each) { LetterOpenerWeb.reset! }
9
+
10
+ context 'when letters location is on AWS S3 bucket' do
11
+ before do
12
+ LetterOpenerWeb.configure do |config|
13
+ config.aws_access_key_id = 'aws_access_key_id'
14
+ config.aws_secret_access_key = 'aws_secret_access_key'
15
+ config.aws_region = 'aws_region'
16
+ config.aws_bucket = 'aws_bucket'
17
+ config.letters_storage = :s3
18
+ end
19
+ end
20
+
21
+ describe 'GET index' do
22
+ before do
23
+ allow(LetterOpenerWeb::AwsLetter).to receive(:search)
24
+ get :index
25
+ end
26
+
27
+ it 'searches for all letters' do
28
+ expect(LetterOpenerWeb::AwsLetter).to have_received(:search)
29
+ end
30
+
31
+ it 'returns an HTML 200 response' do
32
+ expect(response.status).to eq(200)
33
+ expect(response.content_type).to eq('text/html; charset=utf-8')
34
+ end
35
+ end
36
+
37
+ describe 'GET show' do
38
+ let(:id) { 'an-id' }
39
+ let(:rich_text) { 'rich text href="plain.html"' }
40
+ let(:plain_text) { 'plain text href="rich.html"' }
41
+ let(:letter) { double(:letter, rich_text:, plain_text:, id:) }
42
+
43
+ shared_examples 'found letter examples' do |letter_style|
44
+ before(:each) do
45
+ expect(LetterOpenerWeb::AwsLetter).to receive(:find).with(id).and_return(letter)
46
+ expect(letter).to receive(:valid?).and_return(true)
47
+ get :show, params: { id:, style: letter_style }
48
+ end
49
+
50
+ it 'renders an HTML 200 response' do
51
+ expect(response.status).to eq(200)
52
+ expect(response.content_type).to eq('text/html; charset=utf-8')
53
+ end
54
+ end
55
+
56
+ context 'rich text version' do
57
+ include_examples 'found letter examples', 'rich'
58
+
59
+ it 'renders the rich text contents' do
60
+ expect(response.body).to match(/^rich text/)
61
+ end
62
+
63
+ it 'fixes plain text link' do
64
+ expect(response.body).not_to match(/href="plain.html"/)
65
+ expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'plain')}"/)
66
+ end
67
+ end
68
+
69
+ context 'plain text version' do
70
+ include_examples 'found letter examples', 'plain'
71
+
72
+ it 'renders the plain text contents' do
73
+ expect(response.body).to match(/^plain text/)
74
+ end
75
+
76
+ it 'fixes rich text link' do
77
+ expect(response.body).not_to match(/href="rich.html"/)
78
+ expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'rich')}"/)
79
+ end
80
+ end
81
+
82
+ context 'with wrong parameters' do
83
+ it 'should return 404 when invalid id given' do
84
+ letter = double(:letter, attachments: {}, valid?: false)
85
+ allow(LetterOpenerWeb::AwsLetter).to receive(:find).with(id).and_return(letter)
86
+
87
+ get :show, params: { id:, style: 'rich' }
88
+ expect(response.status).to eq(404)
89
+ end
90
+ end
91
+ end
92
+
93
+ describe 'GET attachment' do
94
+ let(:id) { 'an-id' }
95
+ let(:attachment_path) { 'path/to/attachment' }
96
+ let(:file_name) { 'image.jpg' }
97
+ let(:letter) { double(:letter, attachments: { file_name => attachment_path }, id:) }
98
+
99
+ before do
100
+ allow(LetterOpenerWeb::AwsLetter).to receive(:find).with(id).and_return(letter)
101
+ allow(letter).to receive(:valid?).and_return(true)
102
+ end
103
+
104
+ it 'redirects to the s3 file' do
105
+ allow(controller).to receive(:redirect_to) { controller.head :found }
106
+ get :attachment, params: { id:, file: file_name.gsub(/\.\w+/, ''), format: File.extname(file_name)[1..] }
107
+
108
+ expect(response.status).to eq(302)
109
+ expect(controller).to have_received(:redirect_to)
110
+ .with(attachment_path, allow_other_host: true)
111
+ end
112
+
113
+ it "throws a 404 if attachment file can't be found" do
114
+ get :attachment, params: { id:, file: 'unknown', format: 'woot' }
115
+ expect(response.status).to eq(404)
116
+ end
117
+ end
118
+
119
+ describe 'DELETE clear' do
120
+ before { allow(LetterOpenerWeb::AwsLetter).to receive(:destroy_all) }
121
+
122
+ it 'removes all letters' do
123
+ delete :clear
124
+ expect(LetterOpenerWeb::AwsLetter).to have_received(:destroy_all)
125
+ end
126
+
127
+ it 'redirects back to index' do
128
+ delete :clear
129
+ expect(response).to redirect_to(letters_path)
130
+ end
131
+ end
132
+
133
+ describe 'DELETE destroy' do
134
+ let(:id) { 'an-id' }
135
+
136
+ it 'removes the selected letter' do
137
+ allow_any_instance_of(LetterOpenerWeb::AwsLetter).to receive(:valid?).and_return(true)
138
+ expect_any_instance_of(LetterOpenerWeb::AwsLetter).to receive(:delete)
139
+ delete :destroy, params: { id: }
140
+ end
141
+
142
+ it 'throws a 404 if attachment is not present on s3' do
143
+ bad_id = '../an-id'
144
+
145
+ allow_any_instance_of(LetterOpenerWeb::AwsLetter).to receive(:valid?).and_return(false)
146
+ expect_any_instance_of(LetterOpenerWeb::AwsLetter).not_to receive(:delete)
147
+
148
+ delete :destroy, params: { id: bad_id }
149
+
150
+ expect(response.status).to eq(404)
151
+ end
152
+ end
153
+ end
154
+
155
+ describe 'GET index' do
156
+ before do
157
+ allow(LetterOpenerWeb::Letter).to receive(:search)
158
+ get :index
159
+ end
160
+
161
+ it 'searches for all letters' do
162
+ expect(LetterOpenerWeb::Letter).to have_received(:search)
163
+ end
164
+
165
+ it 'returns an HTML 200 response' do
166
+ expect(response.status).to eq(200)
167
+ expect(response.content_type).to eq('text/html; charset=utf-8')
168
+ end
169
+ end
170
+
171
+ describe 'GET show' do
172
+ let(:id) { 'an-id' }
173
+ let(:rich_text) { 'rich text href="plain.html"' }
174
+ let(:plain_text) { 'plain text href="rich.html"' }
175
+ let(:letter) { double(:letter, rich_text:, plain_text:, id:) }
176
+
177
+ shared_examples 'found letter examples' do |letter_style|
178
+ before(:each) do
179
+ expect(LetterOpenerWeb::Letter).to receive(:find).with(id).and_return(letter)
180
+ expect(letter).to receive(:valid?).and_return(true)
181
+ get :show, params: { id:, style: letter_style }
182
+ end
183
+
184
+ it 'renders an HTML 200 response' do
185
+ expect(response.status).to eq(200)
186
+ expect(response.content_type).to eq('text/html; charset=utf-8')
187
+ end
188
+ end
189
+
190
+ context 'rich text version' do
191
+ include_examples 'found letter examples', 'rich'
192
+
193
+ it 'renders the rich text contents' do
194
+ expect(response.body).to match(/^rich text/)
195
+ end
196
+
197
+ it 'fixes plain text link' do
198
+ expect(response.body).not_to match(/href="plain.html"/)
199
+ expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'plain')}"/)
200
+ end
201
+ end
202
+
203
+ context 'plain text version' do
204
+ include_examples 'found letter examples', 'plain'
205
+
206
+ it 'renders the plain text contents' do
207
+ expect(response.body).to match(/^plain text/)
208
+ end
209
+
210
+ it 'fixes rich text link' do
211
+ expect(response.body).not_to match(/href="rich.html"/)
212
+ expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'rich')}"/)
213
+ end
214
+ end
215
+
216
+ context 'with wrong parameters' do
217
+ it 'should return 404 when invalid id given' do
218
+ get :show, params: { id:, style: 'rich' }
219
+ expect(response.status).to eq(404)
220
+ end
221
+ end
222
+ end
223
+
224
+ describe 'GET attachment' do
225
+ let(:id) { 'an-id' }
226
+ let(:attachment_path) { 'path/to/attachment' }
227
+ let(:file_name) { 'image.jpg' }
228
+ let(:letter) { double(:letter, attachments: { file_name => attachment_path }, id:) }
229
+
230
+ before do
231
+ allow(LetterOpenerWeb::Letter).to receive(:find).with(id).and_return(letter)
232
+ allow(letter).to receive(:valid?).and_return(true)
233
+ end
234
+
235
+ it 'sends the file as an inline attachment' do
236
+ allow(controller).to receive(:send_file) { controller.head :ok }
237
+ get :attachment, params: { id:, file: file_name.gsub(/\.\w+/, ''), format: File.extname(file_name)[1..] }
238
+
239
+ expect(response.status).to eq(200)
240
+ expect(controller).to have_received(:send_file)
241
+ .with(attachment_path, filename: file_name, disposition: 'inline')
242
+ end
243
+
244
+ it "throws a 404 if attachment file can't be found" do
245
+ get :attachment, params: { id:, file: 'unknown', format: 'woot' }
246
+ expect(response.status).to eq(404)
247
+ end
248
+ end
249
+
250
+ describe 'DELETE clear' do
251
+ it 'removes all letters' do
252
+ expect(LetterOpenerWeb::Letter).to receive(:destroy_all)
253
+ delete :clear
254
+ end
255
+
256
+ it 'redirects back to index' do
257
+ delete :clear
258
+ expect(response).to redirect_to(letters_path)
259
+ end
260
+ end
261
+
262
+ describe 'DELETE destroy' do
263
+ let(:id) { 'an-id' }
264
+
265
+ it 'removes the selected letter' do
266
+ allow_any_instance_of(LetterOpenerWeb::Letter).to receive(:valid?).and_return(true)
267
+ expect_any_instance_of(LetterOpenerWeb::Letter).to receive(:delete)
268
+ delete :destroy, params: { id: }
269
+ end
270
+
271
+ it 'throws a 404 if attachment is outside of the letters base path' do
272
+ bad_id = '../an-id'
273
+
274
+ allow_any_instance_of(LetterOpenerWeb::Letter).to receive(:valid?).and_return(false)
275
+ expect_any_instance_of(LetterOpenerWeb::Letter).not_to receive(:delete)
276
+
277
+ delete :destroy, params: { id: bad_id }
278
+
279
+ expect(response.status).to eq(404)
280
+ end
281
+ end
282
+ 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
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
3
+ //= link letter_opener_web_manifest.js
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
File without changes
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ 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,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,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,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'boot'
4
+
5
+ require 'rails'
6
+ # Pick the frameworks you want:
7
+ # require "active_model/railtie"
8
+ # require "active_job/railtie"
9
+ # require "active_record/railtie"
10
+ # require "active_storage/engine"
11
+ require 'action_controller/railtie'
12
+ require 'action_mailer/railtie'
13
+ # require "action_mailbox/engine"
14
+ # require "action_text/engine"
15
+ require 'action_view/railtie'
16
+ # require "action_cable/engine"
17
+ # require "sprockets/railtie"
18
+ # require "rails/test_unit/railtie"
19
+
20
+ # Require the gems listed in Gemfile, including any gems
21
+ # you've limited to :test, :development, or :production.
22
+ Bundler.require(*Rails.groups)
23
+ require 'letter_opener_web'
24
+
25
+ module Dummy
26
+ class Application < Rails::Application
27
+ config.load_defaults Rails::VERSION::STRING.to_f
28
+
29
+ # Configuration for the application, engines, and railties goes here.
30
+ #
31
+ # These settings can be overridden in specific environments using the files
32
+ # in config/environments, which are processed later.
33
+ #
34
+ # config.time_zone = "Central Time (US & Canada)"
35
+ # config.eager_load_paths << Rails.root.join("extras")
36
+ end
37
+ 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,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require_relative 'application'
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!