]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/libraries/expand.rb
4dadd14d38dfbc9f53c92ef4d933bd2a23eebeb5
[chef.git] / cookbooks / munin / libraries / expand.rb
1 class Chef
2   class Munin
3     def self.expand(template, nodes)
4       nodes.map do |node|
5         if node.is_a?(Hash)
6           template.gsub(/%%([^%]+)%%/) { node[Regexp.last_match[1].to_sym] }
7         else
8           template.gsub("%%%", node.tr("-", "_")).gsub("%%", node)
9         end
10       end.join(" ")
11     end
12   end
13 end