Module: Filter
- Defined in:
- lib/sensu-plugins-aws/filter.rb
Overview
DESCRIPTION:
Filter methods for aws queries
DEPENDENCIES:
USAGE:
Filter.parse(string)
NOTES:
LICENSE:
Justin McCarty ([email protected])
Released under the same terms as Sensu (the MIT license); see LICENSE
for details.
Class Method Summary collapse
Class Method Details
.parse(input) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sensu-plugins-aws/filter.rb', line 19 def self.parse(input) filter = [] if input == '{}' return filter end items = input.scan(/{.*?}/) items.each do |item| if item.strip.empty? raise 'Invalid filter syntax' end entry = {} name = item.scan(/name:(.*?),/) value = item.scan(/values:\[(.*?)\]/) if name.nil? || name.empty? || value.nil? || value.empty? raise 'Unable to parse filter entry' end entry[:name] = name[0][0].strip entry[:values] = value[0][0].split(',') filter << entry end filter end |