X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/3a4d52bd4c0f8e6ae7679145846b7bc7845d8ace..1be0e5d385d5c4048ffac061b614aa21312ffcd8:/cookbooks/munin/libraries/expand.rb diff --git a/cookbooks/munin/libraries/expand.rb b/cookbooks/munin/libraries/expand.rb index dcd73cb69..248c5ad5f 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) + def self.expand(template, nodes, separator = " ") nodes.map do |node| if node.is_a?(Hash) - template.gsub(/%%([^%]+)%%/) { node[Regexp.last_match[1].to_sym] } + 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.join(separator) end end end