blob: 0c574b2abb8930e80d8ff80381adabd34ff0613a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
module Concurrent
# @!visibility private
module Utility
# @!visibility private
module EngineDetector
def on_cruby?
RUBY_ENGINE == 'ruby'
end
def on_jruby?
RUBY_ENGINE == 'jruby'
end
def on_truffleruby?
RUBY_ENGINE == 'truffleruby'
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_version(version = RUBY_VERSION, comparison, major, minor, patch)
result = (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
|