mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-10 00:02:25 -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
|
# Stripe Ruby bindings
|
||||||
# API spec at https://stripe.com/docs/api
|
# API spec at https://stripe.com/docs/api
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
require 'set'
|
|
||||||
require 'openssl'
|
require 'openssl'
|
||||||
require 'rest_client'
|
require 'set'
|
||||||
|
require 'socket'
|
||||||
|
|
||||||
|
require 'rest-client'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
@ -159,16 +161,23 @@ module Stripe
|
|||||||
:lang_version => lang_version,
|
:lang_version => lang_version,
|
||||||
:platform => RUBY_PLATFORM,
|
:platform => RUBY_PLATFORM,
|
||||||
:publisher => 'stripe',
|
:publisher => 'stripe',
|
||||||
:uname => @uname
|
:uname => @uname,
|
||||||
|
:hostname => Socket.gethostname,
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_uname
|
def self.get_uname
|
||||||
|
begin
|
||||||
|
File.read('/proc/version').strip
|
||||||
|
rescue SystemCallError
|
||||||
|
begin
|
||||||
`uname -a 2>/dev/null`.strip if RUBY_PLATFORM =~ /linux|darwin/i
|
`uname -a 2>/dev/null`.strip if RUBY_PLATFORM =~ /linux|darwin/i
|
||||||
rescue Errno::ENOMEM => ex # couldn't create subprocess
|
rescue Errno::ENOMEM # couldn't create subprocess
|
||||||
"uname lookup failed"
|
"uname lookup failed"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.uri_encode(params)
|
def self.uri_encode(params)
|
||||||
Util.flatten_params(params).
|
Util.flatten_params(params).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user