~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to lib/puppet/parser/templatewrapper.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# A simple wrapper for templates, so they don't have full access to
2
2
# the scope objects.
 
3
require 'puppet/parser/files'
 
4
 
3
5
class Puppet::Parser::TemplateWrapper
4
 
    attr_accessor :scope, :file, :string
 
6
    attr_writer :scope
 
7
    attr_reader :file
 
8
    attr_accessor :string
5
9
    include Puppet::Util
6
10
    Puppet::Util.logmethods(self)
7
11
 
63
67
    end
64
68
 
65
69
    def file=(filename)
66
 
        @file = Puppet::Module::find_template(filename, scope.compiler.environment)
67
 
 
68
 
        unless FileTest.exists?(file)
69
 
            raise Puppet::ParseError,
70
 
                "Could not find template %s" % file
 
70
        unless @file = Puppet::Parser::Files.find_template(filename, scope.compiler.environment)
 
71
            raise Puppet::ParseError, "Could not find template '%s'" % filename
71
72
        end
72
73
 
73
74
        # We'll only ever not have a parser in testing, but, eh.
90
91
        # current object, making it possible to access them without conflict
91
92
        # to the regular methods.
92
93
        benchmark(:debug, "Bound template variables for #{template_source}") do
93
 
            scope.to_hash.each { |name, value| 
 
94
            scope.to_hash.each { |name, value|
94
95
                if name.kind_of?(String)
95
96
                    realname = name.gsub(/[^\w]/, "_")
96
97
                else
113
114
        "template[%s]" % (file ? file : "inline")
114
115
    end
115
116
end
116