Class: Stripe::APIRequestor::SystemProfiler
- Inherits:
-
Object
- Object
- Stripe::APIRequestor::SystemProfiler
- Defined in:
- lib/stripe/api_requestor.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.
1084 1085 1086 |
# File 'lib/stripe/api_requestor.rb', line 1084 def initialize @uname = self.class.uname end |
Class Method Details
.uname ⇒ Object
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'lib/stripe/api_requestor.rb', line 1053 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
1068 1069 1070 1071 1072 1073 1074 |
# File 'lib/stripe/api_requestor.rb', line 1068 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
1076 1077 1078 1079 1080 1081 1082 |
# File 'lib/stripe/api_requestor.rb', line 1076 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
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 |
# File 'lib/stripe/api_requestor.rb', line 1088 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 |