[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Daniel Pittman daniel at puppetlabs.com
Tue May 10 08:13:24 UTC 2011


The following commit has been merged in the experimental branch:
commit 217c1561a86a76b9570bcc4ab0db31eb25d120fa
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Mon Apr 11 17:04:42 2011 -0700

    (#6962) Report the template filename for help render errors.
    
    We now set the filename attribute of the ERB instance, which results in any
    error messages showing up with the right attribution: to the file they are
    defined in, rather than just '(erb)'.
    
    Paired-With: Matt Robinson <matt at puppetlabs.com>

diff --git a/lib/puppet/faces/help.rb b/lib/puppet/faces/help.rb
index c5f4b0f..26f8397 100644
--- a/lib/puppet/faces/help.rb
+++ b/lib/puppet/faces/help.rb
@@ -39,19 +39,24 @@ Puppet::Faces.define(:help, '0.0.1') do
       action = (face and actionname) ? face.get_action(actionname.to_sym) : nil
 
       template = case args.length
-                 when 0 then erb_template 'global.erb'
-                 when 1 then erb_template 'face.erb'
-                 when 2 then erb_template 'action.erb'
+                 when 0 then erb 'global.erb'
+                 when 1 then erb 'face.erb'
+                 when 2 then erb 'action.erb'
                  else
                    fail ArgumentError, "Too many arguments to help action"
                  end
 
-      return ERB.new(template, nil, '%').result(binding)
+      # Run the ERB template in our current binding, including all the local
+      # variables we established just above. --daniel 2011-04-11
+      return template.result(binding)
     end
   end
 
-  def erb_template(name)
-    (Pathname(__FILE__).dirname + "help" + name).read
+  def erb(name)
+    template = (Pathname(__FILE__).dirname + "help" + name)
+    erb = ERB.new(template.read, nil, '%')
+    erb.filename = template.to_s
+    return erb
   end
 
   def legacy_applications

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list