Top Level Namespace

Defined Under Namespace

Modules: Nuri, Sfp, SfpLang, Trollop

Instance Method Summary collapse

Instance Method Details

#dateObject

lib/trollop.rb – trollop command-line processing library

Author

William Morgan (mailto: [email protected])

Copyright

Copyright 2007 William Morgan

License

the same terms as ruby itself



6
# File 'lib/sfp/trollop.rb', line 6

require 'date'

#mainObject



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/sfp/sfw2graph.rb', line 131

def main
	if ARGV.length < 1
		puts "Usage: 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 = Nuri::Planner::Graph::partial2dot(json)
	when 'sequential'
		dot = Nuri::Planner::Graph::sequential2dot(json)
	when 'stage'
		dot = Nuri::Planner::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