Class: SourceMonitor::Setup::QueueConfigPatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/source_monitor/setup/queue_config_patcher.rb

Constant Summary collapse

RECURRING_SCHEDULE_VALUE =
"config/recurring.yml"
DEFAULT_DISPATCHER =
{
  "polling_interval" => 1,
  "batch_size" => 500,
  "recurring_schedule" => RECURRING_SCHEDULE_VALUE
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(path: "config/queue.yml") ⇒ QueueConfigPatcher

Returns a new instance of QueueConfigPatcher.



17
18
19
# File 'lib/source_monitor/setup/queue_config_patcher.rb', line 17

def initialize(path: "config/queue.yml")
  @path = Pathname.new(path)
end

Instance Method Details

#patchObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/source_monitor/setup/queue_config_patcher.rb', line 21

def patch
  return false unless path.exist?

  parsed = YAML.safe_load(path.read, aliases: true) || {}
  return false if has_recurring_schedule?(parsed)

  add_recurring_schedule!(parsed)
  path.write(YAML.dump(parsed))
  true
end