Module: Heirloom::Utils::File

Included in:
Cipher::Shared, Directory
Defined in:
lib/heirloom/utils/file.rb

Instance Method Summary collapse

Instance Method Details

#pathObject



20
21
22
# File 'lib/heirloom/utils/file.rb', line 20

def path
  ENV['PATH']
end

#path_separatorObject



16
17
18
# File 'lib/heirloom/utils/file.rb', line 16

def path_separator
  ::File::PATH_SEPARATOR
end

#pathextObject



24
25
26
# File 'lib/heirloom/utils/file.rb', line 24

def pathext
  ENV['PATHEXT']
end

#which(cmd) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/heirloom/utils/file.rb', line 5

def which(cmd)
  exts = pathext ? pathext.split(';') : ['']
  path.split(path_separator).each do |path|
    exts.each { |ext|
      exe = "#{path}/#{cmd}#{ext}"
      return exe if ::File.executable? exe
    }
  end
  return nil
end