Sha256: dd7ba6bdecab49f7ceceb3c6edb8e5b66ac6d8600bb5155c270606d3517d3a04

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

require File.expand_path( "../project_factory", __FILE__)
require File.expand_path( "../options", __FILE__)
require File.expand_path( "../validator", __FILE__)
require File.expand_path( "../printer", __FILE__)
require File.expand_path( "../client", __FILE__)

module Runner
  extend Validator

  extend self

  attr_accessor :options

  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
      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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
airbrake-3.1.12 lib/airbrake/cli/runner.rb
airbrake-3.1.11 lib/airbrake/cli/runner.rb
airbrake-3.1.10 lib/airbrake/cli/runner.rb
airbrake-3.1.9 lib/airbrake/cli/runner.rb
airbrake-3.1.8 lib/airbrake/cli/runner.rb
airbrake-3.1.7 lib/airbrake/cli/runner.rb
airbrake-3.1.6 lib/airbrake/cli/runner.rb