class AppsignalReport::CLI::Runner

Attributes

options[R]

Public Class Methods

new(options) click to toggle source
# File lib/appsignal_report/cli/runner.rb, line 6
def initialize(options)
  @options = options
end

Public Instance Methods

report() click to toggle source
# File lib/appsignal_report/cli/runner.rb, line 15
def report
  @report ||= report_class.new(
    api_token: options[:api_token],
    app_id: options[:app_id],
    app_name: options[:app_name]
  )
end
run() click to toggle source
# File lib/appsignal_report/cli/runner.rb, line 10
def run
  report.generate
  options[:slack_webhook] ? post_to_slack : print_json
end

Private Instance Methods

post_to_slack() click to toggle source
# File lib/appsignal_report/cli/runner.rb, line 41
def post_to_slack
  message = AppsignalReport::SlackMessage.new(
    report: report,
    webhook_url: options[:slack_webhook]
  )
  puts message.post
end
print_json() click to toggle source
report_class() click to toggle source
# File lib/appsignal_report/cli/runner.rb, line 25
def report_class
  case options[:type]
  when :deploy
    AppsignalReport::DeployReport
  when :weekly
    AppsignalReport::WeeklyReport
  else
    raise ArgumentError, "invalid report type: '#{options[:type]}'"
  end
end