From 52f6a60c5b91fc875758be88d65e8c52864d43e9 Mon Sep 17 00:00:00 2001 From: Fabro Date: Wed, 25 Nov 2015 02:40:54 -0300 Subject: [PATCH 1/2] Adding generator --- .../capistrano/maintenance/README.md | 11 +++++++++++ .../maintenance/template_generator.rb | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 lib/generators/capistrano/maintenance/README.md create mode 100644 lib/generators/capistrano/maintenance/template_generator.rb diff --git a/lib/generators/capistrano/maintenance/README.md b/lib/generators/capistrano/maintenance/README.md new file mode 100644 index 0000000..c4cd885 --- /dev/null +++ b/lib/generators/capistrano/maintenance/README.md @@ -0,0 +1,11 @@ +To create a local maintenance.html.erb template in a default path "config/deploy/templates" type this in your shell: + +bundle exec rails generate capistrano:maintenance:template + +To override the default path: + +bundle exec rails generate capistrano:maintenance:template "config/templates" + +Add the template path to deploy.rb: + +set :maintenance_template_path, 'config/deploy/templates/maintenance.html.erb' # or your custom path diff --git a/lib/generators/capistrano/maintenance/template_generator.rb b/lib/generators/capistrano/maintenance/template_generator.rb new file mode 100644 index 0000000..baeb5f7 --- /dev/null +++ b/lib/generators/capistrano/maintenance/template_generator.rb @@ -0,0 +1,19 @@ +module Capistrano + module Maintenance + module Generators + class TemplateGenerator < Rails::Generators::Base + + desc "Create local maintenance.html.erb (database.yml on the server) template file for customization" + source_root File.expand_path('../../../../capistrano/templates', __FILE__) + argument :templates_path, type: :string, + default: "config/deploy/templates", + banner: "path to templates" + + def copy_template + copy_file "maintenance.html.erb", "#{templates_path}/maintenance.html.erb" + end + + end + end + end +end From 7aca924f097b869a057000ee53009cc40a0af058 Mon Sep 17 00:00:00 2001 From: Fabro Date: Wed, 25 Nov 2015 02:43:25 -0300 Subject: [PATCH 2/2] Updated generator desc --- lib/generators/capistrano/maintenance/template_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/capistrano/maintenance/template_generator.rb b/lib/generators/capistrano/maintenance/template_generator.rb index baeb5f7..74233da 100644 --- a/lib/generators/capistrano/maintenance/template_generator.rb +++ b/lib/generators/capistrano/maintenance/template_generator.rb @@ -3,7 +3,7 @@ module Maintenance module Generators class TemplateGenerator < Rails::Generators::Base - desc "Create local maintenance.html.erb (database.yml on the server) template file for customization" + desc "Create a local maintenance.html.erb template file for customization" source_root File.expand_path('../../../../capistrano/templates', __FILE__) argument :templates_path, type: :string, default: "config/deploy/templates",