move Rscons.absolute_path?() to Util

This commit is contained in:
josh committed 2018-11-25 21:31:48 -05:00
1 parent cd2696dd0b
commit dff80587ac
4 files changed
+45 -43

No files matched your search

-13
View File
@@ -66,19 +66,6 @@ module Rscons
application.vars(*args)
end
# Return whether the given path is an absolute filesystem path.
#
# @param path [String] the path to examine.
#
# @return [Boolean] Whether the given path is an absolute filesystem path.
def absolute_path?(path)
if RUBY_PLATFORM =~ /mingw/
path =~ %r{^(?:\w:)?[\\/]}
else
path.start_with?("/")
end
end
# Return whether the given target is a phony target.
#
# @param target [Symbol, String] Target name.
+14 -1
View File
@@ -2,6 +2,19 @@ module Rscons
module Util
class << self
# Return whether the given path is an absolute filesystem path.
#
# @param path [String] the path to examine.
#
# @return [Boolean] Whether the given path is an absolute filesystem path.
def absolute_path?(path)
if RUBY_PLATFORM =~ /mingw/
path =~ %r{^(?:\w:)?[\\/]}
else
path.start_with?("/")
end
end
# Make a relative path corresponding to a possibly absolute one.
#
# @param path [String]
@@ -10,7 +23,7 @@ module Rscons
# @return [String]
# Relative path.
def make_relative_path(path)
if Rscons.absolute_path?(path)
if absolute_path?(path)
if path =~ %r{^(\w):(.*)$}
"_#{$1}#{$2}"
else