lib/faster_path/optional/monkeypatches.rb in faster_path-0.1.11 vs lib/faster_path/optional/monkeypatches.rb in faster_path-0.1.12

- old
+ new

@@ -1,23 +1,30 @@ require 'pathname' module FasterPath module MonkeyPatches + # rubocop:disable Metrics/CyclomaticComplexity def self._ruby_core_file! ::File.class_eval do def self.basename(pth, ext = '') + pth = pth.to_path if pth.respond_to? :to_path + raise TypeError unless pth.is_a? String FasterPath.basename(pth, ext) end def self.extname(pth) + pth = pth.to_path if pth.respond_to? :to_path + raise TypeError unless pth.is_a? String FasterPath.extname(pth) end def self.dirname(pth) + pth = pth.to_path if pth.respond_to? :to_path + raise TypeError unless pth.is_a? String FasterPath.dirname(pth) end - end if ENV['WITH_REGRESSION'] + end end def self._ruby_library_pathname! ::Pathname.class_eval do def absolute? @@ -53,11 +60,11 @@ end end end private_constant :MonkeyPatches - def self.sledgehammer_everything! - MonkeyPatches._ruby_core_file! + def self.sledgehammer_everything!(include_file = !!ENV['WITH_REGRESSION']) + MonkeyPatches._ruby_core_file! if include_file # SLOW; DON'T AUTO INCLUDE MonkeyPatches._ruby_library_pathname! "CAUTION: Monkey patching effects everything! Be very sure you want this!" end end