summaryrefslogtreecommitdiffstats
path: root/lib/puppet/external
diff options
context:
space:
mode:
authorIan Taylor <ian@lorf.org>2009-06-05 12:38:35 -0400
committerJames Turnbull <james@lovedthanlost.net>2009-06-06 09:11:28 +1000
commit41ce18cc8ea239d1633fc6cd9e9f599957a82e74 (patch)
tree9d398b4e3e6d726a174b5b57094c7dd6749ccf0e /lib/puppet/external
parentf3b40923605420f774dac298fb1708de180c0a81 (diff)
downloadpuppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.tar.gz
puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.tar.xz
puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.zip
Changed tabs to spaces without interfering with indentation or alignment
Diffstat (limited to 'lib/puppet/external')
-rw-r--r--lib/puppet/external/dot.rb8
-rwxr-xr-xlib/puppet/external/nagios.rb40
-rw-r--r--lib/puppet/external/nagios/grammar.ry186
3 files changed, 117 insertions, 117 deletions
diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb
index b94568c12..caeee21ca 100644
--- a/lib/puppet/external/dot.rb
+++ b/lib/puppet/external/dot.rb
@@ -229,7 +229,7 @@ module DOT
t + "]\n"
end
- end # class DOTNode
+ end # class DOTNode
# A subgraph element is the same to graph, but has another header in dot
# notation.
@@ -276,7 +276,7 @@ module DOT
hdr + options + nodes + t + "}\n"
end
- end # class DOTSubgraph
+ end # class DOTSubgraph
# This is a graph.
@@ -287,7 +287,7 @@ module DOT
@dot_string = 'digraph'
end
- end # class DOTDigraph
+ end # class DOTDigraph
# This is an edge.
@@ -314,7 +314,7 @@ module DOT
}.compact.join( "\n" ) + "\n" + t + "]\n"
end
- end # class DOTEdge
+ end # class DOTEdge
class DOTDirectedEdge < DOTEdge
diff --git a/lib/puppet/external/nagios.rb b/lib/puppet/external/nagios.rb
index 0dcae4c6d..d7f64d59b 100755
--- a/lib/puppet/external/nagios.rb
+++ b/lib/puppet/external/nagios.rb
@@ -27,24 +27,24 @@ module Nagios
NAGIOSVERSION
end
- class Config
- def Config.import(config)
-
- text = String.new
-
- File.open(config) { |file|
- file.each { |line|
- text += line
- }
- }
- parser = Nagios::Parser.new
- return parser.parse(text)
- end
-
- def Config.each
- Nagios::Object.objects.each { |object|
- yield object
- }
- end
- end
+ class Config
+ def Config.import(config)
+
+ text = String.new
+
+ File.open(config) { |file|
+ file.each { |line|
+ text += line
+ }
+ }
+ parser = Nagios::Parser.new
+ return parser.parse(text)
+ end
+
+ def Config.each
+ Nagios::Object.objects.each { |object|
+ yield object
+ }
+ end
+ end
end
diff --git a/lib/puppet/external/nagios/grammar.ry b/lib/puppet/external/nagios/grammar.ry
index 87c909280..dc203be5c 100644
--- a/lib/puppet/external/nagios/grammar.ry
+++ b/lib/puppet/external/nagios/grammar.ry
@@ -5,51 +5,51 @@ token DEFINE NAME STRING PARAM LCURLY RCURLY VALUE RETURN COMMENT INLINECOMMENT
rule
decls: decl { return val[0] if val[0] }
- | decls decl {
- if val[1].nil?
- result = val[0]
- else
- if val[0].nil?
- result = val[1]
- else
- result = [ val[0], val[1] ].flatten
- end
- end
- }
- ;
+ | decls decl {
+ if val[1].nil?
+ result = val[0]
+ else
+ if val[0].nil?
+ result = val[1]
+ else
+ result = [ val[0], val[1] ].flatten
+ end
+ end
+ }
+ ;
decl: object { result = [val[0]] }
- | RETURN { result = nil }
- | comment
- ;
-
+ | RETURN { result = nil }
+ | comment
+ ;
+
comment: COMMENT RETURN { result = nil }
- ;
+ ;
object: DEFINE NAME LCURLY RETURN vars RCURLY {
- result = Nagios::Base.create(val[1],val[4])
- }
- ;
+ result = Nagios::Base.create(val[1],val[4])
+ }
+ ;
vars: var
- | vars var {
- val[1].each {|p,v|
- val[0][p] = v
- }
- result = val[0]
- }
- ;
+ | vars var {
+ val[1].each {|p,v|
+ val[0][p] = v
+ }
+ result = val[0]
+ }
+ ;
var: PARAM VALUE icomment returns { result = {val[0],val[1]} }
- ;
+ ;
returns: RETURN
| returns RETURN
;
icomment: # nothing
- | INLINECOMMENT
- ;
+ | INLINECOMMENT
+ ;
end
@@ -58,61 +58,61 @@ end
class ::Nagios::Parser::SyntaxError < RuntimeError; end
def parse(src)
- @src = src
+ @src = src
- # state variables
- @invar = false
- @inobject = false
- @done = false
+ # state variables
+ @invar = false
+ @inobject = false
+ @done = false
- @line = 0
- @yydebug = true
+ @line = 0
+ @yydebug = true
do_parse
end
# The lexer. Very simple.
def token
- @src.sub!(/\A\n/,'')
- if $&
- @line += 1
- return [ :RETURN, "\n" ]
- end
-
- if @done
- return nil
- end
- yytext = String.new
-
-
- # remove comments from this line
- @src.sub!(/\A[ \t]*;.*\n/,"\n")
- if $&
- return [:INLINECOMMENT, ""]
- end
-
- @src.sub!(/\A#.*\n/,"\n")
- if $&
- return [:COMMENT, ""]
- end
-
- @src.sub!(/#.*/,'')
-
- if @src.length == 0
- @done = true
- return [false, '$']
- end
-
- if @invar
- @src.sub!(/\A[ \t]+/,'')
- @src.sub!(/\A([^;\n]+)(\n|;)/,'\2')
- if $1
- yytext += $1
- end
- @invar = false
- return [:VALUE, yytext]
- else
- @src.sub!(/\A[\t ]*(\S+)([\t ]*|$)/,'')
+ @src.sub!(/\A\n/,'')
+ if $&
+ @line += 1
+ return [ :RETURN, "\n" ]
+ end
+
+ if @done
+ return nil
+ end
+ yytext = String.new
+
+
+ # remove comments from this line
+ @src.sub!(/\A[ \t]*;.*\n/,"\n")
+ if $&
+ return [:INLINECOMMENT, ""]
+ end
+
+ @src.sub!(/\A#.*\n/,"\n")
+ if $&
+ return [:COMMENT, ""]
+ end
+
+ @src.sub!(/#.*/,'')
+
+ if @src.length == 0
+ @done = true
+ return [false, '$']
+ end
+
+ if @invar
+ @src.sub!(/\A[ \t]+/,'')
+ @src.sub!(/\A([^;\n]+)(\n|;)/,'\2')
+ if $1
+ yytext += $1
+ end
+ @invar = false
+ return [:VALUE, yytext]
+ else
+ @src.sub!(/\A[\t ]*(\S+)([\t ]*|$)/,'')
if $1
yytext = $1
case yytext
@@ -152,11 +152,11 @@ def token
end
end
end
- end
+ end
end
def next_token
- token
+ token
end
def yydebug
@@ -168,18 +168,18 @@ def yywrap
end
def on_error(token, value, vstack )
- msg = ""
- unless value.nil?
- msg = "line #{@line}: syntax error at '#{value}'"
- else
- msg = "line #{@line}: syntax error at '#{token}'"
- end
- unless @src.size > 0
- msg = "line #{@line}: Unexpected end of file"
- end
- if token == '$end'.intern
- puts "okay, this is silly"
- else
- raise ::Nagios::Parser::SyntaxError, msg
- end
+ msg = ""
+ unless value.nil?
+ msg = "line #{@line}: syntax error at '#{value}'"
+ else
+ msg = "line #{@line}: syntax error at '#{token}'"
+ end
+ unless @src.size > 0
+ msg = "line #{@line}: Unexpected end of file"
+ end
+ if token == '$end'.intern
+ puts "okay, this is silly"
+ else
+ raise ::Nagios::Parser::SyntaxError, msg
+ end
end