Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

aasm_statecharts

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aasm_statecharts


Version published
Maintainers
1
Created
Source

aasm_statecharts

aasm_statecharts is a utility for generating UML statechart diagrams from state machines defined using AASM. Unlike other state diagram generators, it can express extended finite state machine concepts such as guards and entry actions.

Installation and Invokation

You can install aasm_statecharts from RubyGems using gem install aasm_statecharts, or add the aasm_statecharts gem to your Gemfile and run Bundler to install it.

If you have installed aasm_statecharts via gem, you can invoke it using the command aasm_statecharts; otherwise, if you have used Bundler without generating binstubs, you can invoke it with the command bundle exec aasm_statecharts. The following assumes that it has been installed via gem for simplicity.

Example

Considuer following model, which is assumed to be stored in app/models/claim.rb:

class Claim < ActiveRecord::Base
  belongs_to :user
  validates :title, presence: true
  validates :description, presence: true

  include AASM

  aasm do
    state :unsubmitted, initial: true
    state :submitted, exit: [:cancel_deadline, :close_ticket]
    state :resolved, final: true

    event :submit do
      transitions from: :unsubmitted, to: :submitted,
                  guard: :accepting_claims?,
                  on_transition: :notify_submitted
    end
    event :return do
      transitions from: :submitted, to: :unsubmitted
    end
    event :accept do
      transitions from: :submitted, to: :resolved
    end
  end
  
  def accepting_claims?
  end
  
  def cancel_deadline
  end

  def close_ticket
  end
  
  def notify_submitted
  end
end

If we invoke aasm_statecharts claim, then the following diagram will be written to ./doc/claim.png:

Claim Statechart

Usage

For more advanced usage information, see aasm_statecharts --help:

Usage: aasm_statecharts [options] <model> [models ...]
    -a, --all                        Render all models using AASM
    -d, --directory directory        Output to a specific directory (default: ./doc)
    -t, --file-type type             Output in the specified format (default: png),
which must be one of the following: bmp, canon, dot, xdot, cmap, dia, eps, fig, gd,
gd2, gif, gtk, hpgl, ico, imap, cmapx, imap_np, cmapx_np, ismap, jpeg, jpg, jpe, mif,
mp, pcl, pdf, pic, plain, plain-ext, png, ps, ps2, svg, svgz, tga, tiff, tif, vml,
vmlz, vrml, vtx, wbmp, xlib, none.

FAQs

Package last updated on 04 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc