compass/lib/vendor/fssm/support.rb

52 lines
1.0 KiB
Ruby
Raw Normal View History

require 'rbconfig'
module FSSM::Support
class << self
def backend
@@backend ||= case
when mac? && !jruby? && carbon_core?
'FSEvents'
when linux? && rb_inotify?
'Inotify'
else
'Polling'
end
end
def jruby?
defined?(JRUBY_VERSION)
end
2009-09-03 05:42:59 +00:00
def mac?
Config::CONFIG['target_os'] =~ /darwin/i
end
def linux?
Config::CONFIG['target_os'] =~ /linux/i
end
2009-09-03 05:42:59 +00:00
def carbon_core?
begin
require 'osx/foundation'
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
true
rescue LoadError
STDERR.puts("Warning: Unable to load CarbonCore. FSEvents will be unavailable.")
false
end
end
def rb_inotify?
begin
require 'rubygems'
require 'rb-inotify'
true
rescue LoadError, Gem::LoadError
STDERR.puts("Warning: Unable to load rb-inotify. Inotify will be unavailable.")
false
end
end
end
end