class Coverband::Utils::RelativeFileConverter
Public Class Methods
convert(file)
click to toggle source
# File lib/coverband/utils/relative_file_converter.rb, line 14 def self.convert(file) instance.convert(file) end
instance()
click to toggle source
# File lib/coverband/utils/relative_file_converter.rb, line 6 def self.instance @instance ||= new(Coverband.configuration.all_root_paths) end
new(roots)
click to toggle source
# File lib/coverband/utils/relative_file_converter.rb, line 18 def initialize(roots) @cache = {} @roots = normalize(roots) end
reset()
click to toggle source
# File lib/coverband/utils/relative_file_converter.rb, line 10 def self.reset @instance = nil end
Public Instance Methods
convert(file)
click to toggle source
# File lib/coverband/utils/relative_file_converter.rb, line 23 def convert(file) @cache[file] ||= begin relative_file = file @roots.each do |root| relative_file = file.gsub(/^#{root}/, ".") break relative_file if relative_file.start_with?(".") end relative_file end end
Private Instance Methods
normalize(paths)
click to toggle source
# File lib/coverband/utils/relative_file_converter.rb, line 36 def normalize(paths) paths.map { |root| File.expand_path(root) } end