summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-07 18:53:02 -0700
committerJames Turnbull <james@lovedthanlost.net>2008-08-09 07:24:25 +1000
commit8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94 (patch)
tree069c408bf6bdf9189386ea3b121a51b0b420057f /lib/puppet
parent3ae7eca3928d5dd9d0c93e61ceedc38f60573eb5 (diff)
downloadpuppet-8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94.tar.gz
puppet-8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94.tar.xz
puppet-8a0cb16abd4c6a9cbf27d88593aa2b42a7375b94.zip
Added tests for TemplateWrapper's use of Scope#to_hash.
We should deprecate the method_missing stuff in 0.25. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/templatewrapper.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb
index 298428f63..3b74e62d4 100644
--- a/lib/puppet/parser/templatewrapper.rb
+++ b/lib/puppet/parser/templatewrapper.rb
@@ -18,15 +18,6 @@ class Puppet::Parser::TemplateWrapper
if scope.parser
scope.parser.watch_file(file)
end
-
- # Expose all the variables in our scope as instance variables of the
- # current object, making it possible to access them without conflict
- # to the regular methods.
- benchmark(:debug, "Bound template variables for #{file}") do
- scope.to_hash.each { |name, value|
- instance_variable_set("@#{name}", value)
- }
- end
end
def scope
@@ -67,12 +58,20 @@ class Puppet::Parser::TemplateWrapper
else
# Just throw an error immediately, instead of searching for
# other missingmethod things or whatever.
- raise Puppet::ParseError,
- "Could not find value for '%s'" % name
+ raise Puppet::ParseError, "Could not find value for '%s'" % name
end
end
def result
+ # Expose all the variables in our scope as instance variables of the
+ # current object, making it possible to access them without conflict
+ # to the regular methods.
+ benchmark(:debug, "Bound template variables for #{file}") do
+ scope.to_hash.each { |name, value|
+ instance_variable_set("@#{name}", value)
+ }
+ end
+
result = nil
benchmark(:debug, "Interpolated template #{file}") do
template = ERB.new(File.read(file), 0, "-")