aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/PATH.rb14
-rw-r--r--Library/Homebrew/extend/ENV/std.rb2
-rw-r--r--Library/Homebrew/extend/ENV/super.rb22
-rw-r--r--Library/Homebrew/test/PATH_spec.rb4
-rw-r--r--Library/Homebrew/utils.rb2
5 files changed, 26 insertions, 18 deletions
diff --git a/Library/Homebrew/PATH.rb b/Library/Homebrew/PATH.rb
index 0bee1a5f2..eaa963ea5 100644
--- a/Library/Homebrew/PATH.rb
+++ b/Library/Homebrew/PATH.rb
@@ -23,6 +23,14 @@ class PATH
self
end
+ def select(&block)
+ self.class.new(@paths.select(&block))
+ end
+
+ def reject(&block)
+ self.class.new(@paths.reject(&block))
+ end
+
def to_ary
@paths
end
@@ -49,9 +57,9 @@ class PATH
@paths.empty?
end
- def validate
- validated_path = self.class.new(@paths.select(&File.method(:directory?)))
- validated_path unless validated_path.empty?
+ def existing
+ existing_path = select(&File.method(:directory?))
+ existing_path unless existing_path.empty?
end
private
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index cf828cf20..c4cc0985f 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -62,7 +62,7 @@ module Stdenv
HOMEBREW_PREFIX/"share/pkgconfig",
homebrew_extra_pkg_config_paths,
"/usr/lib/pkgconfig",
- ).validate
+ ).existing
end
# Removes the MAKEFLAGS environment variable, causing make to use a single job.
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index ac60e13cd..ef41161af 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -122,7 +122,7 @@ module Superenv
nil
end
- path.validate
+ path.existing
end
def homebrew_extra_pkg_config_paths
@@ -133,14 +133,14 @@ module Superenv
PATH.new(
deps.map { |d| d.opt_lib/"pkgconfig" },
deps.map { |d| d.opt_share/"pkgconfig" },
- ).validate
+ ).existing
end
def determine_pkg_config_libdir
PATH.new(
"/usr/lib/pkgconfig",
homebrew_extra_pkg_config_paths,
- ).validate
+ ).existing
end
def homebrew_extra_aclocal_paths
@@ -152,7 +152,7 @@ module Superenv
keg_only_deps.map { |d| d.opt_share/"aclocal" },
HOMEBREW_PREFIX/"share/aclocal",
homebrew_extra_aclocal_paths,
- ).validate
+ ).existing
end
def homebrew_extra_isystem_paths
@@ -163,11 +163,11 @@ module Superenv
PATH.new(
HOMEBREW_PREFIX/"include",
homebrew_extra_isystem_paths,
- ).validate
+ ).existing
end
def determine_include_paths
- PATH.new(keg_only_deps.map(&:opt_include)).validate
+ PATH.new(keg_only_deps.map(&:opt_include)).existing
end
def homebrew_extra_library_paths
@@ -179,7 +179,7 @@ module Superenv
keg_only_deps.map(&:opt_lib),
HOMEBREW_PREFIX/"lib",
homebrew_extra_library_paths,
- ).validate
+ ).existing
end
def determine_dependencies
@@ -190,7 +190,7 @@ module Superenv
PATH.new(
keg_only_deps.map(&:opt_prefix),
HOMEBREW_PREFIX.to_s,
- ).validate
+ ).existing
end
def homebrew_extra_cmake_include_paths
@@ -198,7 +198,7 @@ module Superenv
end
def determine_cmake_include_path
- PATH.new(homebrew_extra_cmake_include_paths).validate
+ PATH.new(homebrew_extra_cmake_include_paths).existing
end
def homebrew_extra_cmake_library_paths
@@ -206,7 +206,7 @@ module Superenv
end
def determine_cmake_library_path
- PATH.new(homebrew_extra_cmake_library_paths).validate
+ PATH.new(homebrew_extra_cmake_library_paths).existing
end
def homebrew_extra_cmake_frameworks_paths
@@ -217,7 +217,7 @@ module Superenv
PATH.new(
deps.map(&:opt_frameworks),
homebrew_extra_cmake_frameworks_paths,
- ).validate
+ ).existing
end
def determine_make_jobs
diff --git a/Library/Homebrew/test/PATH_spec.rb b/Library/Homebrew/test/PATH_spec.rb
index 07caae617..409819a17 100644
--- a/Library/Homebrew/test/PATH_spec.rb
+++ b/Library/Homebrew/test/PATH_spec.rb
@@ -86,13 +86,13 @@ describe PATH do
end
end
- describe "#validate" do
+ describe "#existing" 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("/path2").and_return(false)
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"])
end
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 257d24784..83b8ba342 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -193,7 +193,7 @@ module Homebrew
path = PATH.new(ENV["PATH"])
path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH
path.prepend(Gem.bindir)
- ENV["PATH"] = path.validate
+ ENV["PATH"] = path.existing
if Gem::Specification.find_all_by_name(name, version).empty?
ohai "Installing or updating '#{name}' gem"