Sha256: 42a0533c202521c4bd42c46fb32fd26851663fae3e3187681c47a0dd6da2a87e

Contents?: true

Size: 955 Bytes

Versions: 5

Compression:

Stored size: 955 Bytes

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'json'

module Sfp
end

require File.expand_path('../../lib/sfplanner/graph.rb', __FILE__)

def main
	if ARGV.length < 1
		puts "Convert SFP plan to an image graph with Graphviz (dot).\n\nUsage: sfw2dot.rb <input-file> [output-file]\n\n"
		exit
	end
	
	fp = open(ARGV[0], "rb")
	json = JSON.parse(fp.read)
	fp.close
	
	dot = ""
	case json["type"]
	when 'partial-order', 'parallel'
		dot = Sfp::Graph::partial2dot(json)
	when 'sequential'
		dot = Sfp::Graph::sequential2dot(json)
	when 'stage'
		dot = Sfp::Graph::stage2dot(json)
	else
		throw Exception, "Unrecognised type of workflow: #{json['type']}"
	end
	
	outfile = "/tmp/#{ARGV[0]}.dot"
	fp = open(outfile, "w");
	fp.write(dot)
	fp.close
	
	cmd = 'dot -Tpng -o';
	if ARGV.length > 1
		cmd += "#{ARGV[1]} #{outfile}"
	else
		cmd += ARGV[0].sub(/\.[a-zA-Z]*/,'') + ".png < #{outfile}"
	end
	system(cmd)
	File.delete(outfile)
end

main if __FILE__ == $0

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sfplanner-0.2.4 bin/sfw2graph
sfplanner-0.2.3 bin/sfw2graph
sfplanner-0.2.1 bin/sfw2graph
sfplanner-0.1.5 bin/sfw2graph
sfplanner-0.1.4 bin/sfw2graph