blob: 98a86efb04e638113ce9b143270c6f77744db587 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
class Pry
module Platform
extend self
#
# @return [Boolean]
# Returns true if Pry is running on Mac OSX.
#
# @note
# Queries RbConfig::CONFIG['host_os'] with a best guess.
#
def mac_osx?
!!(RbConfig::CONFIG['host_os'] =~ /\Adarwin/i)
end
#
# @return [Boolean]
# Returns true if Pry is running on Linux.
#
# @note
# Queries RbConfig::CONFIG['host_os'] with a best guess.
#
def linux?
!!(RbConfig::CONFIG['host_os'] =~ /linux/i)
end
#
# @return [Boolean]
# Returns true if Pry is running on Windows.
#
# @note
# Queries RbConfig::CONFIG['host_os'] with a best guess.
#
def windows?
!!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
end
#
# @return [Boolean]
# Returns true when Pry is running on Windows with ANSI support.
#
def windows_ansi?
return false if not windows?
!!(defined?(Win32::Console) or ENV['ANSICON'] or mri_2?)
end
#
# @return [Boolean]
# Returns true when Pry is being run from JRuby.
#
def jruby?
RbConfig::CONFIG['ruby_install_name'] == 'jruby'
end
#
# @return [Boolean]
# Returns true when Pry is being run from JRuby in 1.9 mode.
#
def jruby_19?
jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
end
#
# @return [Boolean]
# Returns true when Pry is being run from MRI (CRuby).
#
def mri?
RbConfig::CONFIG['ruby_install_name'] == 'ruby'
end
#
# @return [Boolean]
# Returns true when Pry is being run from MRI v1.9+ (CRuby).
#
def mri_19?
!!(mri? and RUBY_VERSION =~ /\A1\.9/)
end
#
# @return [Boolean]
# Returns true when Pry is being run from MRI v2+ (CRuby).
#
def mri_2?
!!(mri? and RUBY_VERSION =~ /\A2/)
end
#
# @return [Array<Symbol>]
# Returns an Array of Ruby engines that Pry is known to run on.
#
def known_engines
[:jruby, :mri]
end
end
# Not supported on MRI 2.2 and lower.
deprecate_constant(:Platform) if respond_to?(:deprecate_constant)
end
|