Module: Editors::Helpers::PlatformDetection

Included in:
Editors
Defined in:
lib/editors/helpers/platform_detection.rb

Overview

Utilities for detecting which platform and which version of ruby the user is running

Author:

  • Jeff Sandberg

Instance Method Summary collapse

Instance Method Details

#jruby?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/editors/helpers/platform_detection.rb', line 18

def jruby?
  RbConfig::CONFIG['ruby_install_name'] == 'jruby'
end

#jruby_19?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/editors/helpers/platform_detection.rb', line 22

def jruby_19?
  jruby? && RbConfig::CONFIG['ruby_version'] == '1.9'
end

#mri?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/editors/helpers/platform_detection.rb', line 30

def mri?
  RbConfig::CONFIG['ruby_install_name'] == 'ruby'
end

#mri_19?Boolean

rubocop:disable Style/DoubleNegation

Returns:

  • (Boolean)


34
35
36
# File 'lib/editors/helpers/platform_detection.rb', line 34

def mri_19?
  !!(mri? && RUBY_VERSION =~ /^1\.9/)
end

#mri_20?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/editors/helpers/platform_detection.rb', line 42

def mri_20?
  !!(mri? && RUBY_VERSION =~ /^2\.0/)
end

#mri_21?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/editors/helpers/platform_detection.rb', line 46

def mri_21?
  !!(mri? && RUBY_VERSION =~ /^2\.1/)
end

#mri_2?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/editors/helpers/platform_detection.rb', line 38

def mri_2?
  !!(mri? && RUBY_VERSION =~ /^2/)
end

#rbx?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/editors/helpers/platform_detection.rb', line 26

def rbx?
  RbConfig::CONFIG['ruby_install_name'] == 'rbx'
end

#windows?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/editors/helpers/platform_detection.rb', line 7

def windows?
  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
end

#windows_ansi?Boolean

Determines if we can use ANSI on windows

Returns:

  • (Boolean)


14
15
16
# File 'lib/editors/helpers/platform_detection.rb', line 14

def windows_ansi?
  defined?(Win32::Console) || ENV['ANSICON'] || (windows? && mri_2?)
end