Class: Bundler::CurrentRuby

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

Constant Summary collapse

ALL_RUBY_VERSIONS =
(18..27).to_a.concat((30..35).to_a).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)
[View source]

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

def jruby?
  RUBY_ENGINE == "jruby"
end

#maglev?Boolean

Returns:

  • (Boolean)
[View source]

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

def maglev?
  RUBY_ENGINE == "maglev"
end

#mri?Boolean

Returns:

  • (Boolean)
[View source]

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

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

#rbx?Boolean

Returns:

  • (Boolean)
[View source]

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

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

#ruby?Boolean

Returns:

  • (Boolean)
[View source]

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

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

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

#truffleruby?Boolean

Returns:

  • (Boolean)
[View source]

56
57
58
# File 'lib/bundler/current_ruby.rb', line 56

def truffleruby?
  RUBY_ENGINE == "truffleruby"
end

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

Returns:

  • (Boolean)
[View source]

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

def windows?
  Gem.win_platform?
end