Skip to content

Instantly share code, notes, and snippets.

@FooBarWidget
Created May 17, 2011 17:26
Show Gist options
  • Save FooBarWidget/976908 to your computer and use it in GitHub Desktop.
Save FooBarWidget/976908 to your computer and use it in GitHub Desktop.
class WhatsGoingOn
def initialize(io)
@io = io
end
def analyze
require 'rbconfig'
require 'rubygems'
print('Ruby exe', ruby_exe)
print('Ruby version', RUBY_VERSION)
print('Ruby platform', RUBY_PLATFORM)
print('Ruby engine', ruby_engine)
print('RubyGems version', Gem::VERSION)
print('uname -a', `uname -a`.strip)
print('UID', Process.uid)
print('GID', Process.gid)
print_env('PATH')
print_env('LD_LIBRARY_PATH')
print_env('RUBYOPT')
print_hash('Config', RbConfig::CONFIG)
print_hash('Environment', ENV)
print_list('$LOAD_PATH', $LOAD_PATH)
print_list('$LOADED_FEATURES', $LOADED_FEATURES)
return self
end
def flush
@io.flush
end
private
def print(name, value)
@io.printf "%-18s %s\n", name, value.nil? ? "nil" : value
end
def print_env(env)
print(env, ENV[env])
end
def print_list(name, list)
@io.puts("#{name} (#{list.size} items)")
list.each do |item|
@io.puts " #{item}"
end
end
def print_hash(name, hash)
@io.puts("#{name} (#{hash.size} items)")
hash.sort.each do |key, value|
@io.printf " %-20s => %s\n", key.inspect, value.inspect
end
end
def ruby_exe
return RbConfig::CONFIG['bindir'] + '/' +
RbConfig::CONFIG['RUBY_INSTALL_NAME'] +
RbConfig::CONFIG['EXEEXT']
end
def ruby_engine
if defined?(RUBY_ENGINE)
return RUBY_ENGINE
else
return "ruby"
end
end
end
require 'stringio'
WhatsGoingOn.new(STDERR).analyze.flush
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment