Sha256: ccf6b64cd0b3d5d785e99174f4240a96e8f1d41fbf71648f57dac5b1ec616736
Contents?: true
Size: 1.9 KB
Versions: 9
Compression:
Stored size: 1.9 KB
Contents
require 'forwardable' require 'honeybadger/cli/main' require 'honeybadger/cli/test' require 'pathname' module Honeybadger module CLI class Install extend Forwardable def initialize(options, api_key) @options = options @api_key = api_key @shell = ::Thor::Base.shell.new end def run say("Installing Honeybadger #{VERSION}") begin require File.join(Dir.pwd, 'config', 'application.rb') rescue LoadError nil end root = defined?(Rails.root) ? Rails.root : Pathname.new(Dir.pwd) config_root = defined?(Rails.root) ? root.join('config') : root 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 File.open(path, 'w+') do |file| file.write(<<-CONFIG) --- api_key: '#{api_key}' CONFIG 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 private attr_reader :options, :api_key def_delegator :@shell, :say end end end
Version data entries
9 entries across 9 versions & 1 rubygems