#!/usr/bin/env ruby -S rake

require 'rake/deveiate'

NODE_STATE_GRAPH = Rake::DevEiate::PROJECT_DIR + 'node-state-machine.dot'


Rake::DevEiate.setup( 'arborist' ) do |project|
	project.publish_to = 'deveiate:/usr/local/www/public/code'
end


file NODE_STATE_GRAPH

desc "Generate a graph of the node status state machine."
task NODE_STATE_GRAPH do |task|
	$LOAD_PATH.unshift( LIBDIR.to_s )

	require 'state_machines'
	require 'state_machines/graphviz'
	require 'arborist/node'

	state_machine = Arborist::Node.state_machine
	name = File.basename( NODE_STATE_GRAPH, '.dot' )
	puts "Writing status state machine diagram to #{NODE_STATE_GRAPH}"
	graph = state_machine.draw( path: BASEDIR.to_s, name: name, format: 'dot' )
	# graph.output
end
task :diagrams => [ NODE_STATE_GRAPH ]

CLEAN.include( NODE_STATE_GRAPH.to_s )