File: as_boxart_html

package info (click to toggle)
libgraph-easy-perl 0.71-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,284 kB
  • sloc: perl: 24,909; makefile: 2
file content (44 lines) | stat: -rwxr-xr-x 1,096 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl -w

#############################################################################
# This example is a bit outdated, please use the new bin/graph-easy script -
# which is after "make install" available on any command line in your system.

# Convert an input file containing a Graph::Easy description to
# ASCII art using "box drawing" Unicode characters.

# Example usage:
#  examples/as_boxart t/in/2nodes.txt
#  echo "[ A ] -> [ B ]" | examples/as_boxart

BEGIN { $|++; }

use lib 'lib';
use Graph::Easy::Parser;

my $file = shift;
my $id = shift || '';
my $debug = shift;

my $parser = Graph::Easy::Parser->new( debug => $debug );

if (!defined $file)
  {
  $file = \*STDIN;
  binmode STDIN, ':utf8' or die ("binmode STDIN, ':utf8' failed: $!");
  }
my $graph = $parser->from_file( $file );

die ($parser->error()) unless defined $graph;

$graph->id($id);
$graph->timeout(360);
$graph->layout();

warn($graph->error()) if $graph->error();

binmode STDOUT, ':utf8' or die ("binmode STDOUT, ':utf8' failed: $!");

#print $graph->as_boxart();
print $graph->as_boxart_html_file();