Sha256: 085fa2a0c5a86d996cb717996c5bb9aa7127ad9f8db1835bfcd65e34d9ec0b8f

Contents?: true

Size: 512 Bytes

Versions: 2

Compression:

Stored size: 512 Bytes

Contents

class Sysdig::AlertFilter
  def self.dump(hash)
    hash.map { |k,v| [k, normalize_condition(v).inspect].join(" = ") }.join(", ")
  end

  def self.load(hash_or_string)
    case hash_or_string
    when NilClass, Hash
      hash_or_string
    when String
      hash_or_string.split(", ").map { |t| t.split(" = ") }.inject({}) { |r,(k,c)|
        r.merge(k => normalize_condition(c))
      }
    else nil
    end
  end

  def self.normalize_condition(string)
    string.gsub(/(^\\?['"])|(\\?['"]$)/, "")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sysdig-0.3.1 lib/sysdig/alert_filter.rb
sysdig-0.3.0 lib/sysdig/alert_filter.rb