No commit activity in last 3 years
No release in over 3 years
A library that provides additional introspection capabilities for Ruby programs (allows various queries on methods and classes)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
~> 0.10
~> 10.4

Runtime

 Project Readme

SystemNavigation

Description

SystemNavigation is a Ruby library that provides additional introspection capabilities for Ruby programs. The library defines a number of useful methods that allow querying:

  • methods for instance, class or global variables
  • methods for literals such as numbers, strings, symbols, etc.
  • methods for finding a specific string (method source search)
  • classes and modules that implement given methods
  • classes and modules that send messages
  • all classes and modules in gems
  • and many more...

For the complete list of features please read the documentation or read the tests. All interaction with the library is done via the SystemNavigation class and its class methods. The description of the methods can be found in these places:

Examples (full list in the documentation)

#all_accesses

Retrieve all methods that access instance variables in the given class/module including its ancestors and children.

module M
  def increment
    @num + 1
  end
end

class A
  include M

  attr_reader :num

  def initialize(num)
    @num = num
  end
end

sn = SystemNavigation.default

sn.all_accesses(to: :@num, from: A)
#=> [#<UnboundMethod: A#num>, #<UnboundMethod: A(M)#increment>, #<UnboundMethod: A#initialize>]
#all_implementors_of

Find all classes and modules that implement the given message.

sn = SystemNavigation.default

sn.all_implementors_of(:puts)
#=> [ARGF.class, IO, Kernel, ..., YARD::Logger]
#all_calls

Find all methods in Bundler that invoke the 1 literal.

require 'bundler'

sn = SystemNavigation.default

sn.all_calls(on: 1, gem: 'bundler')
#=> [#<UnboundMethod: #<Class:Bundler>#with_clean_env>, #<UnboundMethod: #<Class:Bundler>#eval_gemspec>]
#all_objects

Retrieve all objects defined in the system.

sn = SystemNavigation.default

sn.all_objects.map(&:class).uniq.count #=> 158

And many more...

Installation

All you need is to install the gem.

gem install system_navigation

Limitations

Supports only CRuby.

  • CRuby 2.2.2 and higher

Credits

  • Inspired by Smalltalk

License

The project uses Zlib License. See LICENCE.txt file for more information.