Sha256: 143c57679eb92bb7f88c119262de4ef7a24f6b3cd186afa5f74226d426069169

Contents?: true

Size: 688 Bytes

Versions: 22

Compression:

Stored size: 688 Bytes

Contents

#--
# Copyright (c) 2010-2012 Engine Yard, Inc.
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
# This source code is available under the MIT license.
# See the file LICENSE.txt for details.
#++

module Warbler
  module PlatformHelper
    # Cross-platform way of finding an executable in the $PATH.
    # Thanks to @mislav
    #
    #   which('ruby') #=> /usr/bin/ruby
    def which(cmd)
      exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
      ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
        exts.each { |ext|
          exe = File.join(path, "#{cmd}#{ext}")
          return exe if File.executable? exe
        }
      end
      return nil
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
warbler_updated-2.1.0 lib/warbler/platform_helper.rb
warbler-2.0.5 lib/warbler/platform_helper.rb
warbler-2.0.4 lib/warbler/platform_helper.rb
warbler-1.4.10 lib/warbler/platform_helper.rb
warbler-2.0.3 lib/warbler/platform_helper.rb
warbler-2.0.2 lib/warbler/platform_helper.rb
warbler-2.0.1 lib/warbler/platform_helper.rb
warbler-2.0.0 lib/warbler/platform_helper.rb
warbler-2.0.0.rc3 lib/warbler/platform_helper.rb
warbler-2.0.0.rc2 lib/warbler/platform_helper.rb
warbler-2.0.0.rc1 lib/warbler/platform_helper.rb
warbler-2.0.0.pre3 lib/warbler/platform_helper.rb
warbler-2.0.0.pre2 lib/warbler/platform_helper.rb
warbler-1.4.9 lib/warbler/platform_helper.rb
warbler-1.4.8 lib/warbler/platform_helper.rb
warbler-2.0.0.pre1 lib/warbler/platform_helper.rb
warbler-1.4.7 lib/warbler/platform_helper.rb
warbler-1.4.6 lib/warbler/platform_helper.rb
warbler-1.4.5 lib/warbler/platform_helper.rb
warbler-1.4.4 lib/warbler/platform_helper.rb