diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-06 19:03:05 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-06 19:03:05 +0000 |
| commit | 46d344b9daa24047b60183cc94509d306b6b562a (patch) | |
| tree | 3c11eaad696ba3d6e6dd40bd7b9e7d1a4a71af85 /lib/puppet/parser | |
| parent | 68233706a9ff05be8fa8ab3ab7198cd0918517d6 (diff) | |
| download | puppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.gz puppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.xz puppet-46d344b9daa24047b60183cc94509d306b6b562a.zip | |
Merging the webserver_portability branch from version 2182 to version 2258.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2259 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser')
| -rw-r--r-- | lib/puppet/parser/ast/caseopt.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/casestatement.rb | 39 | ||||
| -rw-r--r-- | lib/puppet/parser/scope.rb | 2 |
3 files changed, 11 insertions, 33 deletions
diff --git a/lib/puppet/parser/ast/caseopt.rb b/lib/puppet/parser/ast/caseopt.rb index 8d578a10b..11483d082 100644 --- a/lib/puppet/parser/ast/caseopt.rb +++ b/lib/puppet/parser/ast/caseopt.rb @@ -54,8 +54,7 @@ class Puppet::Parser::AST # Evaluate the actual statements; this only gets called if # our option matched. def evaluate(hash) - scope = hash[:scope] - return @statements.safeevaluate(:scope => scope) + return @statements.safeevaluate(hash) end def tree(indent = 0) diff --git a/lib/puppet/parser/ast/casestatement.rb b/lib/puppet/parser/ast/casestatement.rb index 760a1095c..c56e33bc9 100644 --- a/lib/puppet/parser/ast/casestatement.rb +++ b/lib/puppet/parser/ast/casestatement.rb @@ -18,6 +18,7 @@ class Puppet::Parser::AST found = false # Iterate across the options looking for a match. + default = nil @options.each { |option| option.eachvalue(scope) { |opval| opval = opval.downcase if ! sensitive and opval.respond_to?(:downcase) @@ -32,12 +33,16 @@ class Puppet::Parser::AST retvalue = option.safeevaluate(:scope => scope) break end + + if option.default? + default = option + end } # Unless we found something, look for the default. unless found - if defined? @default - retvalue = @default.safeevaluate(:scope => scope) + if default + retvalue = default.safeevaluate(:scope => scope) else Puppet.debug "No true answers and no default" retvalue = nil @@ -46,33 +51,6 @@ class Puppet::Parser::AST return retvalue end - # Do some input validation on our options. - def initialize(hash) - values = {} - - super - - # This won't work if we move away from only allowing - # constants here, but for now, it's fine and useful. - @options.each { |option| - unless option.is_a?(CaseOpt) - raise Puppet::DevError, "Option is not a CaseOpt" - end - if option.default? - @default = option - end - option.eachvalue(nil) { |val| - if values.include?(val) - raise Puppet::ParseError, - "Value %s appears twice in case statement" % - val - else - values[val] = true - end - } - } - end - def tree(indent = 0) rettree = [ @test.tree(indent + 1), @@ -87,5 +65,6 @@ class Puppet::Parser::AST [@test,@options].each { |child| yield child } end end - end + +# $Id$ diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index e81862dad..e5d7df7ca 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -552,7 +552,7 @@ class Puppet::Parser::Scope if ss.matched == '\\$' out << '$' else # look the variable up - out << lookupvar(ss[1] || ss[2]) || "" + out << lookupvar(ss[1] || ss[2]).to_s || "" end elsif ss.scan(/^\\(.)/) # Puppet.debug("Got escape: pos:%d; m:%s" % [ss.pos, ss.matched]) |
