diff --git a/lib/puppet-lint.rb b/lib/puppet-lint.rb index c89d2a61..7926014d 100644 --- a/lib/puppet-lint.rb +++ b/lib/puppet-lint.rb @@ -11,7 +11,6 @@ require 'puppet-lint/checks' require 'puppet-lint/report/github' require 'puppet-lint/bin' -require 'puppet-lint/monkeypatches' class PuppetLint::NoCodeError < StandardError; end diff --git a/lib/puppet-lint/monkeypatches.rb b/lib/puppet-lint/monkeypatches.rb deleted file mode 100644 index 13200b8f..00000000 --- a/lib/puppet-lint/monkeypatches.rb +++ /dev/null @@ -1,51 +0,0 @@ -begin - '%{test}' % { test: 'replaced' } == 'replaced' -rescue StandardError - # monkeypatch String#% into Ruby 1.8.7 - class String - Percent = instance_method(:%) unless defined?(Percent) - - def %(*a, &) - a.flatten! - - string = case a.last - when Hash - expand(a.pop) - else - self - end - - if a.empty? - string - else - Percent.bind_call(string, a, &) - end - end - - 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 - - def expand(opts = {}) - dup.expand!(opts) - end - end -end - -unless String.respond_to?(:prepend) - # monkeypatch String#prepend into Ruby 1.8.7 - class String - def prepend(lead) - replace("#{lead}#{self}") - end - end -end