def relative_path(other)
other = Registry.at(other) if String === other && Registry.at(other)
same_parent = false
if other.respond_to?(:path)
same_parent = other.parent == parent
other = other.path
end
return other unless namespace
common = [path, other].join(" ").match(/^(\S*)\S*(?: \1\S*)*$/)[1]
common = path unless common =~ /(\.|::|#)$/
common = common.sub(/(\.|::|#)[^:#\.]*?$/, '') if same_parent
if %w(. :).include?(common[-1,1]) || other[common.size,1] == '#'
suffix = ''
else
suffix = '(::|\.)'
end
result = other.sub(/^#{Regexp.quote common}#{suffix}/, '')
result.empty? ? other : result
end