Class: Bundler::CurrentRuby

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/current_ruby.rb

Constant Summary collapse

ALL_RUBY_VERSIONS =
[*18..27, *30..34, 40].freeze
KNOWN_MINOR_VERSIONS =
ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze
KNOWN_MAJOR_VERSIONS =
ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze
PLATFORM_MAP =
{
  ruby: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
  mri: [Gem::Platform::RUBY, CurrentRuby::ALL_RUBY_VERSIONS],
  rbx: [Gem::Platform::RUBY],
  truffleruby: [Gem::Platform::RUBY],
  jruby: [Gem::Platform::JAVA, [18, 19]],
  windows: [Gem::Platform::WINDOWS, CurrentRuby::ALL_RUBY_VERSIONS],
  # deprecated
  mswin: [Gem::Platform::MSWIN, CurrentRuby::ALL_RUBY_VERSIONS],
  mswin64: [Gem::Platform::MSWIN64, CurrentRuby::ALL_RUBY_VERSIONS - [18]],
  mingw: [Gem::Platform::UNIVERSAL_MINGW, CurrentRuby::ALL_RUBY_VERSIONS],
  x64_mingw: [Gem::Platform::UNIVERSAL_MINGW, CurrentRuby::ALL_RUBY_VERSIONS - [18, 19]],
}.each_with_object({}) do |(platform, spec), hash|
  hash[platform] = spec[0]
  spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }
end.freeze

Instance Method Summary collapse

Instance Method Details

#jruby?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/bundler/current_ruby.rb', line 48

def jruby?
  RUBY_ENGINE == "jruby"
end

#maglev?Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
# File 'lib/bundler/current_ruby.rb', line 52

def maglev?
  removed_message =
    "`CurrentRuby#maglev?` was removed with no replacement. Please use the " \
    "built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
  SharedHelpers.feature_removed!(removed_message)
end

#mri?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/bundler/current_ruby.rb', line 40

def mri?
  !windows? && RUBY_ENGINE == "ruby"
end

#rbx?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/bundler/current_ruby.rb', line 44

def rbx?
  ruby? && RUBY_ENGINE == "rbx"
end

#ruby?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
# File 'lib/bundler/current_ruby.rb', line 34

def ruby?
  return true if Bundler::MatchPlatform.generic_local_platform_is_ruby?

  !windows? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
end

#truffleruby?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/bundler/current_ruby.rb', line 59

def truffleruby?
  RUBY_ENGINE == "truffleruby"
end

#windows?Boolean Also known as: mswin?, mswin64?, mingw?, x64_mingw?

Returns:

  • (Boolean)


63
64
65
# File 'lib/bundler/current_ruby.rb', line 63

def windows?
  Gem.win_platform?
end