module MicMonitorGem module Generators class InstallGenerator < Rails::Generators::Base source_root File.expand_path('templates', __dir__) GEM_PATH = "#{Rails.root}/config/initializers/mic_monitor_gem.rb" def create_file_mic_monitor_gem template 'mic_monitor_gem.rb', GEM_PATH end def add_config_email append_to_file GEM_PATH do <<-'RUBY' if Rails.env.production? Rails.application.config.middleware.use ExceptionNotification::Rack, email: { deliver_with: :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now email_prefix: ENV['EMAIL_PREFIX'], sender_address: ENV['SENDER_ADDRESS'], exception_recipients: ENV['EXCEPTION_RECINPIENTS'] } end RUBY end end end end end