Rename PATH#validate to PATH#existing.
This commit is contained in:
parent
22f624b373
commit
4d5d6a65e3
@ -23,6 +23,14 @@ class PATH
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def select(&block)
|
||||||
|
self.class.new(@paths.select(&block))
|
||||||
|
end
|
||||||
|
|
||||||
|
def reject(&block)
|
||||||
|
self.class.new(@paths.reject(&block))
|
||||||
|
end
|
||||||
|
|
||||||
def to_ary
|
def to_ary
|
||||||
@paths
|
@paths
|
||||||
end
|
end
|
||||||
@ -49,9 +57,9 @@ class PATH
|
|||||||
@paths.empty?
|
@paths.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def existing
|
||||||
validated_path = self.class.new(@paths.select(&File.method(:directory?)))
|
existing_path = select(&File.method(:directory?))
|
||||||
validated_path unless validated_path.empty?
|
existing_path unless existing_path.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@ -62,7 +62,7 @@ module Stdenv
|
|||||||
HOMEBREW_PREFIX/"share/pkgconfig",
|
HOMEBREW_PREFIX/"share/pkgconfig",
|
||||||
homebrew_extra_pkg_config_paths,
|
homebrew_extra_pkg_config_paths,
|
||||||
"/usr/lib/pkgconfig",
|
"/usr/lib/pkgconfig",
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes the MAKEFLAGS environment variable, causing make to use a single job.
|
# Removes the MAKEFLAGS environment variable, causing make to use a single job.
|
||||||
|
|||||||
@ -122,7 +122,7 @@ module Superenv
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
path.validate
|
path.existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def homebrew_extra_pkg_config_paths
|
def homebrew_extra_pkg_config_paths
|
||||||
@ -133,14 +133,14 @@ module Superenv
|
|||||||
PATH.new(
|
PATH.new(
|
||||||
deps.map { |d| d.opt_lib/"pkgconfig" },
|
deps.map { |d| d.opt_lib/"pkgconfig" },
|
||||||
deps.map { |d| d.opt_share/"pkgconfig" },
|
deps.map { |d| d.opt_share/"pkgconfig" },
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_pkg_config_libdir
|
def determine_pkg_config_libdir
|
||||||
PATH.new(
|
PATH.new(
|
||||||
"/usr/lib/pkgconfig",
|
"/usr/lib/pkgconfig",
|
||||||
homebrew_extra_pkg_config_paths,
|
homebrew_extra_pkg_config_paths,
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def homebrew_extra_aclocal_paths
|
def homebrew_extra_aclocal_paths
|
||||||
@ -152,7 +152,7 @@ module Superenv
|
|||||||
keg_only_deps.map { |d| d.opt_share/"aclocal" },
|
keg_only_deps.map { |d| d.opt_share/"aclocal" },
|
||||||
HOMEBREW_PREFIX/"share/aclocal",
|
HOMEBREW_PREFIX/"share/aclocal",
|
||||||
homebrew_extra_aclocal_paths,
|
homebrew_extra_aclocal_paths,
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def homebrew_extra_isystem_paths
|
def homebrew_extra_isystem_paths
|
||||||
@ -163,11 +163,11 @@ module Superenv
|
|||||||
PATH.new(
|
PATH.new(
|
||||||
HOMEBREW_PREFIX/"include",
|
HOMEBREW_PREFIX/"include",
|
||||||
homebrew_extra_isystem_paths,
|
homebrew_extra_isystem_paths,
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_include_paths
|
def determine_include_paths
|
||||||
PATH.new(keg_only_deps.map(&:opt_include)).validate
|
PATH.new(keg_only_deps.map(&:opt_include)).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def homebrew_extra_library_paths
|
def homebrew_extra_library_paths
|
||||||
@ -179,7 +179,7 @@ module Superenv
|
|||||||
keg_only_deps.map(&:opt_lib),
|
keg_only_deps.map(&:opt_lib),
|
||||||
HOMEBREW_PREFIX/"lib",
|
HOMEBREW_PREFIX/"lib",
|
||||||
homebrew_extra_library_paths,
|
homebrew_extra_library_paths,
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_dependencies
|
def determine_dependencies
|
||||||
@ -190,7 +190,7 @@ module Superenv
|
|||||||
PATH.new(
|
PATH.new(
|
||||||
keg_only_deps.map(&:opt_prefix),
|
keg_only_deps.map(&:opt_prefix),
|
||||||
HOMEBREW_PREFIX.to_s,
|
HOMEBREW_PREFIX.to_s,
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def homebrew_extra_cmake_include_paths
|
def homebrew_extra_cmake_include_paths
|
||||||
@ -198,7 +198,7 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
def determine_cmake_include_path
|
def determine_cmake_include_path
|
||||||
PATH.new(homebrew_extra_cmake_include_paths).validate
|
PATH.new(homebrew_extra_cmake_include_paths).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def homebrew_extra_cmake_library_paths
|
def homebrew_extra_cmake_library_paths
|
||||||
@ -206,7 +206,7 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
def determine_cmake_library_path
|
def determine_cmake_library_path
|
||||||
PATH.new(homebrew_extra_cmake_library_paths).validate
|
PATH.new(homebrew_extra_cmake_library_paths).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def homebrew_extra_cmake_frameworks_paths
|
def homebrew_extra_cmake_frameworks_paths
|
||||||
@ -217,7 +217,7 @@ module Superenv
|
|||||||
PATH.new(
|
PATH.new(
|
||||||
deps.map(&:opt_frameworks),
|
deps.map(&:opt_frameworks),
|
||||||
homebrew_extra_cmake_frameworks_paths,
|
homebrew_extra_cmake_frameworks_paths,
|
||||||
).validate
|
).existing
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_make_jobs
|
def determine_make_jobs
|
||||||
|
|||||||
@ -86,13 +86,13 @@ describe PATH do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#validate" do
|
describe "#existing" do
|
||||||
it "returns a new PATH without non-existent paths" do
|
it "returns a new PATH without non-existent paths" do
|
||||||
allow(File).to receive(:directory?).with("/path1").and_return(true)
|
allow(File).to receive(:directory?).with("/path1").and_return(true)
|
||||||
allow(File).to receive(:directory?).with("/path2").and_return(false)
|
allow(File).to receive(:directory?).with("/path2").and_return(false)
|
||||||
|
|
||||||
path = described_class.new("/path1", "/path2")
|
path = described_class.new("/path1", "/path2")
|
||||||
expect(path.validate.to_ary).to eq(["/path1"])
|
expect(path.existing.to_ary).to eq(["/path1"])
|
||||||
expect(path.to_ary).to eq(["/path1", "/path2"])
|
expect(path.to_ary).to eq(["/path1", "/path2"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -193,7 +193,7 @@ module Homebrew
|
|||||||
path = PATH.new(ENV["PATH"])
|
path = PATH.new(ENV["PATH"])
|
||||||
path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH
|
path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH
|
||||||
path.prepend(Gem.bindir)
|
path.prepend(Gem.bindir)
|
||||||
ENV["PATH"] = path.validate
|
ENV["PATH"] = path.existing
|
||||||
|
|
||||||
if Gem::Specification.find_all_by_name(name, version).empty?
|
if Gem::Specification.find_all_by_name(name, version).empty?
|
||||||
ohai "Installing or updating '#{name}' gem"
|
ohai "Installing or updating '#{name}' gem"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user