lib/kratos/app_builder.rb in kratos-1.0.2 vs lib/kratos/app_builder.rb in kratos-1.0.3
- old
+ new
@@ -35,29 +35,16 @@
after: 'config.action_mailer.raise_delivery_errors = true'
)
end
def add_bullet_gem_configuration
- config = <<-RUBY
-config.after_initialize do
- Bullet.enable = true
- Bullet.bullet_logger = true
- Bullet.rails_logger = true
-end
-
- RUBY
-
- inject_into_file(
- 'config/environments/development.rb',
- config,
- after: "config.action_mailer.raise_delivery_errors = true\n"
- )
+ copy_file 'bullet.rb', 'config/initializers/bullet.rb'
end
def raise_on_unpermitted_parameters
config = <<-RUBY
- config.action_controller.action_on_unpermitted_parameters = :raise
+ config.action_controller.action_on_unpermitted_parameters = :raise
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
@@ -71,19 +58,19 @@
end
def configure_generators
config = <<-RUBY
- config.generators do |generate|
- generate.helper false
- generate.javascript_engine false
- generate.request_specs false
- generate.routing_specs false
- generate.stylesheets false
- generate.test_framework :rspec
- generate.view_specs false
- end
+ config.generators do |generate|
+ generate.helper false
+ generate.javascript_engine false
+ generate.request_specs false
+ generate.routing_specs false
+ generate.stylesheets false
+ generate.test_framework :rspec
+ generate.view_specs false
+ end
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
@@ -93,11 +80,11 @@
raise_on_missing_translations_in('test')
end
def configure_quiet_assets
config = <<-RUBY
- config.quiet_assets = true
+ config.quiet_assets = true
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
@@ -171,23 +158,23 @@
prepend_file 'config/environments/production.rb',
%{require Rails.root.join("config/smtp")\n}
config = <<-RUBY
-config.action_mailer.delivery_method = :smtp
-config.action_mailer.smtp_settings = SMTP_SETTINGS
+ config.action_mailer.delivery_method = :smtp
+ config.action_mailer.smtp_settings = SMTP_SETTINGS
RUBY
inject_into_file 'config/environments/production.rb', config,
after: 'config.action_mailer.raise_delivery_errors = false'
end
def enable_rack_deflater
config = <<-RUBY
-# Enable deflate / gzip compression of controller-generated responses
-config.middleware.use Rack::Deflater
+ # Enable deflate / gzip compression of controller-generated responses
+ config.middleware.use Rack::Deflater
RUBY
inject_into_file(
'config/environments/production.rb',
config,
@@ -225,16 +212,16 @@
def setup_staging_environment
staging_file = 'config/environments/staging.rb'
copy_file 'staging.rb', staging_file
- config = <<-RUBY
+ config = <<~RUBY
-Rails.application.configure do
-# ...
-end
- RUBY
+ Rails.application.configure do
+ # ...
+ end
+ RUBY
append_file staging_file, config
end
def setup_secret_token
@@ -265,30 +252,33 @@
action_mailer_host 'development', %("localhost:3000")
action_mailer_host 'test', %("www.example.com")
action_mailer_host 'production', %{ENV.fetch("APPLICATION_HOST")}
end
+ def configure_routes
+ remove_file 'config/routes.rb'
+ copy_file 'routes.rb', 'config/routes.rb'
+ end
+
def configure_redis
copy_file 'redis.rb', 'config/initializers/redis.rb'
end
def configure_sidekiq
copy_file 'sidekiq.yml', 'config/sidekiq.yml'
copy_file 'sidekiq_rspec.yml', 'spec/support/sidekiq.rb'
copy_file 'sidekiq_security.rb', 'config/initializers/sidekiq.rb'
empty_directory 'tmp/pids'
- end
- def configure_routes
- replace_in_file 'config/routes.rb',
- /Rails\.application\.routes\.draw do.*end/m,
- <<-EOS
-Rails.application.routes.draw do
-require 'sidekiq/web'
-mount Sidekiq::Web => '/sidekiq'
-end
-EOS
+ route = <<-HERE
+ require 'sidekiq/web'
+ mount Sidekiq::Web => '/sidekiq'
+ HERE
+
+ inject_into_file('config/routes.rb',
+ route,
+ after: "Rails.application.routes.draw do\n")
end
def configure_time_formats
remove_file 'config/locales/en.yml'
copy_file 'config_locales_en_datetime.yml', 'config/locales/en.datetime.yml'
@@ -313,14 +303,20 @@
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
+ def configure_rubocop
+ copy_file 'rubocop.yml', '.rubocop.yml'
+ copy_file 'rubocop_database.yml', 'db/migrate/.rubocop.yml'
+ copy_file 'rubocop_rspec.yml', 'spec/.rubocop.yml'
+ end
+
def setup_brazilian_app
config = <<-RUBY
- config.time_zone = 'Brasilia'
- config.i18n.default_locale = :'pt-BR'
+ config.time_zone = 'Brasilia'
+ config.i18n.default_locale = :'pt-BR'
RUBY
inject_into_class 'config/application.rb', 'Application', config
copy_file 'timezones.rb', 'config/initializers/timezones.rb'
@@ -335,11 +331,11 @@
copy_file 'json_encoding.rb', 'config/initializers/json_encoding.rb'
end
def fix_i18n_deprecation_warning
config = <<-RUBY
- config.i18n.enforce_available_locales = false
+ config.i18n.enforce_available_locales = false
RUBY
inject_into_class 'config/application.rb', 'Application', config
end
@@ -348,13 +344,13 @@
<<-EOS
task(:default).clear
task default: [:spec]
if defined? RSpec
-task(:spec).clear
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.verbose = false
-end
+ task(:spec).clear
+ RSpec::Core::RakeTask.new(:spec) do |t|
+ t.verbose = false
+ end
end
EOS
end
end