File: platform_extension_helpers.rb

package info (click to toggle)
rake-compiler 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 324 kB
  • sloc: ruby: 1,497; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 582 bytes parent folder | download | duplicates (7)
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
27
module PlatformExtensionHelpers
  def binary_extension(platform = RUBY_PLATFORM)
    case platform
      when /darwin/
        'bundle'
      when /mingw|mswin|linux/
        'so'
      when /java/
        'jar'
      else
        RbConfig::CONFIG['DLEXT']
    end
  end

  def search_path(binaries)
    paths = ENV['PATH'].split(File::PATH_SEPARATOR)
    binary = binaries.find do |bin_file|
      paths.find do |path|
        bin = File.join(path, bin_file)
        File.exist?(bin) && File.executable?(bin)
      end
    end
    binary
  end
end

World(PlatformExtensionHelpers)