class Honeybadger::CLI::Install

def initialize(options, api_key)

def initialize(options, api_key)
  @options = options
  @api_key = api_key
  @shell = ::Thor::Base.shell.new
end

def run

def run
  say("Installing Honeybadger #{VERSION}")
  begin
    require File.join(Dir.pwd, 'config', 'application.rb')
    raise LoadError unless defined?(::Rails.application)
    root = Rails.root
    config_root = root.join('config')
  rescue LoadError
    root = config_root = Pathname.new(Dir.pwd)
  end
  config_path = config_root.join('honeybadger.yml')
  if config_path.exist?
    say("You're already on Honeybadger, so you're all set.", :yellow)
  else
    say("Writing configuration to: #{config_path}", :yellow)
    path = config_path
    if path.exist?
      say("The configuration file #{config_path} already exists.", :red)
      exit(1)
    elsif !path.dirname.writable?
      say("The configuration path #{config_path.dirname} is not writable.", :red)
      exit(1)
    end
    default_env = defined?(::Rails.application) ? "Rails.env" : "ENV['RUBY_ENV'] || ENV['RACK_ENV']"
    default_root = defined?(::Rails.application) ? "Rails.root.to_s" : "Dir.pwd"
    File.open(path, 'w+') do |file|
      file.write(<<-CONFIG)
more options, see https://docs.honeybadger.io/lib/ruby/gem-reference/configuration
y: '#{api_key}'
environment your app is running in.
<%= #{default_env} %>"
absolute path to your project folder.
"<%= #{default_root} %>"
ybadger won't report errors in these environments.
pment_environments:

lopment
mber
efault, Honeybadger won't report errors in the development_environments.
can override this by explicitly setting report_data to true or false.
rt_data: true
current Git revision of your project. Defaults to the last commit hash.
sion: null
le verbose debug logging (useful for troubleshooting).
 false

    end
  end
  if (capfile = root.join('Capfile')).exist?
    if capfile.read.match(/honeybadger/)
      say("Detected Honeybadger in Capfile; skipping Capistrano installation.", :yellow)
    else
      say("Appending Capistrano tasks to: #{capfile}", :yellow)
      File.open(capfile, 'a') do |f|
        f.puts("\nrequire 'capistrano/honeybadger'")
      end
    end
  end
  Test.new({install: true}.freeze).run
end