lib/Meta/Grapher/Moose/Role/HasOutput.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 38 CC 2 SCAR 11.5
CC
2
Cov
0%
_build_format
6.0
has_output
2.0
BEGIN
2.0
CRAP 3.1
1 package Meta::Grapher::Moose::Role::HasOutput;
2  
3 use strict;
4 use warnings;
5 use namespace::autoclean;
6  
7 our $VERSION = '1.03';
8  
9 use Moose::Role;
10  
11 has output => (
12 is => 'ro',
13 isa => 'Str',
14 );
15  
16 has format => (
17 is => 'ro',
18 isa => 'Str',
19 lazy => 1,
20 builder => '_build_format',
21 );
22  
23 sub has_output { defined $_[0]->output }
24  
25 sub _build_format {
26 my $self = shift;
27  
28 # attempt to use the file extension as the format, if there is a usable
29 # extension that is...
30 my $ext;
31 unless ( $self->has_output
32 && ( ($ext) = $self->output =~ /[.]([^.]+)\z/ ) ) {
33 return 'src';
34 }
35  
36 return $ext;
37 }
38  
39 1;
40  
41 # ABSTRACT: Role with standard way to specify Meta::Grapher::Moose output
42  
43 __END__