lib/nagios_parser/object/parser.rb in nagios_parser-1.2.0 vs lib/nagios_parser/object/parser.rb in nagios_parser-1.2.1
- old
+ new
@@ -29,10 +29,14 @@
case
when scanner.scan(/\s+/)
# ignore whitespace
when scanner.scan(/#[^\n]*/)
# ignore comments
+ when scanner.scan(/.*;[^\n]*/)
+ r = scanner.matched.sub(/(.*);[^\n]*/, '\1')
+ scanner.string = r + scanner.rest
+ scanner.reset
when scanner.scan(/define/)
result << [:DEFINE, nil]
when (!inside and match = scanner.scan(/\w+/))
result << [:TYPE, match]
when match = scanner.scan(/\{/)
@@ -45,10 +49,10 @@
result << [:KEY, match.chomp.gsub(/\s+$/, '')]
when (inside and match = scanner.scan(/\d+$/))
result << [:VALUE, match.to_i]
when (inside and match = scanner.scan(/[^\n\}]+/))
# Make sure to ignore inline comments starting with ';'.
- result << [:VALUE, match.split(';').first.gsub(/\s+$/, '')]
+ result << [:VALUE, match.first.gsub(/\s+$/, '')]
else
raise "Can't tokenize <#{scanner.peek(10)}>"
end
end