Module: RestClient::Platform

Defined in:
lib/restclient/platform.rb

Class Method Summary collapse

Class Method Details

.architectureObject



32
33
34
# File 'lib/restclient/platform.rb', line 32

def self.architecture
  "#{RbConfig::CONFIG['host_os']} #{RbConfig::CONFIG['host_cpu']}"
end

.default_user_agentObject



45
46
47
# File 'lib/restclient/platform.rb', line 45

def self.default_user_agent
  "rest-client/#{VERSION} (#{architecture}) #{ruby_agent_version}"
end

.jruby?Boolean

Return true if we are running on jruby.

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/restclient/platform.rb', line 27

def self.jruby?
  # defined on mri >= 1.9
  RUBY_ENGINE == 'jruby'
end

.mac_mri?Boolean

Return true if we are running on a darwin-based Ruby platform. This will be false for jruby even on OS X.

Returns:

  • (Boolean)


9
10
11
# File 'lib/restclient/platform.rb', line 9

def self.mac_mri?
  RUBY_PLATFORM.include?('darwin')
end

.ruby_agent_versionObject



36
37
38
39
40
41
42
43
# File 'lib/restclient/platform.rb', line 36

def self.ruby_agent_version
  case RUBY_ENGINE
  when 'jruby'
    "jruby/#{JRUBY_VERSION} (#{RUBY_VERSION}p#{RUBY_PATCHLEVEL})"
  else
    "#{RUBY_ENGINE}/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
  end
end

.windows?Boolean

Return true if we are running on Windows.

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/restclient/platform.rb', line 17

def self.windows?
  # Ruby only sets File::ALT_SEPARATOR on Windows, and the Ruby standard
  # library uses that to test what platform it's on.
  !!File::ALT_SEPARATOR
end