Skip to content

Commit 314483f

Browse files
committed
Remove Array#to_path_s.
1 parent a167469 commit 314483f

File tree

4 files changed

+50
-54
lines changed

4 files changed

+50
-54
lines changed

Library/Homebrew/extend/ENV.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
require "extend/ENV/std"
44
require "extend/ENV/super"
55

6-
class Array
7-
def to_path_s
8-
map(&:to_s).uniq.select { |s| File.directory?(s) }.join(File::PATH_SEPARATOR).chuzzle
9-
end
10-
end
11-
126
def superenv?
137
ARGV.env != "std" && Superenv.bin
148
end

Library/Homebrew/extend/ENV/std.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ def homebrew_extra_pkg_config_paths
5757
end
5858

5959
def determine_pkg_config_libdir
60-
paths = []
61-
paths << "#{HOMEBREW_PREFIX}/lib/pkgconfig"
62-
paths << "#{HOMEBREW_PREFIX}/share/pkgconfig"
63-
paths += homebrew_extra_pkg_config_paths
64-
paths << "/usr/lib/pkgconfig"
65-
paths.to_path_s
60+
PATH.new(
61+
HOMEBREW_PREFIX/"lib/pkgconfig",
62+
HOMEBREW_PREFIX/"share/pkgconfig",
63+
homebrew_extra_pkg_config_paths,
64+
"/usr/lib/pkgconfig",
65+
).validate
6666
end
6767

6868
# Removes the MAKEFLAGS environment variable, causing make to use a single job.

Library/Homebrew/extend/ENV/super.rb

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -101,121 +101,123 @@ def homebrew_extra_paths
101101
end
102102

103103
def determine_path
104-
paths = [Superenv.bin]
104+
path = PATH.new(Superenv.bin)
105105

106106
# Formula dependencies can override standard tools.
107-
paths += deps.map { |d| d.opt_bin.to_s }
108-
109-
paths += homebrew_extra_paths
110-
paths += %w[/usr/bin /bin /usr/sbin /sbin]
107+
path.append(deps.map { |d| d.opt_bin.to_s })
108+
path.append(homebrew_extra_paths)
109+
path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin")
111110

112111
# Homebrew's apple-gcc42 will be outside the PATH in superenv,
113112
# so xcrun may not be able to find it
114113
begin
115114
case homebrew_cc
116115
when "gcc-4.2"
117-
paths << Formulary.factory("apple-gcc42").opt_bin
116+
path.append(Formulary.factory("apple-gcc42").opt_bin)
118117
when GNU_GCC_REGEXP
119-
paths << gcc_version_formula($&).opt_bin
118+
path.append(gcc_version_formula($&).opt_bin)
120119
end
121120
rescue FormulaUnavailableError
122121
# Don't fail and don't add these formulae to the path if they don't exist.
123122
nil
124123
end
125124

126-
paths.to_path_s
125+
path.validate
127126
end
128127

129128
def homebrew_extra_pkg_config_paths
130129
[]
131130
end
132131

133132
def determine_pkg_config_path
134-
paths = deps.map { |d| "#{d.opt_lib}/pkgconfig" }
135-
paths += deps.map { |d| "#{d.opt_share}/pkgconfig" }
136-
paths.to_path_s
133+
PATH.new(
134+
deps.map { |d| d.opt_lib/"pkgconfig" },
135+
deps.map { |d| d.opt_share/"pkgconfig" },
136+
).validate
137137
end
138138

139139
def determine_pkg_config_libdir
140-
paths = %w[/usr/lib/pkgconfig]
141-
paths += homebrew_extra_pkg_config_paths
142-
paths.to_path_s
140+
PATH.new(
141+
"/usr/lib/pkgconfig",
142+
homebrew_extra_pkg_config_paths,
143+
).validate
143144
end
144145

145146
def homebrew_extra_aclocal_paths
146147
[]
147148
end
148149

149150
def determine_aclocal_path
150-
paths = keg_only_deps.map { |d| "#{d.opt_share}/aclocal" }
151-
paths << "#{HOMEBREW_PREFIX}/share/aclocal"
152-
paths += homebrew_extra_aclocal_paths
153-
paths.to_path_s
151+
PATH.new(
152+
keg_only_deps.map { |d| d.opt_share/"aclocal" },
153+
HOMEBREW_PREFIX/"share/aclocal",
154+
homebrew_extra_aclocal_paths,
155+
).validate
154156
end
155157

156158
def homebrew_extra_isystem_paths
157159
[]
158160
end
159161

160162
def determine_isystem_paths
161-
paths = ["#{HOMEBREW_PREFIX}/include"]
162-
paths += homebrew_extra_isystem_paths
163-
paths.to_path_s
163+
PATH.new(
164+
HOMEBREW_PREFIX/"include",
165+
homebrew_extra_isystem_paths,
166+
).validate
164167
end
165168

166169
def determine_include_paths
167-
keg_only_deps.map { |d| d.opt_include.to_s }.to_path_s
170+
PATH.new(keg_only_deps.map(&:opt_include)).validate
168171
end
169172

170173
def homebrew_extra_library_paths
171174
[]
172175
end
173176

174177
def determine_library_paths
175-
paths = keg_only_deps.map { |d| d.opt_lib.to_s }
176-
paths << "#{HOMEBREW_PREFIX}/lib"
177-
paths += homebrew_extra_library_paths
178-
paths.to_path_s
178+
PATH.new(
179+
keg_only_deps.map(&:opt_lib),
180+
HOMEBREW_PREFIX/"lib",
181+
homebrew_extra_library_paths,
182+
).validate
179183
end
180184

181185
def determine_dependencies
182186
deps.map(&:name).join(",")
183187
end
184188

185189
def determine_cmake_prefix_path
186-
paths = keg_only_deps.map { |d| d.opt_prefix.to_s }
187-
paths << HOMEBREW_PREFIX.to_s
188-
paths.to_path_s
190+
PATH.new(
191+
keg_only_deps.map(&:opt_prefix),
192+
HOMEBREW_PREFIX.to_s,
193+
).validate
189194
end
190195

191196
def homebrew_extra_cmake_include_paths
192197
[]
193198
end
194199

195200
def determine_cmake_include_path
196-
paths = []
197-
paths += homebrew_extra_cmake_include_paths
198-
paths.to_path_s
201+
PATH.new(homebrew_extra_cmake_include_paths).validate
199202
end
200203

201204
def homebrew_extra_cmake_library_paths
202205
[]
203206
end
204207

205208
def determine_cmake_library_path
206-
paths = []
207-
paths += homebrew_extra_cmake_library_paths
208-
paths.to_path_s
209+
PATH.new(homebrew_extra_cmake_library_paths).validate
209210
end
210211

211212
def homebrew_extra_cmake_frameworks_paths
212213
[]
213214
end
214215

215216
def determine_cmake_frameworks_path
216-
paths = deps.map { |d| d.opt_frameworks.to_s }
217-
paths += homebrew_extra_cmake_frameworks_paths
218-
paths.to_path_s
217+
PATH.new(
218+
deps.map(&:opt_frameworks),
219+
homebrew_extra_cmake_frameworks_paths,
220+
).validate
219221
end
220222

221223
def determine_make_jobs

Library/Homebrew/utils.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ def install_gem_setup_path!(name, version = nil, executable = name)
190190
Gem::Specification.reset
191191

192192
# Add Gem binary directory and (if missing) Ruby binary directory to PATH.
193-
paths = ENV["PATH"].split(File::PATH_SEPARATOR)
194-
paths.unshift(RUBY_BIN) if which("ruby") != RUBY_PATH
195-
paths.unshift(Gem.bindir)
196-
ENV["PATH"] = paths.to_path_s
193+
path = PATH.new(ENV["PATH"])
194+
path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH
195+
path.prepend(Gem.bindir)
196+
ENV["PATH"] = path.validate
197197

198198
if Gem::Specification.find_all_by_name(name, version).empty?
199199
ohai "Installing or updating '#{name}' gem"

0 commit comments

Comments
 (0)