PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/install/lib/puppet/parser/functions/gsub.rb

https://code.google.com/
Ruby | 17 lines | 11 code | 1 blank | 5 comment | 1 complexity | 86336edb61f3b33f9f7bb7367918b031 MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0
  1. module Puppet::Parser::Functions
  2. # thin wrapper around the ruby gsub function
  3. # gsub($string, $pattern, $replacement) will replace all occurrences of
  4. # $pattern in $string with $replacement. $string can be either a singel
  5. # value or an array. In the latter case, each element of the array will
  6. # be processed in turn.
  7. newfunction(:gsub, :type => :rvalue) do |args|
  8. if args[0].is_a?(Array)
  9. args[0].collect do |val|
  10. val.gsub(/#{args[1]}/, args[2])
  11. end
  12. else
  13. args[0].gsub(/#{args[1]}/, args[2])
  14. end
  15. end
  16. end