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 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 16 def configure_good_job say 'Add GoodJob configuration' inject_into_class 'config/application.rb', 'Application', optimize_indentation(<<~'RUBY', 4) # Add GoodJob ActiveJob queue adapter config.active_job.queue_adapter = :good_job RUBY gsub_file 'config/environments/production.rb', 'config.active_job.queue_adapter', '# config.active_job.queue_adapter' end |
#configure_good_job_routes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 28 def configure_good_job_routes say 'Add GoodJob routes' route <<~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 end |
#configure_procfile ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 41 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
55 56 57 58 59 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 55 def copy_initializers say 'Add GoodJob initializers' directory 'config/initializers' end |
#finishing_notes ⇒ Object
61 62 63 64 65 |
# File 'lib/generators/rolemodel/good_job/good_job_generator.rb', line 61 def finishing_notes say <<~NOTES, :green *** 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 |