Module: BridgetownPluginNano::Commands::Nano::JobsHelpers

Included in:
BridgetownPluginNano::Commands::Nano
Defined in:
lib/bridgetown-plugin-nano/command_helpers/jobs_helpers.rb

Instance Method Summary collapse

Instance Method Details

#configure_active_jobObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bridgetown-plugin-nano/command_helpers/jobs_helpers.rb', line 7

def configure_active_job
  self.destination_root = File.expand_path(folder_name)

  say_status :nano, %(Setting up ActiveJob in "#{folder_name}")
  directory "jobs", ".", exclude_pattern: %r!DS_Store$!
  inject_into_file "config/application.rb",
                   "require \"active_job/railtie\"\n",
                   after: "require \"action_controller/railtie\"\n"

  inject_into_file "config/application.rb",
                   "#  config.active_job.queue_adapter = :sidekiq\n",
                   after: "Rails.logger  = config.logger\n"
  append_to_file(
    "config/base_classes.rb",
    "\n" + File.read("#{self.class.source_root}/base_classes/application_job.rb")
  )

  say_status :nano, "ActiveJob configuration complete!"
  say_status :nano, "Take a look at #{folder_name}/test_job.rb for an example job,"
  say_status :nano, "and #{folder_name}/config/application.rb to set your " \
                    "queue backend (such as Sidekiq)."
end