Module: FSSM::Support
- Defined in:
- lib/fssm/support.rb
Class Method Summary collapse
- .backend ⇒ Object
- .carbon_core? ⇒ Boolean
- .jruby? ⇒ Boolean
- .linux? ⇒ Boolean
- .mac? ⇒ Boolean
- .rb_inotify? ⇒ Boolean
- .use_block(context, block) ⇒ Object
Class Method Details
.backend ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fssm/support.rb', line 5 def backend @@backend ||= case when mac? && !jruby? && carbon_core? 'FSEvents' when linux? && rb_inotify? 'Inotify' else 'Polling' end end |
.carbon_core? ⇒ Boolean
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fssm/support.rb', line 28 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 |
.jruby? ⇒ Boolean
16 17 18 |
# File 'lib/fssm/support.rb', line 16 def jruby? defined?(JRUBY_VERSION) end |
.linux? ⇒ Boolean
24 25 26 |
# File 'lib/fssm/support.rb', line 24 def linux? Config::CONFIG['target_os'] =~ /linux/i end |
.mac? ⇒ Boolean
20 21 22 |
# File 'lib/fssm/support.rb', line 20 def mac? Config::CONFIG['target_os'] =~ /darwin/i end |
.rb_inotify? ⇒ Boolean
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fssm/support.rb', line 39 def rb_inotify? found = begin require 'rb-inotify' if defined?(INotify::VERSION) version = INotify::VERSION version[0] > 0 || version[1] >= 6 end rescue LoadError false end STDERR.puts("Warning: Unable to load rb-inotify >= 0.5.1. Inotify will be unavailable.") unless found found end |
.use_block(context, block) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/fssm/support.rb', line 53 def use_block(context, block) return if block.nil? if block.arity == 1 block.call(context) else context.instance_eval(&block) end end |