From f20798026a5da30b5ec6cac7b276a2995c93318a Mon Sep 17 00:00:00 2001 From: hamdibayhan Date: Wed, 25 Oct 2017 16:36:17 +0300 Subject: [PATCH] KBP-127 #time 5m -Code was improved --- lib/cybele.rb | 1 + lib/cybele/app_builder.rb | 14 +------------- lib/cybele/helpers/simple_form.rb | 5 +++++ lib/cybele/helpers/staging.rb | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 lib/cybele/helpers/staging.rb diff --git a/lib/cybele.rb b/lib/cybele.rb index 1489df7..c16e3dc 100644 --- a/lib/cybele.rb +++ b/lib/cybele.rb @@ -3,6 +3,7 @@ require 'cybele/version' require 'cybele/generators/app_generator' require 'cybele/helpers' +require 'cybele/helpers/staging' require 'cybele/helpers/sidekiq' require 'cybele/helpers/responders' require 'cybele/helpers/simple_form' diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index 412c6a4..8b07edb 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -3,6 +3,7 @@ module Cybele class AppBuilder < Rails::AppBuilder include Cybele::Helpers + include Cybele::Helpers::Staging include Cybele::Helpers::Sidekiq include Cybele::Helpers::Responders include Cybele::Helpers::SimpleForm @@ -24,11 +25,6 @@ def add_gems append_file('Gemfile', template_content('Gemfile.erb')) end - def add_simple_form_gem - # Add simple_form gems - append_file('Gemfile', template_content('simple_form/simple_form_Gemfile.erb')) - end - def add_editor_config copy_file 'editorconfig', '.editorconfig' end @@ -47,10 +43,6 @@ def create_database bundle_command 'exec rake db:create db:migrate' end - def setup_staging_environment - run 'cp config/environments/production.rb config/environments/staging.rb' - end - def generate_config generate 'config:install' run 'cp config/settings/development.yml config/settings/staging.yml' @@ -61,10 +53,6 @@ def generate_rollbar generate 'rollbar' end - def add_staging_secret_key_to_secrets_yml - append_file 'config/secrets.yml', template_content('secrets.yml.erb') - end - private def configure_environment(rails_env, config) diff --git a/lib/cybele/helpers/simple_form.rb b/lib/cybele/helpers/simple_form.rb index f083e5f..2f415c8 100644 --- a/lib/cybele/helpers/simple_form.rb +++ b/lib/cybele/helpers/simple_form.rb @@ -14,6 +14,11 @@ def configure_simple_form # Remove simple_form turkish file copy_file 'config/locales/simple_form.tr.yml', 'config/locales/simple_form.tr.yml' end + + def add_simple_form_gem + # Add simple_form gem + append_file('Gemfile', template_content('simple_form/simple_form_Gemfile.erb')) + end end end end diff --git a/lib/cybele/helpers/staging.rb b/lib/cybele/helpers/staging.rb new file mode 100644 index 0000000..6cc5cef --- /dev/null +++ b/lib/cybele/helpers/staging.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Cybele + module Helpers + module Staging + def setup_staging_environment + run 'cp config/environments/production.rb config/environments/staging.rb' + end + + def add_staging_secret_key_to_secrets_yml + append_file 'config/secrets.yml', template_content('secrets.yml.erb') + end + end + end +end