Sha256: 6fadf8d4b0e397f6f5d14f25419f349e2bc3562ab340cd44b873d580256f8005

Contents?: true

Size: 1.25 KB

Versions: 11

Compression:

Stored size: 1.25 KB

Contents

module Concurrent
  module Utility

    # @!visibility private
    module EngineDetector
      def on_jruby?
        ruby_engine == 'jruby'
      end

      def on_jruby_9000?
        on_jruby? && 0 == (JRUBY_VERSION =~ /^9\.0\.0\.0/)
      end

      def on_cruby?
        ruby_engine == 'ruby'
      end

      def on_rbx?
        ruby_engine == 'rbx'
      end

      def on_truffle?
        ruby_engine == 'jruby+truffle'
      end

      def on_windows?
        !(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/).nil?
      end

      def on_osx?
        !(RbConfig::CONFIG['host_os'] =~ /darwin|mac os/).nil?
      end

      def on_linux?
        !(RbConfig::CONFIG['host_os'] =~ /linux/).nil?
      end

      def ruby_engine
        defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
      end

      def ruby_version(comparison, major, minor = 0, patch = 0)
        result      = (RUBY_VERSION.split('.').map(&:to_i) <=> [major, minor, patch])
        comparisons = { :== => [0],
                        :>= => [1, 0],
                        :<= => [-1, 0],
                        :>  => [1],
                        :<  => [-1] }
        comparisons.fetch(comparison).include? result
      end
    end
  end

  # @!visibility private
  extend Utility::EngineDetector
end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/engine.rb
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/engine.rb
tdiary-5.0.2 vendor/bundle/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/engine.rb
tdiary-5.0.1 vendor/bundle/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/engine.rb
concurrent-ruby-1.0.3.pre3-java lib/concurrent/utility/engine.rb
concurrent-ruby-1.0.3.pre3 lib/concurrent/utility/engine.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.2/lib/concurrent/utility/engine.rb
concurrent-ruby-1.0.2-java lib/concurrent/utility/engine.rb
concurrent-ruby-1.0.2 lib/concurrent/utility/engine.rb
concurrent-ruby-1.0.1-java lib/concurrent/utility/engine.rb
concurrent-ruby-1.0.1 lib/concurrent/utility/engine.rb