Sha256: 512a6cf35d95084fa4ff3ff7a8a610d4af626c943d3535bb0c833d6b74a661bd
Contents?: true
Size: 1.87 KB
Versions: 189
Compression:
Stored size: 1.87 KB
Contents
require 'appsignal' class AppsignalGenerator < Rails::Generators::Base EXCLUDED_ENVIRONMENTS = ['test'].freeze source_root File.expand_path('../templates', __FILE__) argument :push_api_key, :type => :string desc 'Generate a config file for AppSignal' def copy_config_file template_file = 'appsignal.yml' destination_file = File.join('config', template_file) if File.exists?(destination_file) say_status(:error, 'Looks like you already have a config file', :red) else template(template_file, destination_file) add_appsignal_require_for_capistrano check_push_api_key end end protected def add_appsignal_require_for_capistrano deploy_file = File.expand_path(File.join('config', 'deploy.rb')) cap_file = File.expand_path('Capfile') if [deploy_file, cap_file].all? { |file| File.exists?(file) } file_contents = File.read(deploy_file) if (file_contents =~ /require (\'|\").\/appsignal\/capistrano/).nil? append_to_file deploy_file, "\nrequire 'appsignal/capistrano'\n" end else say_status :info, "No capistrano setup detected! Did you know you can "\ "use the AppSignal CLI to notify AppSignal of deployments?", :yellow say_status "", "Run the following command for help:" say_status "", "appsignal notify_of_deploy -h" end end def config Appsignal::Config.new( Rails.root, 'development' ) end def check_push_api_key auth_check = ::Appsignal::AuthCheck.new(config, Appsignal.logger) status, result = auth_check.perform_with_result if status == '200' say_status :success, result else say_status :error, result, :red end end private def environments @environments ||= Dir.glob( File.join(%w(. config environments *.rb)) ).map { |o| File.basename(o, ".rb") }.sort - EXCLUDED_ENVIRONMENTS end end
Version data entries
189 entries across 189 versions & 1 rubygems