Module: AnalyticsOps::RailsTasks

Defined in:
lib/analytics_ops/rails/railtie.rb

Overview

Helpers used only when an operator explicitly invokes a Rails Rake task.

Class Method Summary collapse

Class Method Details

.run(command, report_name: nil) ⇒ Object

Raises:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/analytics_ops/rails/railtie.rb', line 8

def run(command, report_name: nil)
  arguments = [
    command,
    "--config", ENV.fetch("ANALYTICS_OPS_CONFIG", Rails.root.join("config/analytics_ops.yml").to_s)
  ]
  arguments.push("--profile", ENV.fetch("ANALYTICS_OPS_PROFILE")) if ENV.key?("ANALYTICS_OPS_PROFILE")
  if command == "plan"
    arguments.push("--output",
                   ENV.fetch("ANALYTICS_OPS_PLAN", Rails.root.join("tmp/analytics_ops-plan.json").to_s))
  end
  arguments << report_name if report_name

  status = CLI.start(arguments)
  return if status == CLI::SUCCESS

  raise Error, "analytics-ops #{command} exited with status #{status}"
end