Module: FileTest
- Defined in:
- lib/detroit/core_ext/filetest.rb
Instance Method Summary collapse
-
#bin?(fname) ⇒ Boolean
Is a file a bin/ executable?.
-
#command_paths ⇒ Object
Return a cached list of the PATH environment variable.
Instance Method Details
#bin?(fname) ⇒ Boolean
Is a file a bin/ executable?
TODO: Make more robust. Probably needs to be fixed for Windows.
12 13 14 15 16 17 18 |
# File 'lib/detroit/core_ext/filetest.rb', line 12 def bin?(fname) is_bin = command_paths.any? do |f| FileTest.exist?(File.join(f, fname)) end #is_bin ? File.basename(fname) : false is_bin ? fname : false end |
#command_paths ⇒ Object
Return a cached list of the PATH environment variable. This is a support method used by #bin?
5 6 7 |
# File 'lib/detroit/core_ext/filetest.rb', line 5 def command_paths @command_paths ||= ENV['PATH'].split(/[:;]/) end |