mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
49497498ca
Platform is a category module that adds utility functions for querying platform information relating to Pry. Some methods are moved from BaseHelpers, and for backwards compatibility included via 'include Pry::Platform'. module_function is not used by BaseHelpers anymore, in favour of include/extend being used in its place. There is also less indentation noise in BaseHelpers module. With _pry_.h (available on the backup master branch) these methods exist on a single module that doesn't pollute the command scope, although for backwards compatibility we still include the functions as top-level command functions.
93 lines
1.8 KiB
Ruby
93 lines
1.8 KiB
Ruby
module Pry::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 Rubinius.
|
|
#
|
|
def rbx?
|
|
RbConfig::CONFIG['ruby_install_name'] == 'rbx'
|
|
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
|
|
end
|