https://github.com/ktonon/code_node
Create Class and Module graphs for Ruby projects
https://github.com/ktonon/code_node
Last synced: 4 months ago
JSON representation
Create Class and Module graphs for Ruby projects
- Host: GitHub
- URL: https://github.com/ktonon/code_node
- Owner: ktonon
- License: mit
- Created: 2012-11-18T03:22:37.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-12-30T04:19:06.000Z (over 12 years ago)
- Last Synced: 2024-03-14T22:24:13.876Z (over 1 year ago)
- Language: Ruby
- Size: 2.04 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
code_node
=========[](https://travis-ci.org/ktonon/code_node)
[](https://gemnasium.com/ktonon/code_node)
[](https://codeclimate.com/github/ktonon/code_node)Create graphs of the classes and modules in a Ruby project
Get it
------Install the [gem][] from a terminal
```bash
$ 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
```bash
$ cog gen new -p code_node my_graph
Created cog/generators/my_graph.rb
```The generator will look something like this
```ruby
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](http://ktonon.github.com/code_node/CodeNode/DSL/GraphDefiner.html) for help) and then run that generator
```bash
$ 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```bash
$ dot -T png -o lib/my_graph.png lib/my_graph.dot
```[cog]:https://github.com/ktonon/cog
[gem]:https://rubygems.org/gems/code_node
[Graphviz]:http://www.graphviz.org
[Get Graphviz]:http://www.graphviz.org/Download.php