nagios_parser 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,6 +1,10 @@
1
1
  nagios_parser - ChangeLog
2
2
  =========================
3
3
 
4
+ # 1.2.1
5
+ * Apply original diff from Mitsuru to strip comments.
6
+ This catches more inline comments.
7
+
4
8
  # 1.2.0
5
9
  * Add NagiosParser::Resource parser to parse Nagios resource
6
10
  macro files.
@@ -31,6 +31,10 @@ def create_token(string)
31
31
  # ignore whitespace
32
32
  when scanner.scan(/#[^\n]*/)
33
33
  # ignore comments
34
+ when scanner.scan(/.*;[^\n]*/)
35
+ r = scanner.matched.sub(/(.*);[^\n]*/, '\1')
36
+ scanner.string = r + scanner.rest
37
+ scanner.reset
34
38
  when scanner.scan(/define/)
35
39
  result << [:DEFINE, nil]
36
40
  when (!inside and match = scanner.scan(/\w+/))
@@ -47,7 +51,7 @@ def create_token(string)
47
51
  result << [:VALUE, match.to_i]
48
52
  when (inside and match = scanner.scan(/[^\n\}]+/))
49
53
  # Make sure to ignore inline comments starting with ';'.
50
- result << [:VALUE, match.split(';').first.gsub(/\s+$/, '')]
54
+ result << [:VALUE, match.first.gsub(/\s+$/, '')]
51
55
  else
52
56
  raise "Can't tokenize <#{scanner.peek(10)}>"
53
57
  end
@@ -49,6 +49,10 @@ def create_token(string)
49
49
  # ignore whitespace
50
50
  when scanner.scan(/#[^\n]*/)
51
51
  # ignore comments
52
+ when scanner.scan(/.*;[^\n]*/)
53
+ r = scanner.matched.sub(/(.*);[^\n]*/, '\1')
54
+ scanner.string = r + scanner.rest
55
+ scanner.reset
52
56
  when scanner.scan(/define/)
53
57
  result << [:DEFINE, nil]
54
58
  when (!inside and match = scanner.scan(/\w+/))
@@ -65,7 +69,7 @@ def create_token(string)
65
69
  result << [:VALUE, match.to_i]
66
70
  when (inside and match = scanner.scan(/[^\n\}]+/))
67
71
  # Make sure to ignore inline comments starting with ';'.
68
- result << [:VALUE, match.split(';').first.gsub(/\s+$/, '')]
72
+ result << [:VALUE, match.first.gsub(/\s+$/, '')]
69
73
  else
70
74
  raise "Can't tokenize <#{scanner.peek(10)}>"
71
75
  end
@@ -1,3 +1,3 @@
1
1
  module NagiosParser
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -19,10 +19,11 @@ describe NagiosParser::Object::Parser do
19
19
  host_name foo.example.com
20
20
  _plugin_path /usr/lib64/nagios/plugins
21
21
  }
22
+ ; comment
22
23
  define service {
23
24
  host_name foo.example.com
24
25
  service_description SUPERD ; I like that!
25
- }
26
+ } ; Another comment
26
27
  RUBY
27
28
 
28
29
  parser.create_token(string).should == [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagios_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
9
+ - 1
10
+ version: 1.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bernd Ahlers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-20 00:00:00 Z
18
+ date: 2011-06-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake