alphabetize Util public methods
This commit is contained in:
parent
1b63dc7503
commit
b41a368da1
@ -26,25 +26,6 @@ module Rscons
|
|||||||
command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ')
|
command.map { |c| c =~ /\s/ ? "'#{c}'" : c }.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make a relative path corresponding to a possibly absolute one.
|
|
||||||
#
|
|
||||||
# @param path [String]
|
|
||||||
# Input path that is possibly absolute.
|
|
||||||
#
|
|
||||||
# @return [String]
|
|
||||||
# Relative path.
|
|
||||||
def make_relative_path(path)
|
|
||||||
if absolute_path?(path)
|
|
||||||
if path =~ %r{^(\w):(.*)$}
|
|
||||||
"_#{$1}#{$2}"
|
|
||||||
else
|
|
||||||
"_#{path}"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Look for an executable.
|
# Look for an executable.
|
||||||
#
|
#
|
||||||
# @return [String, nil]
|
# @return [String, nil]
|
||||||
@ -64,6 +45,25 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Make a relative path corresponding to a possibly absolute one.
|
||||||
|
#
|
||||||
|
# @param path [String]
|
||||||
|
# Input path that is possibly absolute.
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
# Relative path.
|
||||||
|
def make_relative_path(path)
|
||||||
|
if absolute_path?(path)
|
||||||
|
if path =~ %r{^(\w):(.*)$}
|
||||||
|
"_#{$1}#{$2}"
|
||||||
|
else
|
||||||
|
"_#{path}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Parse dependencies from a Makefile.
|
# Parse dependencies from a Makefile.
|
||||||
#
|
#
|
||||||
# This method is used internally by Rscons builders.
|
# This method is used internally by Rscons builders.
|
||||||
|
@ -29,32 +29,6 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".make_relative_path" do
|
|
||||||
context "when passed a relative path" do
|
|
||||||
it "returns the path itself" do
|
|
||||||
expect(Util.make_relative_path("foo/bar")).to eq "foo/bar"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when passed an absolute path" do
|
|
||||||
before(:each) do
|
|
||||||
expect(Util).to receive(:absolute_path?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
context "on Windows" do
|
|
||||||
it "returns a relative path corresponding to an absolute one" do
|
|
||||||
expect(Util.make_relative_path("D:/foo/bar")).to eq "_D/foo/bar"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "on non-Windows" do
|
|
||||||
it "returns a relative path corresponding to an absolute one" do
|
|
||||||
expect(Util.make_relative_path("/foo/bar")).to eq "_/foo/bar"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe ".find_executable" do
|
describe ".find_executable" do
|
||||||
context "when given a path with directory components" do
|
context "when given a path with directory components" do
|
||||||
it "returns the path if it is executable" do
|
it "returns the path if it is executable" do
|
||||||
@ -111,6 +85,32 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".make_relative_path" do
|
||||||
|
context "when passed a relative path" do
|
||||||
|
it "returns the path itself" do
|
||||||
|
expect(Util.make_relative_path("foo/bar")).to eq "foo/bar"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when passed an absolute path" do
|
||||||
|
before(:each) do
|
||||||
|
expect(Util).to receive(:absolute_path?).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "on Windows" do
|
||||||
|
it "returns a relative path corresponding to an absolute one" do
|
||||||
|
expect(Util.make_relative_path("D:/foo/bar")).to eq "_D/foo/bar"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "on non-Windows" do
|
||||||
|
it "returns a relative path corresponding to an absolute one" do
|
||||||
|
expect(Util.make_relative_path("/foo/bar")).to eq "_/foo/bar"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe ".parse_makefile_deps" do
|
describe ".parse_makefile_deps" do
|
||||||
it 'handles dependencies on one line' do
|
it 'handles dependencies on one line' do
|
||||||
expect(File).to receive(:read).with('makefile').and_return(<<EOS)
|
expect(File).to receive(:read).with('makefile').and_return(<<EOS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user