Skip to content
Snippets Groups Projects
Commit 4d5d6a65 authored by Markus Reiter's avatar Markus Reiter
Browse files

Rename `PATH#validate` to `PATH#existing`.

parent 22f624b3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment