summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-23 04:49:56 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-23 04:49:56 +0000
commit9bb5c50d0b30b4dfb82b6b705dfcbf0e126a9d61 (patch)
treee41fbeb90e4050ea2af6d37e7b443cf9f84be162 /lib/puppet/parser/ast
parentbe711d357857f5e6d4a28a22bd60dd89e9e136c0 (diff)
Not downcasing facts any longer, closing #210 (although not using the patch from mpalmer, since I had not noticed the patch was there). Also, making all nodes, classes, and definitions case insensitive, closing #344. Finally, I added case insensitivity to the language in general, which should preserve backwards compatibility and probably makes the most sense in the long run anyway.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1964 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r--lib/puppet/parser/ast/casestatement.rb11
-rw-r--r--lib/puppet/parser/ast/selector.rb10
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/puppet/parser/ast/casestatement.rb b/lib/puppet/parser/ast/casestatement.rb
index 6543293b4..b4197d9b4 100644
--- a/lib/puppet/parser/ast/casestatement.rb
+++ b/lib/puppet/parser/ast/casestatement.rb
@@ -11,13 +11,21 @@ class Puppet::Parser::AST
def evaluate(hash)
scope = hash[:scope]
value = @test.safeevaluate(:scope => scope)
+ sensitive = Puppet[:casesensitive]
+ value = value.downcase if ! sensitive and value.respond_to?(:downcase)
retvalue = nil
found = false
# Iterate across the options looking for a match.
@options.each { |option|
- if option.eachvalue(scope) { |opval| break true if opval == value }
+ if option.eachvalue(scope) { |opval|
+ opval = opval.downcase if ! sensitive and opval.respond_to?(:downcase)
+ # break true if opval == value
+ if opval == value
+ break true
+ end
+ }
# we found a matching option
retvalue = option.safeevaluate(:scope => scope)
found = true
@@ -31,6 +39,7 @@ class Puppet::Parser::AST
retvalue = @default.safeevaluate(:scope => scope)
else
Puppet.debug "No true answers and no default"
+ retvalue = nil
end
end
return retvalue
diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb
index 94b7a5583..ce421e491 100644
--- a/lib/puppet/parser/ast/selector.rb
+++ b/lib/puppet/parser/ast/selector.rb
@@ -18,10 +18,15 @@ class Puppet::Parser::AST
# Get our parameter.
paramvalue = @param.safeevaluate(:scope => scope)
+
+ sensitive = Puppet[:casesensitive]
+
+ if ! sensitive and paramvalue.respond_to?(:downcase)
+ paramvalue = paramvalue.downcase
+ end
default = nil
- #@values = [@values] unless @values.instance_of? AST::ASTArray
unless @values.instance_of? AST::ASTArray or @values.instance_of? Array
@values = [@values]
end
@@ -29,6 +34,9 @@ class Puppet::Parser::AST
# Then look for a match in the options.
@values.each { |obj|
param = obj.param.safeevaluate(:scope => scope)
+ if ! sensitive && param.respond_to?(:downcase)
+ param = param.downcase
+ end
if param == paramvalue
# we found a matching option
retvalue = obj.value.safeevaluate(:scope => scope)