Module: Runner

Extended by:
Runner, Validator
Included in:
Runner
Defined in:
lib/airbrake/cli/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validator

validates

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



12
13
14
# File 'lib/airbrake/cli/runner.rb', line 12

def options
  @options
end

Instance Method Details

#run!(command, cli_options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/airbrake/cli/runner.rb', line 14

def run!(command, cli_options = {})

  self.options = Options.new(cli_options)

  case command
  when 'raise'
    validates :api_key
    Airbrake.configure do |c|
      c.api_key = options.api_key
      c.host    = options.host if options.host
      c.port    = options.port if options.port
      c.secure  = options.port.to_i == 443
    end
    exception_id = Airbrake.notify(:error_class   => options.error,
                                   :error_message => "#{options.error}: #{options.message}",
                                   :cgi_data      => ENV)
    abort "Error sending exception to Airbrake server. Try again later." unless exception_id
    puts "Exception sent successfully: http://airbrake.io/locate/#{exception_id}"

  when "list"
    validates :auth_token, :account
    Client.print_projects

  when "create"
    validates :auth_token, :account
    Client.create_project

  when "deploy"
    validates :api_key
    Client.create_deploy

  else
    Printer.print_usage
  end
end