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