Class: CheckerJobs::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/checker_jobs/configuration.rb

Constant Summary collapse

DEFAULT_TIME_BETWEEN_CHECKS =

15 minutes, expressed in seconds

15 * 60
NOTIFIER_CLASSES =
{
  email: "CheckerJobs::Notifiers::Email",
  logger: "CheckerJobs::Notifiers::Logger",
  bugsnag: "CheckerJobs::Notifiers::Bugsnag",
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#around_checkObject

Returns the value of attribute around_check.



13
14
15
# File 'lib/checker_jobs/configuration.rb', line 13

def around_check
  @around_check
end

#jobs_processorObject

Returns the value of attribute jobs_processor.



13
14
15
# File 'lib/checker_jobs/configuration.rb', line 13

def jobs_processor
  @jobs_processor
end

#notifiers_optionsObject

Returns the value of attribute notifiers_options.



13
14
15
# File 'lib/checker_jobs/configuration.rb', line 13

def notifiers_options
  @notifiers_options
end

#repository_urlObject

Returns the value of attribute repository_url.



13
14
15
# File 'lib/checker_jobs/configuration.rb', line 13

def repository_url
  @repository_url
end

#time_between_checksObject

Returns the value of attribute time_between_checks.



13
14
15
# File 'lib/checker_jobs/configuration.rb', line 13

def time_between_checks
  @time_between_checks
end

Class Method Details

.defaultObject



19
20
21
22
23
24
25
# File 'lib/checker_jobs/configuration.rb', line 19

def self.default
  new.tap do |config|
    config.notifiers_options = {}
    config.time_between_checks = DEFAULT_TIME_BETWEEN_CHECKS
    config.around_check = ->(&block) { block.call }
  end
end

Instance Method Details

#jobs_processor_moduleObject



33
34
35
36
37
38
39
40
# File 'lib/checker_jobs/configuration.rb', line 33

def jobs_processor_module
  case jobs_processor
  when :sidekiq
    CheckerJobs::JobsProcessors::Sidekiq
  else
    raise CheckerJobs::UnsupportedConfigurationOption.new(:jobs_processor, jobs_processor)
  end
end

#notifier(notifier_symbol) {|options| ... } ⇒ Object

Yields:

  • (options)


27
28
29
30
31
# File 'lib/checker_jobs/configuration.rb', line 27

def notifier(notifier_symbol)
  options = default_options_for(notifier_symbol)
  yield options
  @notifiers_options[notifier_symbol] = options
end

#notifier_class(notifier) ⇒ Object



42
43
44
45
46
47
# File 'lib/checker_jobs/configuration.rb', line 42

def notifier_class(notifier)
  notifier_class_name = NOTIFIER_CLASSES.fetch(notifier) do
    raise CheckerJobs::UnsupportedConfigurationOption.new(:notifier, notifier)
  end
  Object.const_get(notifier_class_name)
end