File Coverage

blib/lib/App/Midgen/Role/Output/Infile.pm
Criterion Covered Total %
statement 24 59 40.6
branch 0 14 0.0
condition 0 3 0.0
subroutine 8 13 61.5
pod 3 3 100.0
total 35 92 38.0


line stmt bran cond sub pod time code
1             package App::Midgen::Role::Output::Infile;
2              
3             use constant {
4 2         154 BLANK => q{ },
5             NONE => q{},
6             THREE => 3,
7             EIGHT => 8,
8             NINE => 9,
9             TEN => 10
10 2     2   897 };
  2         2  
11              
12 2     2   8 use Moo::Role;
  2         2  
  2         10  
13             requires qw( core dual_life debug );
14 2     2   3417 use Try::Tiny;
  2         2  
  2         155  
15              
16             # Load time and dependencies negate execution time
17             # use namespace::clean -except => 'meta';
18              
19             our $VERSION = '0.33_05';
20             $VERSION = eval $VERSION; ## no critic
21              
22 2     2   8 use English qw( -no_match_vars );
  2         3  
  2         8  
23             local $OUTPUT_AUTOFLUSH = 1;
24              
25 2     2   605 use Term::ANSIColor qw( :constants colored );
  2         2  
  2         423  
26 2     2   10 use Data::Printer {caller_info => 1,};
  2         3  
  2         18  
27 2     2   1607 use File::Spec;
  2         2  
  2         872  
28              
29             #######
30             # header_infile
31             #######
32             sub header_infile {
33 0     0 1   my $self = shift;
34              
35 0           print qq{\n};
36              
37 0           return;
38             }
39             #######
40             # body_infile
41             #######
42             sub body_infile {
43 0     0 1   my $self = shift;
44              
45 0           return;
46             }
47             #######
48             # footer_infile
49             #######
50             sub footer_infile {
51 0     0 1   my $self = shift;
52              
53 0 0         p $self->{modules} if $self->debug;
54              
55             # Let's work out our padding
56 0           my $pm_length = 0;
57 0           my $dir_length = 0;
58 0           foreach my $module_name (sort keys %{$self->{modules}}) {
  0            
59              
60 0 0         if (length $module_name > $pm_length) {
61 0           $pm_length = length $module_name;
62             }
63             try {
64 0     0     foreach my $foundin (sort @{$self->{modules}{$module_name}{infiles}}) {
  0            
65 0 0         if (length $foundin->[0] > $dir_length) {
66 0           $dir_length = length $foundin->[0];
67             }
68             }
69 0           };
70              
71             }
72              
73 0           print " "
74             . "-" x $pm_length
75             . "-" x EIGHT
76             . "-" x TEN
77             . "-" x $dir_length
78             . "-" x TEN . "\n";
79              
80              
81 0           printf " | %-*s | %-*s | %-*s | %-*s |\n", $pm_length, 'Module', EIGHT,
82             'Version ', EIGHT, 'Installed', $dir_length, 'Found in';
83 0           print " "
84             . "-" x $pm_length
85             . "-" x EIGHT
86             . "-" x TEN
87             . "-" x $dir_length
88             . "-" x TEN . "\n";
89              
90              
91 0           foreach my $module_name (sort keys %{$self->{modules}}) {
  0            
92              
93             # honnor options dual-life and core module display
94 0 0         if ($self->core) {
    0          
95              
96             # do nothing
97             }
98             elsif ($self->dual_life) {
99             next
100             if ($self->{modules}{$module_name}{corelist}
101 0 0 0       and not $self->{modules}{$module_name}{dual_life});
102             }
103             else {
104 0 0         next if $self->{modules}{$module_name}{corelist};
105             }
106              
107             try {
108 0     0     foreach my $foundin (sort @{$self->{modules}{$module_name}{infiles}}) {
  0            
109 0           my $dir_relative = $foundin->[0];
110 0           $dir_relative =~ s{^/}{};
111 0           printf " | %-*s | %-*s | %-*s | %-*s |\n", $pm_length, $module_name,
112             EIGHT, $foundin->[1], NINE, $self->in_local_lib($module_name),
113             $dir_length, $dir_relative,;
114             }
115 0           };
116             }
117              
118 0           print " "
119             . "-" x $pm_length
120             . "-" x EIGHT
121             . "-" x TEN
122             . "-" x $dir_length
123             . "-" x TEN . "\n";
124              
125 0           print qq{\n};
126              
127 0           return;
128             }
129              
130 2     2   10 no Moo;
  2         2  
  2         8  
131              
132             1;
133              
134             __END__
135              
136             =pod
137              
138             =encoding UTF-8
139              
140             =head1 NAME
141              
142             App::Midgen::Role::Output::Infile - Modules and files they were found in,
143             used by L<App::Midgen>
144              
145             =head1 VERSION
146              
147             version: 0.33_05
148              
149             =head1 DESCRIPTION
150              
151             This output format list modules found against the files they were Included in.
152              
153             =head1 METHODS
154              
155             =over 4
156              
157             =item * header_infile
158              
159             =item * body_infile
160              
161             =item * footer_infile
162              
163             =back
164              
165             =head1 DEPENDENCIES
166              
167             L<Term::ANSIColor>
168              
169             =head1 SEE ALSO
170              
171             L<App::Midgen>
172              
173             =head1 AUTHOR
174              
175             See L<App::Midgen>
176              
177             =head2 CONTRIBUTORS
178              
179             See L<App::Midgen>
180              
181             =head1 COPYRIGHT
182              
183             See L<App::Midgen>
184              
185             =head1 LICENSE
186              
187             This library is free software; you can redistribute it and/or modify
188             it under the same terms as Perl itself.
189              
190             =cut