lib/acouchi/which.rb in acouchi-0.0.4 vs lib/acouchi/which.rb in acouchi-0.0.5
- old
+ new
@@ -1,22 +1,23 @@
module Acouchi
class Which
- def self.which? command
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
- exts.each { |ext|
- exe = "#{path}/#{command}#{ext}"
- return exe if File.executable? exe
- }
- end
- return nil
- end
-
def self.find_executable *aliases
if executable = aliases.find {|a| which? a}
executable
else
raise %{Couldn't find any matches for the aliases "#{aliases.join(", ")}"}
end
end
+
+ private
+ def self.which? command
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
+ exts.each { |ext|
+ exe = "#{path}/#{command}#{ext}"
+ return exe if File.executable? exe
+ }
+ end
+ return nil
+ end
end
end