Project

graphwerk

0.04
No release in over 3 years
Visualise dependencies between your application and it's Packwerk packages using Graphviz.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 12.3.3
~> 3.0
>= 0

Runtime

 Project Readme

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',
     package_todo_color: 'yellow',
     graph: { overlap: true },
     node: { fillcolor: '#000000' },
     edges: { len: '3.0' }
    }
).build
graph.output(svg: 'packwerk.svg')