Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samuelgiles/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.
https://github.com/samuelgiles/graphwerk
clean-architecture dependencies graphviz packages packwerk rails ruby ruby-on-rails sorbet
Last synced: about 11 hours ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/samuelgiles/graphwerk
- Owner: samuelgiles
- License: mit
- Created: 2020-10-08T13:12:44.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-17T03:07:39.000Z (5 months ago)
- Last Synced: 2024-12-26T15:09:49.964Z (8 days ago)
- Topics: clean-architecture, dependencies, graphviz, packages, packwerk, rails, ruby, ruby-on-rails, sorbet
- Language: Ruby
- Homepage:
- Size: 856 KB
- Stars: 53
- Watchers: 6
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
![graphwerk-logo](https://user-images.githubusercontent.com/2643026/95463568-cfaada80-0970-11eb-8305-aea01a0d77a9.png)
# Graphwerk [![Gem Version](https://badge.fury.io/rb/graphwerk.svg)](https://badge.fury.io/rb/graphwerk) [![Continuous Integration](https://github.com/bellroy/graphwerk/actions/workflows/ci.yml/badge.svg)](https://github.com/bellroy/graphwerk/actions/workflows/ci.yml)
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](https://github.com/Shopify/packwerk) and [Graphviz](https://github.com/glejeune/Ruby-Graphviz).
Here's an example application package dependency diagram:
![example](https://user-images.githubusercontent.com/2643026/97689408-6ca1f480-1a93-11eb-9999-22e79791b300.png)
## 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`.
```bash
bundle exec rake graphwerk:update
```More advance usage is possible by passing a [`Packwerk::PackageSet`](https://github.com/Shopify/packwerk/blob/main/lib/packwerk/package_set.rb) directly to `Graphwerk::Builders::Graph` and calling `#build` returning a `Graphviz` instance:
```ruby
graph = Graphwerk::Builders::Graph.new(
Packwerk::PackageSet.load_all_from(".")
).build
graph.output(svg: 'packwerk.svg')
```All [Graphviz layouts](https://graphviz.org/documentation/#layout-manual-pages) are supported and options for the graph, nodes and edges can be set via an optional `options` argument:
```ruby
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')
```