Class: Stripe::StripeClient::SystemProfiler
- Inherits:
-
Object
- Object
- Stripe::StripeClient::SystemProfiler
- Defined in:
- lib/stripe/stripe_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.
645 646 647 |
# File 'lib/stripe/stripe_client.rb', line 645 def initialize @uname = self.class.uname end |
Class Method Details
.uname ⇒ Object
614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
# File 'lib/stripe/stripe_client.rb', line 614 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
629 630 631 632 633 634 635 |
# File 'lib/stripe/stripe_client.rb', line 629 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
637 638 639 640 641 642 643 |
# File 'lib/stripe/stripe_client.rb', line 637 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
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
# File 'lib/stripe/stripe_client.rb', line 649 def user_agent lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} " \ "(#{RUBY_RELEASE_DATE})" { application: Stripe.app_info, bindings_version: Stripe::VERSION, lang: "ruby", lang_version: lang_version, platform: RUBY_PLATFORM, engine: defined?(RUBY_ENGINE) ? RUBY_ENGINE : "", publisher: "stripe", uname: @uname, hostname: Socket.gethostname, }.delete_if { |_k, v| v.nil? } end |