Class: Which::Base
Class Method Summary
collapse
Class Method Details
.exe(path = find) ⇒ Object
Also known as:
bat
17
18
19
|
# File 'lib/pik/which.rb', line 17
def exe(path=find)
glob(path).first
end
|
.exist?(path) ⇒ Boolean
13
14
15
|
# File 'lib/pik/which.rb', line 13
def exist?(path)
!!exe(path)
end
|
.find(search_path = ENV['PATH']) ⇒ Object
7
8
9
10
11
|
# File 'lib/pik/which.rb', line 7
def find(search_path=ENV['PATH'])
path = SearchPath.new(search_path)
path = path.find{|dir| exist?(dir)}
Pathname(path) rescue nil
end
|
.glob(path) ⇒ Object
22
23
24
25
26
|
# File 'lib/pik/which.rb', line 22
def glob(path)
return [] if path.nil?
glob = "#{Pathname.new(path).to_ruby}/{#{executables.join(',')}}"
Pathname.glob(glob)
end
|