Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Created October 21, 2013 16:01
Show Gist options
  • Select an option

  • Save invisiblefunnel/7086349 to your computer and use it in GitHub Desktop.

Select an option

Save invisiblefunnel/7086349 to your computer and use it in GitHub Desktop.
require 'pp'
require 'set'
def class_count
puts ObjectSpace.each_object(Class){}
end
SKIPS = %w(debug gauntlet_rubygems monitor dl profile).map{ |l| "#{l}.rb" }
def require_all_the_things
$LOAD_PATH.each do |dir|
Dir[File.join(dir, '*.rb')].each do |path|
lib = File.basename(path)
next if SKIPS.include?(lib)
begin
require lib
rescue LoadError
end
end
end
end
class_count
require_all_the_things
class_count
world = Hash.new { |h,k| h[k] = Set.new }
ObjectSpace.each_object(Class) do |klass|
world[klass.superclass] << klass
end
world.each { |k, v| world[k] = v.to_a }
pp world.to_a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment