File: bin.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (26 lines) | stat: -rw-r--r-- 603 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'facets/filetest/safe'
require 'facets/filetest/contains'
require 'facets/filetest/relative'

=begin
module FileTest

  # Return a cached list of the PATH environment variable.
  # This is a support method used by #bin?
  def command_paths
    @command_paths ||= ENV['PATH'].split(/[:;]/)
  end

  # Is a file a bin/ executable?
  #
  # TODO: Make more robust. Probably needs to be fixed for Windows.
  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

end
=end