exception_handler 0.7.5.15 → 0.8.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.coveralls.yml +1 -0
- data/.gitignore +51 -33
- data/.rspec +3 -4
- data/.slugignore +7 -7
- data/.travis.yml +13 -5
- data/Gemfile +16 -13
- data/README.md +643 -436
- data/Rakefile +7 -7
- data/app/assets/stylesheets/exception_handler.css.erb +23 -18
- data/app/assets/stylesheets/styles/_base.css.erb +28 -35
- data/app/assets/stylesheets/styles/_exception.css.erb +106 -105
- data/app/assets/stylesheets/styles/_footer.css.erb +24 -24
- data/app/assets/stylesheets/styles/_responsive.css +5 -5
- data/app/controllers/exception_handler/exceptions_controller.rb +66 -59
- data/app/mailers/exception_handler/exception_mailer.rb +17 -17
- data/app/models/exception_handler/exception.rb +200 -191
- data/app/views/exception_handler/exceptions/show.html.erb +3 -3
- data/app/views/exception_handler/mailers/layout.haml +8 -8
- data/app/views/exception_handler/mailers/layout.text.erb +1 -1
- data/app/views/exception_handler/mailers/new_exception.erb +4 -4
- data/app/views/layouts/exception.html.erb +32 -27
- data/app/views/layouts/mailer.html.erb +5 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/config/locales/exception_handler.en.yml +28 -28
- data/config/routes.rb +42 -0
- data/db/migrate/000000_create_errors.rb +34 -34
- data/exception_handler.gemspec +63 -80
- data/lib/exception_handler.rb +56 -45
- data/lib/exception_handler/config.rb +185 -103
- data/lib/exception_handler/engine.rb +78 -60
- data/lib/exception_handler/version.rb +25 -0
- data/lib/generators/exception_handler/views_generator.rb +33 -33
- data/spec/controllers/controller_spec.rb +107 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +6 -6
- data/spec/dummy/app/assets/config/manifest.js +3 -4
- data/spec/dummy/app/assets/javascripts/application.js +15 -13
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -5
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -5
- data/spec/dummy/app/controllers/application_controller.rb +2 -5
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/jobs/application_job.rb +2 -2
- data/spec/dummy/app/mailers/application_mailer.rb +4 -4
- data/spec/dummy/app/models/application_record.rb +3 -3
- data/spec/dummy/app/views/layouts/application.html.erb +15 -15
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -1
- data/spec/dummy/bin/bundle +3 -3
- data/spec/dummy/bin/rails +4 -4
- data/spec/dummy/bin/rake +4 -4
- data/spec/dummy/bin/setup +36 -34
- data/spec/dummy/bin/update +31 -29
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -8
- data/spec/dummy/config/application.rb +18 -21
- data/spec/dummy/config/boot.rb +5 -5
- data/spec/dummy/config/cable.yml +10 -10
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +61 -62
- data/spec/dummy/config/environments/production.rb +94 -87
- data/spec/dummy/config/environments/test.rb +46 -42
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -6
- data/spec/dummy/config/initializers/assets.rb +14 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
- data/spec/dummy/config/initializers/inflections.rb +16 -16
- data/spec/dummy/config/initializers/mime_types.rb +4 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +33 -23
- data/spec/dummy/config/puma.rb +34 -47
- data/spec/dummy/config/routes.rb +3 -6
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -67
- data/spec/dummy/public/422.html +67 -67
- data/spec/dummy/public/500.html +66 -66
- data/spec/dummy/spec/rails_helper.rb +57 -0
- data/spec/dummy/spec/spec_helper.rb +100 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/features/asset_spec.rb +61 -0
- data/spec/features/config_spec.rb +51 -0
- data/spec/features/engine_spec.rb +180 -0
- data/spec/mailers/mailer_spec.rb +26 -0
- data/spec/models/model_spec.rb +26 -0
- data/spec/routing/routing_spec.rb +85 -0
- data/spec/spec_helper.rb +101 -55
- data/spec/views/views_spec.rb +29 -0
- metadata +47 -24
- data/.gitattributes +0 -1
- data/LICENSE.txt +0 -22
- data/app/assets/images/exception_handler/bg.jpg +0 -0
- data/app/assets/images/exception_handler/bg_overlay.png +0 -0
- data/spec/database.yml +0 -3
- data/spec/dummy/app/assets/javascripts/cable.coffee +0 -11
- data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +0 -6
- data/spec/dummy/config/initializers/callback_terminator.rb +0 -6
- data/spec/dummy/config/initializers/per_form_csrf_tokens.rb +0 -4
- data/spec/dummy/config/initializers/request_forgery_protection.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/exception_handler.rb +0 -22
- data/spec/exception_handler/exception_controller_spec.rb +0 -18
@@ -1,33 +1,33 @@
|
|
1
|
-
module ExceptionHandler
|
2
|
-
class ViewsGenerator < Rails::Generators::Base
|
3
|
-
|
4
|
-
###########################################
|
5
|
-
###########################################
|
6
|
-
###########################################
|
7
|
-
|
8
|
-
#Views
|
9
|
-
VIEWS = %w(views controllers models assets)
|
10
|
-
|
11
|
-
#Options
|
12
|
-
class_option :files, aliases: "-v", default: VIEWS, type: :array, desc: "Select file types (views, models, controllers, assets)"
|
13
|
-
|
14
|
-
#Needed to reference files
|
15
|
-
source_root File.expand_path("../../../../app", __FILE__)
|
16
|
-
|
17
|
-
###########################################
|
18
|
-
###########################################
|
19
|
-
###########################################
|
20
|
-
|
21
|
-
#Files
|
22
|
-
def create_files
|
23
|
-
options.files.each do |arg|
|
24
|
-
directory arg, "app/#{arg}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
###########################################
|
29
|
-
###########################################
|
30
|
-
###########################################
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
1
|
+
module ExceptionHandler
|
2
|
+
class ViewsGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
###########################################
|
5
|
+
###########################################
|
6
|
+
###########################################
|
7
|
+
|
8
|
+
#Views
|
9
|
+
VIEWS = %w(views controllers models assets)
|
10
|
+
|
11
|
+
#Options
|
12
|
+
class_option :files, aliases: "-v", default: VIEWS, type: :array, desc: "Select file types (views, models, controllers, assets)"
|
13
|
+
|
14
|
+
#Needed to reference files
|
15
|
+
source_root File.expand_path("../../../../app", __FILE__)
|
16
|
+
|
17
|
+
###########################################
|
18
|
+
###########################################
|
19
|
+
###########################################
|
20
|
+
|
21
|
+
#Files
|
22
|
+
def create_files
|
23
|
+
options.files.each do |arg|
|
24
|
+
directory arg, "app/#{arg}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
###########################################
|
29
|
+
###########################################
|
30
|
+
###########################################
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#####################################################
|
2
|
+
#####################################################
|
3
|
+
## _____ _ _ _ ##
|
4
|
+
## / __ \ | | | | | ##
|
5
|
+
## | / \/ ___ _ __ | |_ _ __ ___ | | | ___ _ __ ##
|
6
|
+
## | | / _ \| '_ \| __| '__/ _ \| | |/ _ \ '__| ##
|
7
|
+
## | \__/\ (_) | | | | |_| | | (_) | | | __/ | ##
|
8
|
+
## \____/\___/|_| |_|\__|_| \___/|_|_|\___|_| ##
|
9
|
+
## ##
|
10
|
+
#####################################################
|
11
|
+
#####################################################
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
###############################################
|
16
|
+
###############################################
|
17
|
+
|
18
|
+
# => ExceptionHandler (Controller)
|
19
|
+
# => Test erroneous requests under different circumstances
|
20
|
+
# => Expect the return of 404, 500 (etc) Error Pages
|
21
|
+
# => Test layout, show action, @exception object and different config options
|
22
|
+
RSpec.describe ExceptionHandler::ExceptionsController do
|
23
|
+
|
24
|
+
# => General
|
25
|
+
# => Used to describe the actual Controller class
|
26
|
+
describe "class" do
|
27
|
+
subject { controller }
|
28
|
+
it { should respond_to :show }
|
29
|
+
end
|
30
|
+
|
31
|
+
#################################
|
32
|
+
#################################
|
33
|
+
|
34
|
+
# => Layout
|
35
|
+
# => Expected results & overall views
|
36
|
+
describe "layout" do
|
37
|
+
#subject { response.layout }
|
38
|
+
#it { should be_a String }
|
39
|
+
end
|
40
|
+
|
41
|
+
#################################
|
42
|
+
#################################
|
43
|
+
|
44
|
+
# => Response
|
45
|
+
# => Should deliver 404 / 500 error responses
|
46
|
+
# => Should deliver appropriate headers, layout etc
|
47
|
+
describe "response" do
|
48
|
+
|
49
|
+
# => Before
|
50
|
+
before(:each) { }
|
51
|
+
|
52
|
+
# => 404
|
53
|
+
context "404" do
|
54
|
+
subject { response }
|
55
|
+
it { should have_http_status :ok }
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# => 500
|
60
|
+
context "500" do
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
#################################
|
66
|
+
#################################
|
67
|
+
|
68
|
+
# => Dev Routes
|
69
|
+
# => Should deliver 404 / 500 error responses
|
70
|
+
# => Should deliver appropriate headers, layout etc
|
71
|
+
describe "dev routes" do
|
72
|
+
|
73
|
+
# => Item
|
74
|
+
before(:context) { ExceptionHandler.config.dev = true }
|
75
|
+
before(:context) { Rails.application.reload_routes! }
|
76
|
+
|
77
|
+
# => Items
|
78
|
+
let(:dev) { ExceptionHandler.config.dev }
|
79
|
+
|
80
|
+
# => Config
|
81
|
+
|
82
|
+
# => Pages
|
83
|
+
# => These are shown when
|
84
|
+
context "pages" do
|
85
|
+
|
86
|
+
# => Dev Mode
|
87
|
+
# => Only works with dev enabled
|
88
|
+
it "has Dev mode enabled" do
|
89
|
+
expect(dev).to eq(true)
|
90
|
+
end
|
91
|
+
|
92
|
+
# => The error pages need to return the correct status code
|
93
|
+
#Rack::Utils::SYMBOL_TO_STATUS_CODE.select{ |key, value| value.to_s.match('\b(?:4[0-9]{2}|5[0-9]{2}|599)\b') }.each do |status,code|
|
94
|
+
# it "shows #{code.to_s} page" do
|
95
|
+
# get :show, params: { code: status.to_sym }
|
96
|
+
# expect(response).to have_http_status status.to_sym
|
97
|
+
# expect(response.body).to match /404/
|
98
|
+
# end
|
99
|
+
#end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
###############################################
|
107
|
+
###############################################
|
data/spec/dummy/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/spec/dummy/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
Rails.application.load_tasks
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require_relative 'config/application'
|
5
|
+
|
6
|
+
Rails.application.load_tasks
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
//=
|
3
|
-
//= link_directory ../
|
4
|
-
//= link_directory ../stylesheets .css
|
1
|
+
//= link_tree ../images
|
2
|
+
//= link_directory ../javascripts .js
|
3
|
+
//= link_directory ../stylesheets .css
|
@@ -1,13 +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
|
-
//=
|
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,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -1,15 +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
|
-
*/
|
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
|
+
*/
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
1
|
+
module ApplicationCable
|
2
|
+
class Channel < ActionCable::Channel::Base
|
3
|
+
end
|
4
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
1
|
+
module ApplicationCable
|
2
|
+
class Connection < ActionCable::Connection::Base
|
3
|
+
end
|
4
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
module ApplicationHelper
|
2
|
-
end
|
1
|
+
module ApplicationHelper
|
2
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class ApplicationJob < ActiveJob::Base
|
2
|
-
end
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
2
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class ApplicationMailer < ActionMailer::Base
|
2
|
-
default from: 'from@example.com'
|
3
|
-
layout 'mailer'
|
4
|
-
end
|
1
|
+
class ApplicationMailer < ActionMailer::Base
|
2
|
+
default from: 'from@example.com'
|
3
|
+
layout 'mailer'
|
4
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class ApplicationRecord < ActiveRecord::Base
|
2
|
-
self.abstract_class = true
|
3
|
-
end
|
1
|
+
class ApplicationRecord < ActiveRecord::Base
|
2
|
+
self.abstract_class = true
|
3
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= csrf_meta_tags %>
|
6
|
-
<%=
|
7
|
-
|
8
|
-
<%= stylesheet_link_tag 'application', media: 'all'
|
9
|
-
<%= javascript_include_tag 'application'
|
10
|
-
</head>
|
11
|
-
|
12
|
-
<body>
|
13
|
-
<%= yield %>
|
14
|
-
</body>
|
15
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
9
|
+
<%= javascript_include_tag 'application' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -1,13 +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>
|
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>
|
@@ -1 +1 @@
|
|
1
|
-
<%= yield %>
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/bundle
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby.exe
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
3
|
-
load Gem.bin_path('bundler', 'bundle')
|
1
|
+
#!/usr/bin/env ruby.exe
|
2
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
3
|
+
load Gem.bin_path('bundler', 'bundle')
|
data/spec/dummy/bin/rails
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby.exe
|
2
|
-
APP_PATH = File.expand_path('
|
3
|
-
require_relative '../config/boot'
|
4
|
-
require 'rails/commands'
|
1
|
+
#!/usr/bin/env ruby.exe
|
2
|
+
APP_PATH = File.expand_path('../config/application', __dir__)
|
3
|
+
require_relative '../config/boot'
|
4
|
+
require 'rails/commands'
|
data/spec/dummy/bin/rake
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby.exe
|
2
|
-
require_relative '../config/boot'
|
3
|
-
require 'rake'
|
4
|
-
Rake.application.run
|
1
|
+
#!/usr/bin/env ruby.exe
|
2
|
+
require_relative '../config/boot'
|
3
|
+
require 'rake'
|
4
|
+
Rake.application.run
|
data/spec/dummy/bin/setup
CHANGED
@@ -1,34 +1,36 @@
|
|
1
|
-
#!/usr/bin/env ruby.exe
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
system
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
#
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
1
|
+
#!/usr/bin/env ruby.exe
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a starting point to setup your application.
|
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
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
# puts "\n== Copying sample files =="
|
24
|
+
# unless File.exist?('config/database.yml')
|
25
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
26
|
+
# end
|
27
|
+
|
28
|
+
puts "\n== Preparing database =="
|
29
|
+
system! 'bin/rails db:setup'
|
30
|
+
|
31
|
+
puts "\n== Removing old logs and tempfiles =="
|
32
|
+
system! 'bin/rails log:clear tmp:clear'
|
33
|
+
|
34
|
+
puts "\n== Restarting application server =="
|
35
|
+
system! 'bin/rails restart'
|
36
|
+
end
|