Sha256: a00d32b19c2dd35283c4cd364a857cf482550a93be92d1cec9e7999f4f7bb63b

Contents?: true

Size: 1.34 KB

Versions: 302

Compression:

Stored size: 1.34 KB

Contents

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

    def mac?
      Config::CONFIG['target_os'] =~ /darwin/i
    end

    def linux?
      Config::CONFIG['target_os'] =~ /linux/i
    end

    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?
      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

    def use_block(context, block)
      return if block.nil?
      if block.arity == 1
        block.call(context)
      else
        context.instance_eval(&block)
      end
    end

  end
end

Version data entries

302 entries across 302 versions & 6 rubygems

Version Path
haml-3.1.3 vendor/sass/vendor/fssm/lib/fssm/support.rb
haml-3.2.0.alpha.8 vendor/sass/vendor/fssm/lib/fssm/support.rb
sass-3.1.4 vendor/fssm/lib/fssm/support.rb
sass-3.2.0.alpha.11 vendor/fssm/lib/fssm/support.rb
sass-3.1.3 vendor/fssm/lib/fssm/support.rb
sass-3.2.0.alpha.9 vendor/fssm/lib/fssm/support.rb
sass-3.2.0.alpha.8 vendor/fssm/lib/fssm/support.rb
haml-3.2.0.alpha.5 vendor/sass/vendor/fssm/lib/fssm/support.rb
haml-3.2.0.alpha.4 vendor/sass/vendor/fssm/lib/fssm/support.rb
haml-3.1.2 vendor/sass/vendor/fssm/lib/fssm/support.rb
sass-3.1.2 vendor/fssm/lib/fssm/support.rb
sass-3.2.0.alpha.7 vendor/fssm/lib/fssm/support.rb
sass-3.2.0.alpha.6 vendor/fssm/lib/fssm/support.rb
radiant-1.0.0.rc1 vendor/plugins/haml/vendor/fssm/lib/fssm/support.rb
haml-3.2.0.alpha.3 vendor/sass/vendor/fssm/lib/fssm/support.rb
sass-3.2.0.alpha.4 vendor/fssm/lib/fssm/support.rb
sass-3.2.0.alpha.3 vendor/fssm/lib/fssm/support.rb
sass-3.1.1 vendor/fssm/lib/fssm/support.rb
haml-3.2.0.alpha.2 vendor/sass/vendor/fssm/lib/fssm/support.rb
haml-3.1.1 vendor/sass/vendor/fssm/lib/fssm/support.rb