X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/7b9ec4b60ee39614d1d083d7220e76b07d2b275f..a661370166bbac0bbe8c8b1f0ba947e3a269edee:/cookbooks/munin/libraries/expand.rb diff --git a/cookbooks/munin/libraries/expand.rb b/cookbooks/munin/libraries/expand.rb index 9269761f9..f9c447387 100644 --- a/cookbooks/munin/libraries/expand.rb +++ b/cookbooks/munin/libraries/expand.rb @@ -1,13 +1,17 @@ class Chef class Munin def self.expand(template, nodes) - nodes.map do |node| - if node.kind_of?(Hash) - template.gsub(/%%([^%]+)%%/) { node[$1.to_sym] } + nodes.map do |node| + if node.is_a?(Hash) + template + .gsub(/%%%([^%]+)%%%/) { node[Regexp.last_match[1].to_sym].tr("-", "_") } + .gsub(/%%([^%]+)%%/) { node[Regexp.last_match[1].to_sym] } else - template.gsub("%%", node) + template + .gsub("%%%", node.tr("-", "_")) + .gsub("%%", node) end end.join(" ") end - end + end end