Blazer (Enh.)
Add Blazer to your Rails app - Checks for devise/whenever, correct indention
Used 21 times
S
Stefan Wienert
Usage
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/zmnsWn"
Template Source
Review the code before running this template on your machine.
run 'bundle add blazer'
rails_command 'generate blazer:install'
rails_command 'db:migrate'
if defined?(Devise)
inject_into_file 'config/routes.rb', after: /Rails.application.routes.draw do[\n\r]+/ do <<-EOF
authenticate :user, ->(user) { user.admin? } do
mount Blazer::Engine, at: "blazer"
end
EOF
end
else
inject_into_file 'config/routes.rb', after: /Rails.application.routes.draw do[\n\r]+/ do <<-EOF
mount Blazer::Engine, at: "blazer"
EOF
end
end
if File.exists?('config/schedule.rb')
template = <<~EOF
every 5.minutes do
rake 'blazer:run_checks SCHEDULE="5 minutes"'
end
every :hour do
rake 'blazer:run_checks SCHEDULE="1 hour"'
end
every :day, at: '07:30' do
rake 'blazer:run_checks SCHEDULE="1 day"'
end
every :day, at: '08:00' do
rake 'blazer:send_failing_checks'
end
EOF
append_to_file 'config/schedule.rb', template
end