summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/resource.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-04 15:14:39 -0500
committerLuke Kanies <luke@madstop.com>2007-09-04 15:14:39 -0500
commit11b127bd6708a18b512ca5b3018ccff1200cc47a (patch)
tree55d6f42b78404d6e6058f5bef2e50b6bf06b7105 /lib/puppet/parser/resource.rb
parent3b2efd2a4b32478b6c6a71e1421061405a0bb11e (diff)
downloadpuppet-11b127bd6708a18b512ca5b3018ccff1200cc47a.tar.gz
puppet-11b127bd6708a18b512ca5b3018ccff1200cc47a.tar.xz
puppet-11b127bd6708a18b512ca5b3018ccff1200cc47a.zip
Successfully modified all tests and code so that all language tests pass again. This is the majority of the work necessary to make the separate "configuration" object work.
Diffstat (limited to 'lib/puppet/parser/resource.rb')
-rw-r--r--lib/puppet/parser/resource.rb34
1 files changed, 25 insertions, 9 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 3f5ca78ae..a8da6b054 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -90,11 +90,10 @@ class Puppet::Parser::Resource
end
end
- [:scope, :source].each do |attribute|
- unless self.send(attribute)
- raise ArgumentError, "Resources require a %s" % attribute
- end
+ unless self.scope
+ raise ArgumentError, "Resources require a scope"
end
+ @source ||= scope.source
options = symbolize_options(options)
@@ -122,6 +121,13 @@ class Puppet::Parser::Resource
unless options.empty?
raise ArgumentError, "Resources do not accept %s" % options.keys.collect { |k| k.to_s }.join(", ")
end
+
+ @tags = []
+ @tags << @ref.type.to_s
+ @tags << @ref.title.to_s if @ref.title.to_s =~ /^[-\w]+$/
+ if scope.resource
+ @tags += scope.resource.tags
+ end
end
# Merge an override resource in. This will throw exceptions if
@@ -208,12 +214,22 @@ class Puppet::Parser::Resource
@ref.to_s
end
+ # Add a tag to our current list. These tags will be added to all
+ # of the objects contained in this scope.
+ def tag(*ary)
+ ary.each { |tag|
+ tag = tag.to_s
+ unless tag =~ /^\w[-\w]*$/
+ fail Puppet::ParseError, "Invalid tag %s" % tag.inspect
+ end
+ unless @tags.include?(tag)
+ @tags << tag
+ end
+ }
+ end
+
def tags
- unless defined? @tags
- @tags = scope.tags
- @tags << self.type unless @tags.include?(self.type)
- end
- @tags
+ @tags.dup
end
def to_hash