class Suspenders::JobsGenerator

Public Instance Methods

add_jobs_gem() click to toggle source
# File lib/suspenders/generators/jobs_generator.rb, line 5
def add_jobs_gem
  gem "sidekiq"
  Bundler.with_clean_env { run "bundle install" }
end
configure_active_job() click to toggle source
# File lib/suspenders/generators/jobs_generator.rb, line 45
def configure_active_job
  inject_into_file(
    "config/application.rb",
    "\n    config.active_job.queue_adapter = :sidekiq\n",
    before: "\n  end",
  )
end
configure_foreman() click to toggle source
# File lib/suspenders/generators/jobs_generator.rb, line 10
def configure_foreman
  append_to_file(
    'Procfile',
    "worker: bundle exec sidekiq -C config/sidekiq.yml\n"
  )
end
configure_sidekiq() click to toggle source
# File lib/suspenders/generators/jobs_generator.rb, line 17
def configure_sidekiq
  copy_file(
    "config_sidekiq.yml",
    "config/sidekiq.yml"
  )
end
configure_sidekiq_test() click to toggle source
# File lib/suspenders/generators/jobs_generator.rb, line 38
def configure_sidekiq_test
  copy_file(
    "spec_support_sidekiq.rb",
    "spec/support/sidekiq.rb"
  )
end
configure_sidekiq_web() click to toggle source
# File lib/suspenders/generators/jobs_generator.rb, line 24
def configure_sidekiq_web
  inject_into_file(
    "config/routes.rb",
    "require 'sidekiq/web'\n\n",
    before: "Rails.application.routes.draw do\n"
  )
  inject_into_file(
    "config/routes.rb",
    "  mount Sidekiq::Web => '/sidekiq'\n",
    after: "Rails.application.routes.draw do\n"
  )
  warn "Sidekiq web is public! Read https://github.com/mperham/sidekiq/wiki/Monitoring to learn how to add authentication"
end