Module: Chronos::RakeTasks

Extended by:
Rake::DSL
Defined in:
lib/chronos/rake_tasks.rb

Overview

Installs explicit Rake commands supplied by the Chronos gem.

Examples:

require "chronos/rake_tasks"
Chronos::RakeTasks.install

Constant Summary collapse

TASK_NAME =
"chronos:verify_integration".freeze

Class Method Summary collapse

Class Method Details

.install(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/chronos/rake_tasks.rb', line 24

def self.install(options = {})
  return false if ::Rake::Task.task_defined?(TASK_NAME)

  output = options[:output] || $stdout
  exiter = options[:exit] || proc { |status| exit(status) }
  load_environment = options[:load_environment] || ::Rake::Task.task_defined?("environment")
  prerequisites = load_environment ? ["environment"] : []

  desc "Send an identified fake error and verify Chronos credentials and ingestion"
  task TASK_NAME => prerequisites do
    result = Chronos.verify_integration
    output.puts(JSON.generate(result.to_h))
    exiter.call(1) unless result.success?
  end
  true
end