Module: Puppet::Util::Tagging
- Included in:
- Resource, Resource::Catalog, Resource::Status, Transaction, Transaction::Event, Type, Log
- Defined in:
- lib/puppet/util/tagging.rb
Constant Summary collapse
- ValidTagRegex =
/^\w[-\w:.]*$/
Instance Method Summary collapse
-
#raw_tagged?(tag_array) ⇒ Boolean
Answers if this resource is tagged with at least one of the tags given in downcased string form.
-
#tag(*ary) ⇒ Object
Add a tag to the current tag set.
-
#tagged?(*tags) ⇒ Boolean
Answers if this resource is tagged with at least one of the given tags.
-
#tags ⇒ Object
Return a copy of the tag list, so someone can’t ask for our tags and then modify them.
- #tags=(tags) ⇒ Object
Instance Method Details
#raw_tagged?(tag_array) ⇒ Boolean
Answers if this resource is tagged with at least one of the tags given in downcased string form.
The method is a faster variant of the tagged? method that does no conversion of its arguments.
45 46 47 48 |
# File 'lib/puppet/util/tagging.rb', line 45 def raw_tagged?(tag_array) = self. !tag_array.index { |t| .include?(t) }.nil? end |
#tag(*ary) ⇒ Object
Add a tag to the current tag set. When a tag set is used for a scope, these tags will be added to all of the objects contained in this scope when the objects are finished.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/puppet/util/tagging.rb', line 10 def tag(*ary) @tags ||= ary.flatten.each do |tag| name = tag.to_s.downcase if name =~ ValidTagRegex @tags << name name.split("::").each do |section| @tags << section end else fail(Puppet::ParseError, "Invalid tag '#{name}'") end end end |
#tagged?(*tags) ⇒ Boolean
Answers if this resource is tagged with at least one of the given tags.
The given tags are converted to downcased strings before the match is performed.
33 34 35 |
# File 'lib/puppet/util/tagging.rb', line 33 def tagged?(*) raw_tagged?(.collect {|t| t.to_s.downcase}) end |
#tags ⇒ Object
Return a copy of the tag list, so someone can’t ask for our tags and then modify them.
52 53 54 55 |
# File 'lib/puppet/util/tagging.rb', line 52 def @tags ||= @tags.dup end |