diff options
author | James Turnbull <james@lovedthanlost.net> | 2008-02-13 20:29:00 +1100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-02-13 20:29:00 +1100 |
commit | d3959c497f4c61995f664d88aa3386b54c4baf8d (patch) | |
tree | 1a83a85c0c6d626781cad5632db146aeae49d0c9 /lib/puppet/util | |
parent | c3ead0331adba5f60ea7d508775a89de68e26caa (diff) | |
parent | bcb9b564281003e22d72752d84fa9dc9c8c7107b (diff) | |
download | puppet-d3959c497f4c61995f664d88aa3386b54c4baf8d.tar.gz puppet-d3959c497f4c61995f664d88aa3386b54c4baf8d.tar.xz puppet-d3959c497f4c61995f664d88aa3386b54c4baf8d.zip |
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
Diffstat (limited to 'lib/puppet/util')
-rw-r--r-- | lib/puppet/util/constant_inflector.rb | 14 | ||||
-rw-r--r-- | lib/puppet/util/graph.rb | 2 | ||||
-rw-r--r-- | lib/puppet/util/tagging.rb | 5 |
3 files changed, 20 insertions, 1 deletions
diff --git a/lib/puppet/util/constant_inflector.rb b/lib/puppet/util/constant_inflector.rb new file mode 100644 index 000000000..8b083951f --- /dev/null +++ b/lib/puppet/util/constant_inflector.rb @@ -0,0 +1,14 @@ +# Created on 2008-02-12 +# Copyright Luke Kanies + +# A common module for converting between constants and +# file names. +module Puppet::Util::ConstantInflector + def file2constant(file) + file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize } + end + + def constant2file(constant) + constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_" + $2 }.gsub("::", "/").downcase + end +end diff --git a/lib/puppet/util/graph.rb b/lib/puppet/util/graph.rb index a9744578b..d1ef36f8e 100644 --- a/lib/puppet/util/graph.rb +++ b/lib/puppet/util/graph.rb @@ -16,7 +16,7 @@ module Puppet::Util::Graph self.each do |child| unless block_given? and ! yield(child) - graph.add_edge!(self, child) + graph.add_edge(self, child) if child.respond_to?(:to_graph) child.to_graph(graph, &block) diff --git a/lib/puppet/util/tagging.rb b/lib/puppet/util/tagging.rb index 25d74c420..9abb3fb2b 100644 --- a/lib/puppet/util/tagging.rb +++ b/lib/puppet/util/tagging.rb @@ -19,6 +19,11 @@ module Puppet::Util::Tagging qualified.collect { |name| name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) } end + # Are we tagged with the provided tag? + def tagged?(tag) + defined?(@tags) and @tags.include?(tag.to_s) + end + # Return a copy of the tag list, so someone can't ask for our tags # and then modify them. def tags |