Sha256: c0691ccba1d602bb2ec5d7085db64e1cc2918d7e89e43c5378e624affbe2bd2c

Contents?: true

Size: 711 Bytes

Versions: 11

Compression:

Stored size: 711 Bytes

Contents

class Lbrt::Alert::Exporter
  class << self
    def export(client, options = {})
      self.new(client, options).export
    end
  end # of class methods

  def initialize(client, options = {})
    @client = client
    @options = options
  end

  def export
    alerts = @client.alerts.get
    normalize(alerts)
  end

  def normalize(alerts)
    alert_by_name = {}

    alerts.each do |alrt|
      name = alrt.delete('name')

      if alert_by_name[name]
        raise "Duplicate alert name exists: #{name}"
      end

      %w(created_at updated_at version).each do |key|
        alrt.delete(key)
      end

      alrt['attributes'] ||= {}
      alert_by_name[name] = alrt
    end

    alert_by_name
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lbrt-0.2.1 lib/lbrt/alert/exporter.rb
lbrt-0.2.0 lib/lbrt/alert/exporter.rb
lbrt-0.1.9 lib/lbrt/alert/exporter.rb
lbrt-0.1.8 lib/lbrt/alert/exporter.rb
lbrt-0.1.7 lib/lbrt/alert/exporter.rb
lbrt-0.1.6 lib/lbrt/alert/exporter.rb
lbrt-0.1.5 lib/lbrt/alert/exporter.rb
lbrt-0.1.4 lib/lbrt/alert/exporter.rb
lbrt-0.1.3 lib/lbrt/alert/exporter.rb
lbrt-0.1.1 lib/lbrt/alert/exporter.rb
lbrt-0.1.0 lib/lbrt/alert/exporter.rb