# File lib/fssm/support.rb, line 31 def backend @@backend ||= usable_backend end
# File lib/fssm/support.rb, line 51 def carbon_core? begin require 'osx/foundation' OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework' true rescue LoadError false end end
# File lib/fssm/support.rb, line 35 def jruby? defined?(JRUBY_VERSION) end
# File lib/fssm/support.rb, line 47 def linux? Config::CONFIG['target_os'] =~ %rlinux/ end
# File lib/fssm/support.rb, line 43 def lion? Config::CONFIG['target_os'] =~ %rdarwin11/ end
# File lib/fssm/support.rb, line 39 def mac? Config::CONFIG['target_os'] =~ %rdarwin/ end
# File lib/fssm/support.rb, line 61 def rb_fsevent? begin require 'rb-fsevent' defined?(FSEvent::VERSION) ? FSEvent::VERSION.to_f >= 0.4 : false rescue LoadError false end end
# File lib/fssm/support.rb, line 70 def rb_inotify? begin require 'rb-inotify' if defined?(INotify::VERSION) version = INotify::VERSION version[0] > 0 || version[1] >= 6 end rescue LoadError false end end
# File lib/fssm/support.rb, line 5 def usable_backend choice = case when mac? && !lion? && !jruby? && carbon_core? 'FSEvents' when mac? && rb_fsevent? 'RBFSEvent' when linux? && rb_inotify? 'Inotify' else 'Polling' end if (mac? || linux?) && choice == 'Polling' optimal = case when mac? 'rb-fsevent' when linux? 'rb-inotify' end FSSM.dbg("An optimized backend is available for this platform!") FSSM.dbg(" gem install #{optimal}") end choice end
# File lib/fssm/support.rb, line 82 def use_block(context, block) return if block.nil? if block.arity == 1 block.call(context) else context.instance_eval(&block) end end