Created
October 21, 2013 16:01
-
-
Save invisiblefunnel/7086349 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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