Class: Helio::HelioClient::SystemProfiler
- Inherits:
-
Object
- Object
- Helio::HelioClient::SystemProfiler
- Defined in:
- lib/helio/helio_client.rb
Overview
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.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ SystemProfiler
constructor
A new instance of SystemProfiler.
- #user_agent ⇒ Object
Constructor Details
#initialize ⇒ SystemProfiler
Returns a new instance of SystemProfiler.
523 524 525 |
# File 'lib/helio/helio_client.rb', line 523 def initialize @uname = self.class.uname end |
Class Method Details
.uname ⇒ Object
492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
# File 'lib/helio/helio_client.rb', line 492 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 ⇒ Object
507 508 509 510 511 512 513 |
# File 'lib/helio/helio_client.rb', line 507 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 ⇒ Object
515 516 517 518 519 520 521 |
# File 'lib/helio/helio_client.rb', line 515 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 |
Instance Method Details
#user_agent ⇒ Object
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
# File 'lib/helio/helio_client.rb', line 527 def user_agent lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})" { application: Helio.app_info, bindings_version: Helio::VERSION, lang: "ruby", lang_version: lang_version, platform: RUBY_PLATFORM, engine: defined?(RUBY_ENGINE) ? RUBY_ENGINE : "", publisher: "helio", uname: @uname, hostname: Socket.gethostname, }.delete_if { |_k, v| v.nil? } end |