mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-05 00:02:50 -04:00
Also handle uname on jruby, windows, bsd.
And add RUBY_ENGINE to the reported information if it exists.
This commit is contained in:
parent
d046a876f9
commit
743c4e3ee1
@ -2,6 +2,7 @@
|
||||
# API spec at https://stripe.com/docs/api
|
||||
require 'cgi'
|
||||
require 'openssl'
|
||||
require 'rbconfig'
|
||||
require 'set'
|
||||
require 'socket'
|
||||
|
||||
@ -160,6 +161,7 @@ module Stripe
|
||||
:lang => 'ruby',
|
||||
:lang_version => lang_version,
|
||||
:platform => RUBY_PLATFORM,
|
||||
:engine => defined?(RUBY_ENGINE) ? RUBY_ENGINE : '',
|
||||
:publisher => 'stripe',
|
||||
:uname => @uname,
|
||||
:hostname => Socket.gethostname,
|
||||
@ -168,17 +170,33 @@ module Stripe
|
||||
end
|
||||
|
||||
def self.get_uname
|
||||
begin
|
||||
if File.exist?('/proc/version')
|
||||
File.read('/proc/version').strip
|
||||
rescue SystemCallError
|
||||
begin
|
||||
`uname -a 2>/dev/null`.strip if RUBY_PLATFORM =~ /linux|darwin/i
|
||||
rescue Errno::ENOMEM # couldn't create subprocess
|
||||
"uname lookup failed"
|
||||
else
|
||||
case RbConfig::CONFIG['host_os']
|
||||
when /linux|darwin|bsd|sunos|solaris|cygwin/i
|
||||
_uname_uname
|
||||
when /mswin|mingw/i
|
||||
_uname_ver
|
||||
else
|
||||
"unknown platform"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self._uname_uname
|
||||
(`uname -a 2>/dev/null` || '').strip
|
||||
rescue Errno::ENOMEM
|
||||
"uname lookup failed"
|
||||
end
|
||||
|
||||
def self._uname_ver
|
||||
(`ver` || '').strip
|
||||
rescue Errno::ENOMEM
|
||||
"uname lookup failed"
|
||||
end
|
||||
|
||||
|
||||
def self.uri_encode(params)
|
||||
Util.flatten_params(params).
|
||||
map { |k,v| "#{k}=#{Util.url_encode(v)}" }.join('&')
|
||||
|
Loading…
x
Reference in New Issue
Block a user