class Supercast::Client::SystemProfiler
SystemProfiler
extracts information about the system that we're running in so that we can generate a rich user agent header to help debug integrations.
Public Class Methods
new()
click to toggle source
# File lib/supercast/client.rb, line 531 def initialize @uname = self.class.uname end
uname()
click to toggle source
# File lib/supercast/client.rb, line 500 def self.uname if ::File.exist?('/proc/version') ::File.read('/proc/version').strip else case RbConfig::CONFIG['host_os'] when /linux|darwin|bsd|sunos|solaris|cygwin/i uname_from_system when /mswin|mingw/i uname_from_system_ver else 'unknown platform' end end end
uname_from_system()
click to toggle source
# File lib/supercast/client.rb, line 515 def self.uname_from_system (`uname -a 2>/dev/null` || '').strip rescue Errno::ENOENT 'uname executable not found' rescue Errno::ENOMEM # couldn't create subprocess 'uname lookup failed' end
uname_from_system_ver()
click to toggle source
# File lib/supercast/client.rb, line 523 def self.uname_from_system_ver (`ver` || '').strip rescue Errno::ENOENT 'ver executable not found' rescue Errno::ENOMEM # couldn't create subprocess 'uname lookup failed' end
Public Instance Methods
user_agent()
click to toggle source
# File lib/supercast/client.rb, line 535 def user_agent lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} " \ "(#{RUBY_RELEASE_DATE})" { bindings_version: Supercast::VERSION, lang: 'ruby', lang_version: lang_version, platform: RUBY_PLATFORM, engine: defined?(RUBY_ENGINE) ? RUBY_ENGINE : '', publisher: 'supercast', uname: @uname, hostname: Socket.gethostname }.delete_if { |_k, v| v.nil? } end