Constree
Recursively show the structure of constants in a module
Installation
Add this line to your application's Gemfile:
gem 'constree'
And then execute:
$ bundle
Or install it yourself as:
$ gem install constree
Example: find distinct module/class under a module
[1] pry(main)> require "concurrent-ruby"
=> true
[2] pry(main)> require "constree"
=> true
[3] pry(main)> Constree.uniq(Concurrent)
=> #<Set:
{Concurrent,
Concurrent::AtomicDirectUpdate,
Concurrent::AtomicNumericCompareAndSetWrapper,
Concurrent::CyclicBarrier,
Concurrent::Synchronization::Volatile::ClassMethods,
Concurrent::Promises,
Concurrent::Promises::FactoryMethods,
Concurrent::Promises::FactoryMethods::Configuration,
Concurrent::Promises::Resolvable,
Concurrent::Promises::InternalStates::State,
Concurrent::Promises::InternalStates::Pending,
Concurrent::Promises::InternalStates::Reserved,
Concurrent::Promises::InternalStates::ResolvedWithResult,
Concurrent::Promises::InternalStates::Fulfilled,
Concurrent::Promises::InternalStates::FulfilledArray,
...
Example: output tree to html
File.open('somewhere', 'w') do |f|
f.puts Constree.html_of SomeConstant
end
Example: check constants in concurrent-ruby, in irb console
irb(main):001:0> require "concurrent-ruby"
=> true
irb(main):002:0> Constree.p Concurrent
Concurrent {:kla=>Module}