Module: Develry::Platform

Included in:
Develry
Defined in:
lib/develry/platform.rb

Overview

Provides methods to determine the ruby platform

Constant Summary collapse

DEFAULT_RVM_NAME =
'mri'.freeze

Instance Method Summary collapse

Instance Method Details

#jit?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for being executed under rubies with a JIT

Returns:

  • (true)

    if running under JRuby or rbx

  • (false)

    otherwise



75
76
77
# File 'lib/develry/platform.rb', line 75

def jit?
  jruby? || rbx?
end

#jruby?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for being executed under JRuby

Returns:

  • (true)

    if running under JRuby

  • (false)

    otherwise



49
50
51
# File 'lib/develry/platform.rb', line 49

def jruby?
  ruby_engine == 'jruby'
end

#rbx?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for being executed under rbx

Returns:

  • (true)

    if running under rbx

  • (false)

    otherwise



62
63
64
# File 'lib/develry/platform.rb', line 62

def rbx?
  ruby_engine == 'rbx'
end

#ruby18?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for 1.8 mode

Returns:

  • (true)

    if running under 1.8.x

  • (false)

    otherwise



88
89
90
# File 'lib/develry/platform.rb', line 88

def ruby18?
  RUBY_VERSION.start_with?('1.8.')
end

#ruby19?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for 1.9 mode

Returns:

  • (true)

    if running under 1.9.x

  • (false)

    otherwise



101
102
103
# File 'lib/develry/platform.rb', line 101

def ruby19?
  RUBY_VERSION.start_with?('1.9.')
end

#ruby20?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test for 2.0 mode

Returns:

  • (true)

    if running under 2.0.x

  • (false)

    otherwise



114
115
116
# File 'lib/develry/platform.rb', line 114

def ruby20?
  RUBY_VERSION.start_with?('2.0.')
end

#ruby_engineString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return Ruby engine string

Returns:

  • (String)


15
16
17
# File 'lib/develry/platform.rb', line 15

def ruby_engine
  @ruby_engine ||= (defined?(RUBY_ENGINE) && RUBY_ENGINE || 'ruby').freeze
end

#rvmString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return RVM string

Returns:

  • (String)


36
37
38
# File 'lib/develry/platform.rb', line 36

def rvm
  @rvm ||= "#{rvm_name}-#{RUBY_VERSION}".freeze
end

#rvm_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return RVM name

Returns:

  • (String)


24
25
26
27
28
29
# File 'lib/develry/platform.rb', line 24

def rvm_name
  @rvm_name ||= begin
    engine = ruby_engine
    engine == 'ruby' ? DEFAULT_RVM_NAME : engine
  end
end