mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-09 00:03:05 -04:00
Prefer reading /proc/version over calling uname.
This will be way faster on linux systems than shelling out to uname. Also add hostname from Socket.gethostname since that information is provided by `uname -a` but not /proc/version.
This commit is contained in:
parent
ede362588c
commit
d046a876f9
@ -1,9 +1,11 @@
|
||||
# Stripe Ruby bindings
|
||||
# API spec at https://stripe.com/docs/api
|
||||
require 'cgi'
|
||||
require 'set'
|
||||
require 'openssl'
|
||||
require 'rest_client'
|
||||
require 'set'
|
||||
require 'socket'
|
||||
|
||||
require 'rest-client'
|
||||
require 'json'
|
||||
|
||||
# Version
|
||||
@ -159,15 +161,22 @@ module Stripe
|
||||
:lang_version => lang_version,
|
||||
:platform => RUBY_PLATFORM,
|
||||
:publisher => 'stripe',
|
||||
:uname => @uname
|
||||
:uname => @uname,
|
||||
:hostname => Socket.gethostname,
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
def self.get_uname
|
||||
`uname -a 2>/dev/null`.strip if RUBY_PLATFORM =~ /linux|darwin/i
|
||||
rescue Errno::ENOMEM => ex # couldn't create subprocess
|
||||
"uname lookup failed"
|
||||
begin
|
||||
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"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.uri_encode(params)
|
||||
|
Loading…
x
Reference in New Issue
Block a user