DepAn now supports Ruby dependency visualization

DepAn now supports Ruby dependency visualization

DepAn support for Ruby applications

A recent set of git commits has added Ruby (DepanRuby) plugin support to the base DepAn product. Interested users should be able to access these capabilities in any recent build of DepAn.

The current Ruby support is focused on exploiting DepAn’s dependency visualization capabilities to analyze Ruby projects. Several different kinds of elements and relations are supported:


  • Classes
  • ClassMethods
  • InstanceMethods
  • SingletonMethods


  • ExtendsType
  • ClassMember
  • InstanceMember
  • SingletonMember
  • StaticCall

Like DepAn’s other dependency models, a Ruby dependency graph’s nodes and edges are obtained by introspection on the Ruby application. Unlike other DepAn analysis components, these dependency graphs are build through an independent application.

The discovery of Ruby dependencies is handled by an separate command line Ruby application.  The use of Ruby for dependency extraction provides natural access to Ruby’s own introspection system.  For many classes, their structure and elements are readily available as object methods.  The call dependencies are naturally deduced by inspecting the RubyVM’s InstructionSequence objects.

Extracting Ruby Dependencies

Ruby dependencies can be obtained via the ruby_export application available from Pnambic Computing.  This command line Ruby application uses introspection to discover structural and run-time dependencies for Ruby programs.

The ruby_export application provides basic dependency information about Ruby programs. Class, superclass and method definitions are included.  However, module structure is not included. Some analysis of Ruby bytecode is performed, allowing the discovery of directly dependent classes and class method class.  Symbolic interpretation is limited to constant resolution.  This allows some “class method” calls to be detected and added as dependencies.

The ruby_export application uses the standard Ruby optparse gem for command line parsing. Details are available with the --help switch. Normal use has the following pattern:

ruby -Ilib lib/ruby_export.rb -o Rake_20160406a.dgi -c Rake rake

This examples outputs an analysis of the Rake application into a Rake_201000406a.dgi file. A log of activity analysis is written to STDERR. This can be redirected with the -l option.

The -c indicates the classes the use a starting point, -o indicates the output file to generate, and unspecified options (e.g. rake) provide a list of required components to include in the analysis. Both the -c and required components can be repeated as necessary.

Teams that require more precise information about their Ruby dependencies are invited to improved the analysis application as appropriate.  A rich symbolic evaluation engine could help resolve many of the call/send dependencies in Ruby’s duck-typing method dispatch.

Leave a comment