Class: Mongo::Server::AppMetadata::Platform Private
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | lib/mongo/server/app_metadata/platform.rb | 
Overview
Implements the logic for building the platform string for the handshake.
Class Method Summary
- 
    
      .new(metadata)  ⇒ Platform 
    
    constructor
    Internal use only
    
Create a new
Platformobject, referencing the given metadata object. 
Instance Attribute Summary
- 
    
      #jruby?  ⇒ true | false 
    
    readonly
    Internal use only
    
Queries whether the current runtime is JRuby or not.
 - #metadata ⇒ Mongo::Server::AppMetadata readonly Internal use only
 
Instance Method Summary
- 
    
      #default_platform_list  ⇒ Array<String> 
    
    Internal use only
    
Builds and returns the default platform list, for use when building the platform string.
 - 
    
      #java_version  ⇒ String | nil 
    
    Internal use only
    
Returns the version of the current Java environment, or nil if not invoked with JRuby.
 - 
    
      #platforms  ⇒ Array<String> 
    
    Internal use only
    
Returns the list of platform identifiers that identify this runtime.
 - 
    
      #purpose  ⇒ String | nil 
    
    Internal use only
    
Returns a single letter representing the purpose reported to the metadata, or nil if no purpose was specified.
 - 
    
      #ruby_versions  ⇒ Array<String> 
    
    Internal use only
    
Returns the list of Ruby versions that identify this runtime.
 - 
    
      #to_s  ⇒ String 
    
    Internal use only
    
Builds and returns the platform string by concatenating relevant values together.
 
Instance Attribute Details
    #jruby?  ⇒ true | false  (readonly)
  
Queries whether the current runtime is JRuby or not.
# File 'lib/mongo/server/app_metadata/platform.rb', line 40
def jruby? BSON::Environment.jruby? end
#metadata ⇒ Mongo::Server::AppMetadata (readonly)
# File 'lib/mongo/server/app_metadata/platform.rb', line 27
attr_reader :
Instance Method Details
    #default_platform_list  ⇒ Array<String> 
  
Builds and returns the default platform list, for use when building the platform string.
# File 'lib/mongo/server/app_metadata/platform.rb', line 78
def default_platform_list [ .platform, *ruby_versions, *platforms, RbConfig::CONFIG['build'] ] end
    #java_version  ⇒ String | nil 
  
Returns the version of the current Java environment, or nil if not invoked with JRuby.
# File 'lib/mongo/server/app_metadata/platform.rb', line 68
def java_version return nil unless jruby? java.lang.System.get_property('java.version') end
    #platforms  ⇒ Array<String> 
  
Returns the list of platform identifiers that identify this runtime.
# File 'lib/mongo/server/app_metadata/platform.rb', line 58
def platforms [ RUBY_PLATFORM ].tap do |list| list.push "JVM #{java_version}" if jruby? end end
    #purpose  ⇒ String | nil 
  
Returns a single letter representing the purpose reported to the metadata, or nil if no purpose was specified.
# File 'lib/mongo/server/app_metadata/platform.rb', line 91
def purpose return nil unless .purpose .purpose.to_s[0].upcase end
    #ruby_versions  ⇒ Array<String> 
  
Returns the list of Ruby versions that identify this runtime.
# File 'lib/mongo/server/app_metadata/platform.rb', line 47
def ruby_versions if jruby? [ "JRuby #{JRUBY_VERSION}", "like Ruby #{RUBY_VERSION}" ] else [ "Ruby #{RUBY_VERSION}" ] end end
    #to_s  ⇒ String 
  
Builds and returns the platform string by concatenating relevant values together.
# File 'lib/mongo/server/app_metadata/platform.rb', line 101
def to_s primary = [ *default_platform_list, purpose ].compact.join(', ') list = [ primary ] .wrapping_libraries&.each do |library| list << (library[:platform] || '') end list.join('|') end