File Coverage

blib/lib/App/Midgen/Role/Output/MB.pm
Criterion Covered Total %
statement 15 52 28.8
branch 0 12 0.0
condition 0 7 0.0
subroutine 5 8 62.5
pod 3 3 100.0
total 23 82 28.0


line stmt bran cond sub pod time code
1             package App::Midgen::Role::Output::MB;
2              
3 2     2   889 use constant {NONE => q{},};
  2         4  
  2         102  
4              
5 2     2   6 use Moo::Role;
  2         4  
  2         9  
6              
7             # Load time and dependencies negate execution time
8             # use namespace::clean -except => 'meta';
9              
10             our $VERSION = '0.33_05';
11             $VERSION = eval $VERSION; ## no critic
12              
13 2     2   3378 use English qw( -no_match_vars ); # Avoids reg-ex performance penalty
  2         4  
  2         7  
14             local $OUTPUT_AUTOFLUSH = 1;
15              
16 2     2   602 use File::Spec;
  2         3  
  2         702  
17              
18             #######
19             # header_mb
20             #######
21             sub header_mb {
22 0     0 1   my $self = shift;
23 0   0       my $package_name = shift || NONE;
24              
25 0 0         if ($package_name ne NONE) {
26 0           $package_name =~ s{::}{-}g;
27 0           print "\n" . '"dist_name" => "' . $package_name . q{",} . "\n";
28             }
29              
30 0           return;
31             }
32             #######
33             # body_mb
34             #######
35             sub body_mb {
36 0     0 1   my $self = shift;
37 0           my $title = shift;
38 0   0       my $required_ref = shift || return;
39              
40 0 0         return if not %{$required_ref};
  0            
41              
42 0           print "\n";
43              
44 0           my $pm_length = 0;
45 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
46 0 0         if (length $module_name > $pm_length) {
47 0           $pm_length = length $module_name;
48             }
49             }
50              
51 0           $title =~ s/^RuntimeRequires/requires/;
52 0           $title =~ s/^TestRequires/test_requires/;
53              
54 0           print q{"} . lc $title . '" => {' . "\n";
55              
56 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
57              
58             next
59             if $title eq 'test_requires'
60 0 0 0       && $required_ref->{$module_name} =~ m/mcpan/;
61              
62 0           my $sq_key = "\"$module_name\"";
63             printf "\t %-*s => \"%s\",\n", $pm_length + 2, $sq_key,
64 0           $required_ref->{$module_name};
65              
66             }
67 0           print "},\n";
68              
69 0           return;
70             }
71             #######
72             # footer_mb
73             #######
74             sub footer_mb {
75 0     0 1   my $self = shift;
76              
77 0 0         if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'script')) {
    0          
78 0           print "\n" . '"script_files" => [' . "\n";
79 0           print "\t\"script/...\"\n";
80 0           print "],\n";
81             }
82             elsif (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'bin')) {
83 0           print "\n" . '"script_files" => [' . "\n";
84 0           print "\t\"bin/...\"\n";
85 0           print "],\n";
86             }
87              
88 0           print "\n";
89              
90 0           return;
91             }
92              
93 2     2   8 no Moo;
  2         2  
  2         9  
94              
95             1;
96              
97             __END__
98              
99             =pod
100              
101             =encoding UTF-8
102              
103             =head1 NAME
104              
105             App::Midgen::Role::Output::MB - Output Format - Module::Build,
106             used by L<App::Midgen>
107              
108             =head1 VERSION
109              
110             version: 0.33_05
111              
112             =head1 DESCRIPTION
113              
114             The output format uses colour to add visualization of module version number
115             types, be that mcpan, dual-life or added distribution.
116              
117             =head1 METHODS
118              
119             =over 4
120              
121             =item * header_mb
122              
123             =item * body_mb
124              
125             =item * footer_mb
126              
127             =back
128              
129             =head1 DEPENDENCIES
130              
131             L<Term::ANSIColor>
132              
133             =head1 SEE ALSO
134              
135             L<App::Midgen>
136              
137             =head1 AUTHOR
138              
139             See L<App::Midgen>
140              
141             =head2 CONTRIBUTORS
142              
143             See L<App::Midgen>
144              
145             =head1 COPYRIGHT
146              
147             See L<App::Midgen>
148              
149             =head1 LICENSE
150              
151             This library is free software; you can redistribute it and/or modify
152             it under the same terms as Perl itself.
153              
154             =cut
155