module Digitalfilmtree::Util

Constants

FILE_SEP
VERSION

Public Class Methods

new() click to toggle source
# File lib/digitalfilmtree/util.rb, line 27
def initialize
  @os = RbConfig::CONFIG['host_os']
end
platform() click to toggle source

Introspect about the platform

# File lib/digitalfilmtree/util.rb, line 24
def self.platform
  require 'rbconfig'
  @platform ||= Class.new do
    def initialize
      @os = RbConfig::CONFIG['host_os']
    end

    def windows?
      @os =~ /mswin|mingw|cygwin/
    end

    def mac?
      @os =~ /darwin/
    end

    def linux?
      @os =~ /linux/
    end

    def to_s
      @os
    end
  end.new
end
safe_path(path) click to toggle source

Pass a file path through this to fix separators

# File lib/digitalfilmtree/util.rb, line 9
def self.safe_path path
  path.gsub(File::SEPARATOR, FILE_SEP)
end
vendored_bin(name, platform, filename) click to toggle source

Grab a vendored binary

# File lib/digitalfilmtree/util.rb, line 15
def self.vendored_bin name, platform, filename
  Util.safe_path(File.expand_path(
    File.join(File.dirname(__FILE__), 
              '..', '..','vendor', 'util', 
              name.to_s, platform.to_s, filename)))
end

Public Instance Methods

linux?() click to toggle source
# File lib/digitalfilmtree/util.rb, line 39
def linux?
  @os =~ /linux/
end
mac?() click to toggle source
# File lib/digitalfilmtree/util.rb, line 35
def mac?
  @os =~ /darwin/
end
to_s() click to toggle source
# File lib/digitalfilmtree/util.rb, line 43
def to_s
  @os
end
windows?() click to toggle source
# File lib/digitalfilmtree/util.rb, line 31
def windows?
  @os =~ /mswin|mingw|cygwin/
end