| 1 | #!/usr/bin/env perl | ||||||||||
| 2 | # Renders examples/demo.json to examples/demo.svg, the picture the README | ||||||||||
| 3 | # shows: | ||||||||||
| 4 | # | ||||||||||
| 5 | # perl -Ilib examples/demo.pl | ||||||||||
| 6 | # | ||||||||||
| 7 | # and the same Combs in the packed layout, the status monitor, to | ||||||||||
| 8 | # examples/monitor.svg. | ||||||||||
| 9 | # | ||||||||||
| 10 | # All files are found next to this script, so it runs from any directory. | ||||||||||
| 11 | # With a path as argument demo.svg is written there instead and monitor.svg | ||||||||||
| 12 | # next to it; that is how t/50-demo.t checks that the committed pictures are | ||||||||||
| 13 | # current. | ||||||||||
| 14 | # | ||||||||||
| 15 | # demo.png and monitor.png are those two pictures in light mode, 1400 pixels | ||||||||||
| 16 | # wide, for the README and the documentation: examples/png.sh makes them with | ||||||||||
| 17 | # a headless Chromium. No test checks them, so run it after the pictures | ||||||||||
| 18 | # changed. | ||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | ▶ | use JSON::MaybeXS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 1 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 1 | ▶ | use Kubernetes::Comb::SVG; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 1 | my $here = path(__FILE__)->absolute->parent; | |||||||||
| 27 | 1 | ▶ | my $out = @ARGV ? path( $ARGV[0] ) : $here->child('demo.svg'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | |||||||||||
| 29 | 1 | my $combs = JSON::MaybeXS->new( utf8 => 1 )->decode( $here->child('demo.json')->slurp_raw ); | |||||||||
| 30 | |||||||||||
| 31 | 1 | $out->spew_raw( Kubernetes::Comb::SVG->new( | |||||||||
| 32 | combs => $combs, | ||||||||||
| 33 | title => 'Shop', | ||||||||||
| 34 | group_label => 'app.kubernetes.io/part-of', | ||||||||||
| 35 | columns => 6 | ||||||||||
| 36 | )->render ); | ||||||||||
| 37 | |||||||||||
| 38 | 1 | $out->sibling('monitor.svg')->spew_raw( Kubernetes::Comb::SVG->new( | |||||||||
| 39 | combs => $combs, | ||||||||||
| 40 | title => 'Shop', | ||||||||||
| 41 | layout => 'packed', | ||||||||||
| 42 | blink => ['Error'] | ||||||||||
| 43 | )->render ); | ||||||||||