Sha256: 70f379da18802a388a50fccb0a37b538d1936601587ef5fa4861ffb67ced646b

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

require 'airbrake'
require 'growl'
require 'terminal-notifier'

module Salemove
  module ProcessHandler
    class NotifierFactory

      def self.get_notifier(env, process_name, conf)
        if conf && conf[:type] == 'airbrake'
          Airbrake.configure do |airbrake|
            airbrake.async = true
            airbrake.environment_name = env
            airbrake.secure = true
            airbrake.host = conf.fetch(:host)
            airbrake.api_key = conf.fetch(:api_key)
          end
          Airbrake
        elsif conf && conf[:type] == 'growl'
          GrowlNotifier.new(process_name)
        elsif conf && conf[:type] == 'terminal-notifier'
          TerminalNotifierWrapper.new(process_name)
        end
      end
    end

    class GrowlNotifier
      def initialize(process_name)
        @process_name = process_name
      end

      def notify_or_ignore(error, _)
        Growl.notify error.message, title: "Error in #{@process_name}"
      end
    end

    class TerminalNotifierWrapper
      def initialize(process_name)
        @process_name = process_name
      end

      def notify_or_ignore(error, _)
        TerminalNotifier.notify(error, title: "Error in #{@process_name}")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
process_handler-0.2.9 lib/salemove/process_handler/notifier_factory.rb
process_handler-0.2.8 lib/salemove/process_handler/notifier_factory.rb
process_handler-0.2.7 lib/salemove/process_handler/notifier_factory.rb
process_handler-0.2.5 lib/salemove/process_handler/notifier_factory.rb
process_handler-0.2.4 lib/salemove/process_handler/notifier_factory.rb
process_handler-0.2.3 lib/salemove/process_handler/notifier_factory.rb
process_handler-0.2.2 lib/salemove/process_handler/notifier_factory.rb
process_handler-0.2.1 lib/salemove/process_handler/notifier_factory.rb