| 1 | 1 | ▶ | use 5.14.0; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | package Dist::Zilla::Plugin::MapMetro::MakeGraphViz; | ||
| 5 | |||
| 6 | # ABSTRACT: Automatically creates a GraphViz2 visualisation of a Metro::Map map | ||
| 7 | our $VERSION = '0.1104'; | ||
| 8 | |||
| 9 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use Path::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | ▶ | use MooseX::AttributeShortcuts; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 1 | ▶ | use Types::Standard qw/HashRef ArrayRef Str Maybe/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 1 | ▶ | use Map::Metro::Shim; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 0 | ▶ | use GraphViz2; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 16 | use Dist::Zilla::Plugin::MapMetro::MakeGraphViz::Map; | ||
| 17 | |||
| 18 | with qw/ | ||
| 19 | Dist::Zilla::Role::Plugin | ||
| 20 | Dist::Zilla::Role::BeforeBuild | ||
| 21 | /; | ||
| 22 | |||
| 23 | sub before_build { | ||
| 24 | my $self = shift; | ||
| 25 | |||
| 26 | if(!$ENV{'MMVIZ'} && !$ENV{'MMVIZDEBUG'}) { | ||
| 27 | $self->log('Set either MMVIZ or MMVIZDEBUG to a true value to run this.'); | ||
| 28 | return; | ||
| 29 | } | ||
| 30 | |||
| 31 | my @maps = sort { $a cmp $b } map { $_->basename(qr/\.pm/) } path(qw/lib Map Metro Plugin Map/)->children(qr/\.pm/); | ||
| 32 | return if !scalar @maps; | ||
| 33 | |||
| 34 | for my $mapname (@maps) { | ||
| 35 | state $counter = 0; | ||
| 36 | ++$counter; | ||
| 37 | $self->log("Works on $mapname [$counter/@{[ scalar @maps ]}]"); | ||
| 38 | my $map = Dist::Zilla::Plugin::MapMetro::MakeGraphViz::Map->new(map => $mapname); | ||
| 39 | |||
| 40 | if($map->has_generated_file) { | ||
| 41 | $self->log(" Saved in @{[ $map->generated_file ]}"); | ||
| 42 | } | ||
| 43 | else { | ||
| 44 | $self->log("! Did not create graphviz"); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | 1; | ||
| 50 | |||
| 51 | __END__ | ||