Sha256: aa2cb133227c0112e892c926341f6b89fc1fb73bcb86ef3899c9ec6ead1bd5db

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

namespace :state_machine do
  desc 'Draws a set of state machines using GraphViz. Target files to load with FILE=x,y,z; Machine class with CLASS=x,y,z; Font name with FONT=x; Image format with FORMAT=x; Orientation with ORIENTATION=x'
  task :draw do
    # Load the library
    $:.unshift(File.dirname(__FILE__) + '/..')
    require 'state_machine'
    
    # Build drawing options
    options = {}
    options[:file] = ENV['FILE'] if ENV['FILE']
    options[:path] = ENV['TARGET'] if ENV['TARGET']
    options[:format] = ENV['FORMAT'] if ENV['FORMAT']
    options[:font] = ENV['FONT'] if ENV['FONT']
    options[:orientation] = ENV['ORIENTATION'] if ENV['ORIENTATION']
    
    StateMachine::Machine.draw(ENV['CLASS'], options)
  end
  
  namespace :draw do
    desc 'Draws a set of state machines using GraphViz for a Ruby on Rails application.  Target class with CLASS=x,y,z; Font name with FONT=x; Image format with FORMAT=x; Orientation with ORIENTATION=x'
    task :rails => [:environment, 'state_machine:draw']
    
    desc 'Draws a set of state machines using GraphViz for a Merb application.  Target class with CLASS=x,y,z; Font name with FONT=x; Image format with FORMAT=x; Orientation with ORIENTATION=x'
    task :merb => [:merb_env] do
      # Fix ruby-graphviz being incompatible with Merb's process title
      $0 = 'rake'
      Rake::Task['state_machine:draw'].invoke
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
state_machine-0.8.1 lib/tasks/state_machine.rb