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
-
#tag(*ary) ⇒ Object
Add a tag to the current tag set.
-
#tagged?(*tags) ⇒ Boolean
Is the receiver tagged with 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
#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) ||= ary.flatten.each do |tag| name = tag.to_s.downcase if name =~ ValidTagRegex << name name.split("::").each do |section| << section end else fail(Puppet::ParseError, "Invalid tag '#{name}'") end end end |
#tagged?(*tags) ⇒ Boolean
Is the receiver tagged with the given tags?
27 28 29 |
# File 'lib/puppet/util/tagging.rb', line 27 def tagged?(*) not ( self. & .flatten.collect { |t| t.to_s } ).empty? end |
#tags ⇒ Object
Return a copy of the tag list, so someone can’t ask for our tags and then modify them.
33 34 35 36 |
# File 'lib/puppet/util/tagging.rb', line 33 def ||= .dup end |
#tags=(tags) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/puppet/util/tagging.rb', line 38 def () = return if .nil? or == "" = .strip.split(/\s*,\s*/) if .is_a?(String) .each {|t| tag(t) } end |