No release in over 3 years
Provides a simple DSL for generating Mikado Graphs using GraphViz.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Mikado Graph Generator Gem Version Build Status Maintainability

Welcome to a DSL for creating Mikado Graphs using GraphViz.

Installation

Add this line to your application's Gemfile:

gem "mikado_graph"

And then execute:

$ bundle

Or install it yourself as:

$ gem install mikado_graph

Prerequisites

Ensure you have GraphViz installed. On macOS you can install it using Homebrew with the following command:

brew install graphviz

Usage

You can use this gem's DSL in the following way to create a Mikado Graph generator definition file:

require "mikado_graph"

MikadoGraph::Generator.define do
  state("State A").with_prerequisites do
    state("State B").with_prerequisites do
      state("State D")
      state("State E")
    end
    state("State C").with_prerequisites do
      state("State F")
      state("State G")
    end
  end
end.generate("png", "img/example_usage_vertical.png") # generate takes GraphViz format and output path

You can also use the shorthand with_prereqs instead of with_prerequisites for defining prerequisite dependencies between states.

Save this file to example_usage_vertical.rb and then you can then execute this file in the terminal using:

ruby example_usage_vertical.rb

This will utilize GraphViz to create this PNG output of the above Mikado Graph generator definition:

Example Usage Vertical

NOTE: If you don't provide any parameters to generate, it'll default to a dot output in the STDOUT.

If you want to instead do a horizontal orientation of your graph, simply provide the direction flag to #generate like so:

generate(direction: :horizontal)

Here is an example usage:

require "mikado_graph"

MikadoGraph::Generator.define do
  state("State A").with_prerequisites do
    state("State B").with_prerequisites do
      state("State D")
      state("State E")
    end
    state("State C").with_prerequisites do
      state("State F")
      state("State G")
    end
  end
end.generate(format: "png", path: "img/example_usage_horizontal.png", direction: :horizontal)

This will generate this graph:

Example Usage Horizontal

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Use direnv to speed development.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/snasirca/mikado-graph-generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.