class String
monkeypatch #% into Ruby 1.8.7
monkeypatch #prepend into Ruby 1.8.7
Constants
- Percent
Public Instance Methods
%(*a, &b)
click to toggle source
# File lib/puppet-lint/monkeypatches.rb, line 8 def %(*a, &b) a.flatten! string = case a.last when Hash expand(a.pop) else self end if a.empty? string else Percent.bind(string).call(a, &b) end end
expand(opts = {})
click to toggle source
# File lib/puppet-lint/monkeypatches.rb, line 38 def expand(opts = {}) dup.expand!(opts) end
expand!(vars = {})
click to toggle source
# File lib/puppet-lint/monkeypatches.rb, line 25 def expand!(vars = {}) loop do changed = false vars.each do |var, value| var = var.to_s var.gsub!(%r{[^a-zA-Z0-9_]}, '') changed = gsub!(%r{\%\{#{var}\}}, value.to_s) end break unless changed end self end
prepend(lead)
click to toggle source
# File lib/puppet-lint/monkeypatches.rb, line 47 def prepend(lead) replace("#{lead}#{self}") end