File Coverage

blib/lib/App/Midgen/Role/Output/Dist.pm
Criterion Covered Total %
statement 18 82 21.9
branch 0 30 0.0
condition 0 11 0.0
subroutine 6 9 66.6
pod 3 3 100.0
total 27 135 20.0


line stmt bran cond sub pod time code
1             package App::Midgen::Role::Output::Dist;
2              
3 2     2   955 use constant {NONE => q{},};
  2         2  
  2         117  
4              
5 2     2   8 use Moo::Role;
  2         1  
  2         12  
6             requires qw( no_index verbose );
7              
8             # Load time and dependencies negate execution time
9             # use namespace::clean -except => 'meta';
10              
11             our $VERSION = '0.33_05';
12             $VERSION = eval $VERSION; ## no critic
13              
14 2     2   3628 use English qw( -no_match_vars ); # Avoids reg-ex performance penalty
  2         4  
  2         9  
15             local $OUTPUT_AUTOFLUSH = 1;
16              
17 2     2   572 use Term::ANSIColor qw( :constants colored );
  2         2  
  2         395  
18 2     2   9 use File::Spec;
  2         3  
  2         1101  
19              
20             #######
21             # header_dist
22             #######
23             sub header_dist {
24 0     0 1   my $self = shift;
25 0   0       my $package_name = shift || NONE;
26              
27 0 0         if ($package_name ne NONE) {
28 0           $package_name =~ s{::}{-}g;
29 0           print "\nname = $package_name\n";
30 0           $package_name =~ tr{-}{/};
31 0           print "main_module = lib/$package_name.pm\n";
32             }
33              
34 0           return;
35             }
36              
37             #######
38             # body_dist
39             #######
40             sub body_dist {
41 0     0 1   my $self = shift;
42 0   0       my $title = shift || return;
43 0   0       my $required_ref = shift || return;
44              
45 0 0         return if not %{$required_ref};
  0            
46              
47 0           print "\n";
48              
49 0           my $pm_length = 0;
50 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
51 0 0         if (length $module_name > $pm_length) {
52 0           $pm_length = length $module_name;
53             }
54             }
55              
56 0 0         if ($title eq 'RuntimeRequires') {
    0          
    0          
    0          
    0          
57 0           print "[Prereqs]\n";
58 0           printf "%-*s = %s\n", $pm_length, 'perl', $App::Midgen::Min_Version;
59             }
60             elsif ($title eq 'RuntimeRecommends') {
61 0           print "[Prereqs / RuntimeRecommends]\n";
62             }
63             elsif ($title eq 'TestRequires') {
64 0           print "[Prereqs / TestRequires]\n";
65             }
66             elsif ($title eq 'TestSuggests') {
67 0           print "[Prereqs / TestSuggests]\n";
68             }
69             elsif ($title eq 'DevelopRequires') {
70 0           print "[Prereqs / DevelopRequires]\n";
71             }
72              
73 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
74              
75             next
76             if $title eq 'TestRequires'
77 0 0 0       && $required_ref->{$module_name} =~ m/mcpan/;
78              
79             printf "%-*s = %s\n", $pm_length, $module_name,
80 0           $required_ref->{$module_name};
81             }
82              
83 0           return;
84             }
85              
86             #######
87             # footer_dist
88             #######
89             sub footer_dist {
90 0     0 1   my $self = shift;
91 0   0       my $package_name = shift || NONE;
92 0           $package_name =~ s{::}{-}g;
93              
94 0           print "\n";
95 0           my @no_index = $self->no_index;
96 0 0         if (@no_index) {
97 0           print "[MetaNoIndex]\n";
98 0           foreach (@no_index) {
99 0 0         print "directory = $_\n" if $_ ne 'inc';
100             }
101 0           print "\n";
102             }
103              
104 0 0         if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'share')) {
105 0           print "[ShareDir]\n";
106 0           print "dir = share\n\n";
107             }
108              
109 0 0         if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'script')) {
    0          
110 0           print "[ExecDir]\n";
111 0           print "dir = script\n\n";
112             }
113             elsif (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'bin')) {
114 0           print "[ExecDir]\n";
115 0           print "dir = bin\n\n";
116             }
117              
118 0 0         if ($self->verbose > 0) {
119 0           print BRIGHT_BLACK;
120 0           print "[MetaResources]\n";
121 0           print "homepage = https://github.com/.../$package_name\n";
122 0           print "bugtracker.web = https://github.com/.../$package_name/issues\n";
123 0           print "bugtracker.mailto = ...\n";
124 0           print "repository.url = git://github.com/.../$package_name.git\n";
125 0           print "repository.type = git\n";
126 0           print "repository.web = https://github.com/.../$package_name";
127 0           print "\n";
128              
129 0           print "[Meta::Contributors]\n";
130 0           print "contributor = brian d foy (ADOPTME) <brian.d.foy\@gmail.com>\n";
131 0           print "contributor = Fred Bloggs <fred\@bloggs.org>\n";
132 0           print CLEAR "\n";
133             }
134              
135 0           return;
136             }
137              
138              
139 2     2   9 no Moo;
  2         9  
  2         9  
140              
141             1;
142              
143             __END__
144              
145             =pod
146              
147             =encoding UTF-8
148              
149             =head1 NAME
150              
151             App::Midgen::Role::Output::Dist - Output Format - dist.ini,
152             used by L<App::Midgen>
153              
154             =head1 VERSION
155              
156             version: 0.33_05
157              
158             =head1 DESCRIPTION
159              
160             The output format uses colour to add visualization of module version number
161             types, be that mcpan, dual-life or added distribution.
162              
163             =head1 METHODS
164              
165             =over 4
166              
167             =item * header_dist
168              
169             =item * body_dist
170              
171             =item * footer_dist
172              
173             =back
174              
175             =head1 DEPENDENCIES
176              
177             L<Term::ANSIColor>
178              
179             =head1 SEE ALSO
180              
181             L<App::Midgen>
182              
183             =head1 AUTHOR
184              
185             See L<App::Midgen>
186              
187             =head2 CONTRIBUTORS
188              
189             See L<App::Midgen>
190              
191             =head1 COPYRIGHT
192              
193             See L<App::Midgen>
194              
195             =head1 LICENSE
196              
197             This library is free software; you can redistribute it and/or modify
198             it under the same terms as Perl itself.
199              
200             =cut
201