Project

code_node

0.0
No commit activity in last 3 years
No release in over 3 years
Create Class and Module graphs for Ruby projects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

code_node

Build Status Dependency Status Code Climate

Create graphs of the classes and modules in a Ruby project

Get it

Install the gem from a terminal

$ gem install code_node

Use it

code_node is a cog plugin. To use it, you'll need to:

  • run cog init from a terminal in the root of your project
  • edit the Cogfile and change project_path to the root of your Ruby source.

Now that your project is ready, create a code_node graph generator like this

$ cog gen new -p code_node my_graph
Created cog/generators/my_graph.rb

The generator will look something like this

CodeNode.graph 'my_graph' do |g|

  # Ignore nodes with no relations to other nodes
  g.ignore &:island?

  # Uncomment and change the value to ignore a specific node
  # g.ignore 'Foo::Bar::Car'
  
  # Uncomment to ignore nodes named ClassMethods
  # g.ignore /::ClassMethods$/

  # Uncomment and change the value to ignore all nodes descending
  # from a specific node
  # g.ignore {|node| node.inherits_from? 'Foo::Bar::Car'}
  
  # Apply styles common to all classes
  g.style :shape => 'ellipse', &:class?

  # Apply styles common to all nodes
  g.style :shape => 'box', &:module?
end

Customize the graph generator (see GraphDefiner for help) and then run that generator

$ cog gen
1st pass: find nodes
2nd pass: find relations
Pruning nodes
Created lib/my_graph.dot

A Graphviz dot file is created. Get Graphviz and use the dot command line tool to turn your generated my_graph.dot file into an image. For example

$ dot -T png -o lib/my_graph.png lib/my_graph.dot