Sha256: 27e38001816f14722388f1f5bd06ca5a78c36203b304dda574d6b8e6f33082a1

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

namespace :state_machine do
  desc 'Draws state machines using GraphViz (options: CLASS=User,Vehicle; FILE=user.rb,vehicle.rb [not required in Rails / Merb]; FONT=Arial; FORMAT=png; ORIENTATION=portrait; HUMAN_NAMES=true'
  task :draw do
    # 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']
    options[:human_names] = ENV['HUMAN_NAMES'] == 'true' if ENV['HUMAN_NAMES']
    
    if defined?(Rails)
      puts "Files are automatically loaded in Rails; ignoring FILE option" if options.delete(:file)
      Rake::Task['environment'].invoke
    elsif defined?(Merb)
      puts "Files are automatically loaded in Merb; ignoring FILE option" if options.delete(:file)
      Rake::Task['merb_env'].invoke
      
      # Fix ruby-graphviz being incompatible with Merb's process title
      $0 = 'rake'
    else
      # Load the library
      $:.unshift(File.dirname(__FILE__) + '/..')
      require 'state_machine'
    end
    
    StateMachine::Machine.draw(ENV['CLASS'], options)
  end
end

Version data entries

10 entries across 10 versions & 8 rubygems

Version Path
state_machine_updated_for_ruby_3_2-2.0.0 lib/tasks/state_machine.rb
telvue_state_machine-1.2.3 lib/tasks/state_machine.rb
telvue_state_machine-1.2.2 lib/tasks/state_machine.rb
state_machine_deuxito-0.0.1 lib/tasks/state_machine.rb
telvue_state_machine-1.2.1 lib/tasks/state_machine.rb
cm-state_machine-1.2.0.1 lib/tasks/state_machine.rb
culturecode-state_machine-1.2.1 lib/tasks/state_machine.rb
automat-1.2.0 lib/tasks/state_machine.rb
glebtv_state_machine-1.3.0 lib/tasks/state_machine.rb
state_machine-1.2.0 lib/tasks/state_machine.rb