diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-19 00:46:25 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-19 00:46:25 +0000 |
| commit | a212ea748f13296489ef39a6404b6ff1ff2def78 (patch) | |
| tree | 256780179e0bf4718a2d90f9256e945a0f1c4db2 /lib/puppet/parser/ast | |
| parent | 90bdc33e440eba602426f709b31b8fca430e19d6 (diff) | |
Adding #539. Definitions can now have titles, and both $title and $name are guaranteed to be set within any definition.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2301 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/ast')
| -rw-r--r-- | lib/puppet/parser/ast/component.rb | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb index 8f82d530a..9e3179edb 100644 --- a/lib/puppet/parser/ast/component.rb +++ b/lib/puppet/parser/ast/component.rb @@ -28,13 +28,15 @@ class Puppet::Parser::AST def evaluate(hash) origscope = hash[:scope] objtype = hash[:type] - name = hash[:name] + title = hash[:title] args = symbolize_options(hash[:arguments] || {}) + name = args[:name] || title + exported = hash[:exported] pscope = origscope - scope = subscope(pscope, name) + scope = subscope(pscope, title) if exported or origscope.exported? scope.exported = true @@ -46,8 +48,10 @@ class Puppet::Parser::AST scope.tag(@type) end - unless name.nil? or name =~ /[^\w]/ or name == "" - scope.tag(name) + [name, title].each do |str| + unless str.nil? or str =~ /[^\w]/ or str == "" + scope.tag(str) + end end # define all of the arguments in our local scope @@ -66,7 +70,7 @@ class Puppet::Parser::AST # [default.inspect, arg.inspect, @name.inspect] else parsefail "Must pass %s to %s of type %s" % - [arg,name,@type] + [arg,title,@type] end end } @@ -84,7 +88,11 @@ class Puppet::Parser::AST end } - unless args.include? "name" + unless args.include? :title + scope.setvar("title",title) + end + + unless args.include? :name scope.setvar("name",name) end @@ -192,6 +200,8 @@ class Puppet::Parser::AST if @arguments.include?(param) # It's a valid arg for us return true + elsif param == "name" + return true # elsif defined? @parentclass and @parentclass # # Else, check any existing parent # if parent = @scope.lookuptype(@parentclass) and parent != [] |
