Sha256: b0616103facf48e0f889f97c54bc151e9c5d3480d834d5de5d08c15a09f363f1

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

module AwsAlertMonitor

  class EventClassifier

    def initialize(message)
      @message = message
    end

    def event
      event_subjects_classes.each do |subject, klass|
        return klass.new(@message) if generic_event_subject =~ subject
      end

      unknown_event_class.new @message
    end

    private
    def event_subjects_classes
      {
        /\AAuto Scaling: / => AwsAlertMonitor::Events::AutoScalingNotification,
        /\AALARM: /        => AwsAlertMonitor::Events::CloudWatchAlarm,
        /\Aprocess_down/   => AwsAlertMonitor::Events::ProcessDown
      }
    end

    def generic_event_subject
      AwsAlertMonitor::Event.new(@message).subject
    end

    def unknown_event_class
      AwsAlertMonitor::Events::Unknown
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws-alert-monitor-0.1.0 lib/aws-alert-monitor/event_classifier.rb