lib/coverband/utils/file_path_helper.rb in coverband-4.2.1.rc3 vs lib/coverband/utils/file_path_helper.rb in coverband-4.2.1.rc4

- old
+ new

@@ -6,20 +6,27 @@ module Coverband module Utils module FilePathHelper module_function + @@path_cache = {} + ### # Takes a full path and converts to a relative path ### def full_path_to_relative(full_path) + return @@path_cache[full_path] if @@path_cache.key?(full_path) + relative_filename = full_path - Coverband.configuration.all_root_paths.each do |root| - relative_filename = relative_filename.gsub(/^#{root}/, './') + Coverband.configuration.all_root_patterns.each do |root| + relative_filename = relative_filename.sub(root, './') # once we have a relative path break out of the loop break if relative_filename.start_with? './' end + + @@path_cache[full_path] = relative_filename + relative_filename end ### # relative_path_to_full code takes: @@ -40,10 +47,12 @@ ### def relative_path_to_full(relative_path, roots) relative_filename = relative_path local_filename = relative_filename roots.each do |root| - relative_filename = relative_filename.gsub(/^#{root}/, './') + relative_filename = relative_filename.sub(/^#{root}/, './') + # once we have a relative path break out of the loop + break if relative_filename.start_with? './' end # the filename for our reports is expected to be a full path. # roots.last should be roots << current_root}/ # a fully expanded path of config.root # filename = filename.gsub('./', roots.last)