module TurboTestRubyRefinements::StringRelativePath
Public Class Methods
app_root_path()
click to toggle source
# File lib/turbo_test_ruby_refinements/string/relative_path.rb, line 15 def app_root_path @app_root_path ||= Pathname.new(Dir.pwd) end
fetch(key) { || ... }
click to toggle source
# File lib/turbo_test_ruby_refinements/string/relative_path.rb, line 8 def fetch(key) @path_cache ||= {} return @path_cache[key] if @path_cache.key?(key) @path_cache[key] = yield end
Public Instance Methods
path_to_relative_path(path)
click to toggle source
# File lib/turbo_test_ruby_refinements/string/relative_path.rb, line 30 def path_to_relative_path(path) return path if path.relative? path.realpath.relative_path_from(StringRelativePath.app_root_path) end
relative_path()
click to toggle source
# File lib/turbo_test_ruby_refinements/string/relative_path.rb, line 21 def relative_path StringRelativePath.fetch(self) do return self unless File.exist?(self) path = path_to_relative_path(Pathname.new(self)) path.cleanpath.to_s end end