Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/mongo/server/app_metadata/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,34 @@ def initialize(metadata)
@metadata = metadata
end

# Queries whether the current runtime is Ruby MRI or not.
#
# @return [ true | false ] whether the runtime is Ruby MRI or not.
def mri?
RUBY_ENGINE == 'ruby'
end

# Queries whether the current runtime is JRuby or not.
#
# @return [ true | false ] whether the runtime is JRuby or not.
def jruby?
BSON::Environment.jruby?
RUBY_ENGINE == 'jruby'
end

ENGINE_NAMES = { 'jruby' => 'JRuby', 'truffleruby' => 'TruffleRuby' }.freeze

def engine_name
ENGINE_NAMES[RUBY_ENGINE] || RUBY_ENGINE
end

# Returns the list of Ruby versions that identify this runtime.
#
# @return [ Array<String> ] the list of ruby versions
def ruby_versions
if jruby?
[ "JRuby #{JRUBY_VERSION}", "like Ruby #{RUBY_VERSION}" ]
else
if mri?
[ "Ruby #{RUBY_VERSION}" ]
else
[ "#{engine_name} #{RUBY_ENGINE_VERSION}", "like Ruby #{RUBY_VERSION}" ]
end
end

Expand Down
Loading