Sha256: f5f66ad01d68644d3e3dd0d98c37b5148e3a7a288b4d5ea407c5cc63151ee395
Contents?: true
Size: 748 Bytes
Versions: 8
Compression:
Stored size: 748 Bytes
Contents
module Trackman module Path module Resolver def translate url, parent_url raise "parent_url: #{parent_url} is required to be relative" if Pathname.new(parent_url).absolute? url = Pathname.new(url) unless url.is_a? Pathname parent_url = Pathname.new(parent_url) unless parent_url.is_a? Pathname if url.relative? parent = parent_of(parent_url) child = url else parent = working_dir s = url.to_s child = Pathname.new(s[1...s.length]) end (parent + child).relative_path_from(working_dir).to_s end def working_dir Pathname.new Dir.pwd end def parent_of(url) (working_dir + url).parent end end end end
Version data entries
8 entries across 8 versions & 1 rubygems