Class: Salemove::ProcessHandler::NotifierFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/salemove/process_handler/notifier_factory.rb

Class Method Summary collapse

Class Method Details

.get_notifier(process_name, conf) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/salemove/process_handler/notifier_factory.rb', line 9

def self.get_notifier(process_name, conf)
  if conf && conf[:type] == 'airbrake'
    notifier_name = conf[:notifier_name] || :default
    Airbrake.configure(notifier_name) do |airbrake|
      airbrake.environment = conf.fetch(:environment)
      airbrake.host = conf.fetch(:host)
      airbrake.project_id = conf.fetch(:project_id)
      airbrake.project_key = conf.fetch(:project_key)
      airbrake.ignore_environments = conf[:ignore_environments] if conf[:ignore_environments]
      airbrake.whitelist_keys = [
        /_HOST$/, /_TCP$/, /_UDP$/, /_PROTO$/, /_ADDR$/, 'PWD',
        'GEM_HOME', 'PATH', 'SERVICE_NAME', 'RUBY_MAJOR', 'RUBY_VERSION',
        'RACK_ENV', 'RUN_ENV', 'HOME', 'RUBYGEMS_VERSION', 'BUNDLER_VERSION'
      ]
    end
    AirbrakeNotifier.new
  elsif conf && conf[:type] == 'growl'
    GrowlNotifier.new(process_name)
  elsif conf && conf[:type] == 'terminal-notifier'
    TerminalNotifierWrapper.new(process_name)
  end
end