Sha256: ab8f6e65fd01e6f702cee24db49ff5b7832b5cddd60369b3726f3e2c05d868dd

Contents?: true

Size: 525 Bytes

Versions: 14

Compression:

Stored size: 525 Bytes

Contents

module Heirloom
  module Utils
    module File

      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

      def path_separator
        ::File::PATH_SEPARATOR
      end

      def path
        ENV['PATH']
      end

      def pathext
        ENV['PATHEXT']
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
heirloom-0.12.7 lib/heirloom/utils/file.rb
heirloom-0.12.5 lib/heirloom/utils/file.rb
heirloom-0.12.4 lib/heirloom/utils/file.rb
heirloom-0.12.3 lib/heirloom/utils/file.rb
heirloom-0.12.2 lib/heirloom/utils/file.rb
heirloom-0.12.1 lib/heirloom/utils/file.rb
heirloom-0.12.0 lib/heirloom/utils/file.rb
heirloom-0.11.2 lib/heirloom/utils/file.rb
heirloom-0.11.1 lib/heirloom/utils/file.rb
heirloom-0.11.0 lib/heirloom/utils/file.rb
heirloom-0.11.0.beta.2 lib/heirloom/utils/file.rb
heirloom-0.11.0.beta.1 lib/heirloom/utils/file.rb
heirloom-0.10.1 lib/heirloom/utils/file.rb
heirloom-0.10.0 lib/heirloom/utils/file.rb