Class: Recipes::BackgroundProcessor
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- Recipes::BackgroundProcessor
- Defined in:
- lib/potassium/recipes/background_processor.rb
Instance Method Summary collapse
- #add_adapters(name) ⇒ Object
- #add_sidekiq ⇒ Object
- #ask ⇒ Object
- #create ⇒ Object
- #edit_procfile(cmd) ⇒ Object
- #install ⇒ Object
- #installed? ⇒ Boolean
Instance Method Details
#add_adapters(name) ⇒ Object
50 51 52 53 54 |
# File 'lib/potassium/recipes/background_processor.rb', line 50 def add_adapters(name) application("config.active_job.queue_adapter = :#{name}") application "config.active_job.queue_adapter = :inline", env: "development" application "config.active_job.queue_adapter = :test", env: "test" end |
#add_sidekiq ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/potassium/recipes/background_processor.rb', line 29 def add_sidekiq gather_gem("sidekiq") add_adapters("sidekiq") add_readme_section :internal_dependencies, :sidekiq edit_procfile("bundle exec sidekiq") append_to_file(".env.development", "DB_POOL=25\n") copy_file("../assets/sidekiq.rb", "config/initializers/sidekiq.rb", force: true) copy_file("../assets/sidekiq.yml", "config/sidekiq.yml", force: true) copy_file("../assets/redis.yml", "config/redis.yml", force: true) insert_into_file "config/routes.rb", after: "Rails.application.routes.draw do\n" do <<-HERE.gsub(/^ {6}/, '') mount Sidekiq::Web => '/queue' HERE end end |
#ask ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/potassium/recipes/background_processor.rb', line 2 def ask response = if selected?(:email_service, :none) answer(:background_processor) do Ask.confirm("Do you want to use Sidekiq for background job processing?") end else info "Note: Emails should be sent on background jobs. We'll install sidekiq" true end set(:background_processor, response) end |
#create ⇒ Object
14 15 16 |
# File 'lib/potassium/recipes/background_processor.rb', line 14 def create add_sidekiq if get(:background_processor) end |
#edit_procfile(cmd) ⇒ Object
46 47 48 |
# File 'lib/potassium/recipes/background_processor.rb', line 46 def edit_procfile(cmd) gsub_file("Procfile", /^.*$/m) { |match| "#{match}worker: #{cmd}" } if selected?(:heroku) end |
#install ⇒ Object
18 19 20 21 22 23 |
# File 'lib/potassium/recipes/background_processor.rb', line 18 def install ask heroku = load_recipe(:heroku) set(:heroku, heroku.installed?) create end |
#installed? ⇒ Boolean
25 26 27 |
# File 'lib/potassium/recipes/background_processor.rb', line 25 def installed? gem_exists?(/sidekiq/) end |