Class: Rolemodel::GoodJobGenerator
- Inherits:
-
GeneratorBase
- Object
- Rails::Generators::Base
- GeneratorBase
- Rolemodel::GoodJobGenerator
- Defined in:
- lib/generators/rolemodel/good_job/good_job_generator.rb
Instance Method Summary collapse
- #configure_good_job ⇒ Object
- #configure_good_job_routes ⇒ Object
- #configure_procfile ⇒ Object
- #copy_initializers ⇒ Object
- #finishing_notes ⇒ Object
- #install_good_job ⇒ Object
Instance Method Details
#configure_good_job ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 16 def configure_good_job say 'Add GoodJob configuration' inject_into_file 'config/application.rb', after: "class Application < Rails::Application\n" do optimize_indentation <<~'RUBY', 4 # Add GoodJob ActiveJob queue adapter config.active_job.queue_adapter = :good_job RUBY end gsub_file 'config/environments/production.rb', 'config.active_job.queue_adapter', '# config.active_job.queue_adapter' end |
#configure_good_job_routes ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 30 def configure_good_job_routes say 'Add GoodJob routes' route_text = <<~RUBY # Example but update per the authorization strategy of app namespace :admin do # authenticate :user, ->(user) { user.admin? } do mount GoodJob::Engine => 'good_job' # end end RUBY route route_text end |
#configure_procfile ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 44 def configure_procfile say 'Add GoodJob to Procfile' if File.exist?(Rails.root.join('Procfile')) append_to_file 'Procfile', <<~COMMAND worker: bundle exec good_job start COMMAND end append_to_file 'Procfile.dev', <<~COMMAND worker: bundle exec good_job start COMMAND end |
#copy_initializers ⇒ Object
58 59 60 61 62 63 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 58 def copy_initializers say 'Add GoodJob initializers' copy_file 'config/initializers/active_job.rb' copy_file 'config/initializers/good_job.rb' end |
#finishing_notes ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 65 def finishing_notes say <<~NOTES *** Reminder to update Honeybadger gem to version 5.7.0 or later to get correct GoodJob error notifications in Honeybadger *** Reminder to also update your job classes to include appropriate concurrency controls (enqueue_limit/perform_limit with keys) NOTES end |
#install_good_job ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 7 def install_good_job say 'Install GoodJob' bundle_command 'add good_job' run_bundle generate 'good_job:install' end |