Generate Mermaid diagrams from AASM state machines.
Add this line to your application's Gemfile:
gem 'aasm_mermaid'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install aasm_mermaid
for an example AASM:
class TestAASMParentClass
include AASM
aasm do
state :sleeping, initial: true
state :running, :cleaning
event :run do
transitions from: :sleeping, to: :running
end
event :clean do
transitions from: :running, to: :cleaning
end
event :sleep do
transitions from: %i[running cleaning], to: :sleeping
end
event :procrastinate do
transitions to: :sleeping
end
end
end
generate the diagram with:
AASMMermaid.generate_diagram_for(aasm: TestAASMParentClass.aasm)
result (rendered by github):
stateDiagram-v2
sleeping --> running : run
running --> cleaning : clean
running --> sleeping : sleep
cleaning --> sleeping : sleep
sleeping --> sleeping : procrastinate
running --> sleeping : procrastinate
cleaning --> sleeping : procrastinate
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.
To install this gem onto your local machine, run bundle exec rake install
.
Bug reports and pull requests are welcome on GitHub at https://github.com/iiwo/aasm_mermaid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the AASMMermaid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.