/graphwerk

Graphwerk is a small Ruby gem that can generate a diagram of dependencies between packages within an application that's using Packwerk to enforce boundaries.

Primary LanguageRubyMIT LicenseMIT

graphwerk-logo

Graphwerk Gem Version Continuous Integration

Graphwerk is a small Ruby gem that can generate a diagram of dependencies between packages within an application that's using Packwerk to enforce boundaries.

The gem builds on top of Packwerk and Graphviz.

Here's an example application package dependency diagram:

example

Install

Add this line to your application's Gemfile and run bundle install:

gem 'graphwerk', group: %i[development test]

Usage

For Rails applications a Railtie automatically loads a rake task that makes it easy to generate a diagram for your root package and its dependencies. The diagram will be placed at the root of your application as packwerk.png.

bundle exec rake graphwerk:update

More advance usage is possible by passing a Packwerk::PackageSet directly to Graphwerk::Builders::Graph and calling #build returning a Graphviz instance:

graph = Graphwerk::Builders::Graph.new(
   Packwerk::PackageSet.load_all_from(".")
).build
graph.output(svg: 'packwerk.svg')

All Graphviz layouts are supported and options for the graph, nodes and edges can be set via an optional options argument:

graph = Graphwerk::Builders::Graph.new(
   Packwerk::PackageSet.load_all_from("."),
   options: {
     layout: Graphwerk::Layout::Twopi,
     deprecated_references_color: 'yellow',
     graph: { overlap: true },
     node: { fillcolor: '#000000' },
     edges: { len: '3.0' }
    }
).build
graph.output(svg: 'packwerk.svg')