Class: Aruba::Platforms::UnixWhich::ProgramWhich
- Inherits:
-
Object
- Object
- Aruba::Platforms::UnixWhich::ProgramWhich
- Defined in:
- lib/aruba/platforms/unix_which.rb
Overview
Find path for command
Class Method Summary collapse
Instance Method Summary collapse
-
#call(program, path) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength.
Class Method Details
Instance Method Details
#call(program, path) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/aruba/platforms/unix_which.rb', line 41 def call(program, path) # Iterate over each path glob the dir + program. path.split(File::PATH_SEPARATOR).each do |dir| dir = Aruba.platform.(dir, Dir.getwd) next unless Aruba.platform.exist?(dir) # In case of bogus second argument found = Dir[File.join(dir, program)].first return found if found && Aruba.platform.executable?(found) end nil end |