Sha256: 4694485df4c3b1c9c755708aa61408ed35a6eee5d5a77fc4828100f29c040362

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 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__) + '/lib')
    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
mattscilipoti-state_machine-0.8.0.1 lib/state_machine/tasks.rb