File Coverage

blib/lib/App/Midgen/Role/Output/EUMM.pm
Criterion Covered Total %
statement 18 115 15.6
branch 0 26 0.0
condition 0 9 0.0
subroutine 6 10 60.0
pod 3 3 100.0
total 27 163 16.5


line stmt bran cond sub pod time code
1             package App::Midgen::Role::Output::EUMM;
2              
3             use constant {
4 2         191 BLANK => q{ },
5             NONE => q{},
6             THREE => q{ },
7             SIX => q{ },
8             NINE => q{ },
9             TWELVE => q{ },
10 2     2   914 };
  2         3  
11              
12 2     2   8 use Moo::Role;
  2         2  
  2         10  
13             requires qw( verbose );
14              
15             # Load time and dependencies negate execution time
16             # use namespace::clean -except => 'meta';
17              
18             our $VERSION = '0.33_05';
19             $VERSION = eval $VERSION; ## no critic
20              
21 2     2   3435 use English qw( -no_match_vars ); # Avoids reg-ex performance penalty
  2         3  
  2         9  
22             local $OUTPUT_AUTOFLUSH = 1;
23              
24 2     2   638 use Term::ANSIColor qw( :constants colored );
  2         3  
  2         467  
25 2     2   10 use File::Spec;
  2         1  
  2         1904  
26              
27             #######
28             # header_eumm
29             #######
30             sub header_eumm {
31 0     0 1   my $self = shift;
32 0   0       my $package_name = shift || NONE;
33              
34 0 0         if ($package_name ne NONE) {
35              
36 0           print "\nuse strict;\n";
37 0           print "use warnings;\n";
38 0           print "use ExtUtils::MakeMaker 6.68;\n\n";
39              
40 0           print "WriteMakefile(\n";
41 0           print THREE. "'NAME' => '$package_name',\n";
42 0           $package_name =~ s{::}{/}g;
43 0           print THREE. "'VERSION_FROM' => 'lib/$package_name.pm',\n";
44 0           print THREE. "'ABSTRACT_FROM' => 'lib/$package_name.pm',\n";
45              
46 0           print BRIGHT_BLACK;
47 0           print THREE. "'AUTHOR' => '...',\n";
48 0           print THREE. "'LICENSE' => 'perl',\n";
49 0           print CLEAR;
50             ## 6.64 f***** RT#85406
51 0           print THREE. "'BUILD_REQUIRES' => {\n";
52 0           print SIX. "'ExtUtils::MakeMaker' => '6.68',\n";
53 0           print THREE. "},\n";
54 0           print THREE. "'CONFIGURE_REQUIRES' => {\n";
55 0           print SIX. "'ExtUtils::MakeMaker' => '6.68',\n";
56 0           print THREE. "},\n";
57             }
58              
59 0           return;
60             }
61             #######
62             # body_eumm
63             #######
64             sub body_eumm {
65 0     0 1   my $self = shift;
66 0           my $title = shift;
67 0   0       my $required_ref = shift || return;
68              
69 0 0         return if not %{$required_ref};
  0            
70              
71 0           my $pm_length = 0;
72 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
73 0 0         if (length $module_name > $pm_length) {
74 0           $pm_length = length $module_name;
75             }
76             }
77              
78 0 0         print THREE. "'MIN_PERL_VERSION' => '$App::Midgen::Min_Version',\n"
79             if $title eq 'RuntimeRequires';
80              
81             # return if not %{$required_ref} and $title =~ m{(?:requires)\z};
82              
83 0 0         if ($title eq 'RuntimeRequires') {
    0          
    0          
84 0           print THREE. "'PREREQ_PM' => {\n";
85             }
86             elsif ($title eq 'TestRequires') {
87 0           print THREE. "'TEST_REQUIRES' => {\n";
88             }
89             elsif ($title eq 'recommends') {
90 0           $self->_recommends($required_ref);
91 0           return;
92             }
93              
94 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
95              
96             next
97             if $title eq 'TestRequires'
98 0 0 0       && $required_ref->{$module_name} =~ m/mcpan/;
99              
100 0           my $sq_key = q{'} . $module_name . q{'};
101             printf SIX. " %-*s => '%s',\n", $pm_length + 2, $sq_key,
102 0           $required_ref->{$module_name};
103             }
104 0           print THREE. "},\n";
105              
106 0           return;
107             }
108              
109             sub _recommends {
110 0     0     my $self = shift;
111 0           my $required_ref = shift;
112              
113 0           my $pm_length = 0;
114 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
115 0 0         if (length $module_name > $pm_length) {
116 0           $pm_length = length $module_name;
117             }
118             }
119 0           print THREE. "'META_MERGE' => {\n";
120 0           print SIX. "'meta-spec' => { 'version' => '2' },\n";
121 0 0         return if not %{$required_ref};
  0            
122 0           print SIX. "'prereqs' => {\n";
123 0           print NINE. "'test' => {\n";
124 0           print TWELVE. "'suggests' => {\n";
125 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
126              
127 0           my $sq_key = q{'} . $module_name . q{'};
128             printf "%-15s %-*s => '%s',\n", BLANK, $pm_length + 2, $sq_key,
129 0           $required_ref->{$module_name};
130             }
131 0           print TWELVE. "}\n";
132 0           print NINE. "}\n";
133 0           print SIX. "},\n";
134              
135             }
136              
137              
138             #######
139             # footer_eumm
140             #######
141             sub footer_eumm {
142 0     0 1   my $self = shift;
143 0   0       my $package_name = shift || NONE;
144 0           $package_name =~ s{::}{-}g;
145              
146 0 0         if ($self->verbose > 0) {
147 0           print BRIGHT_BLACK;
148              
149 0           print SIX. "'resources' => {\n";
150              
151 0           print NINE. "'bugtracker' => {\n";
152 0           print TWELVE. "'web' => 'https://github.com/.../$package_name/issues',\n";
153 0           print NINE. "},\n";
154              
155 0           print NINE. "'homepage' => 'https://github.com/.../$package_name',\n";
156              
157 0           print NINE. "'repository' => {\n";
158 0           print TWELVE. "'type' => 'git',\n";
159 0           print TWELVE. "'url' => 'git://github.com/.../$package_name.git',\n";
160 0           print TWELVE. "'web' => 'https://github.com/.../$package_name',\n";
161 0           print NINE. "},\n";
162 0           print SIX. "},\n";
163              
164 0           print SIX. "'x_contributors' => [\n";
165 0           print NINE. "'brian d foy (ADOPTME) <brian.d.foy\@gmail.com>',\n";
166 0           print NINE. "'Fred Bloggs <fred\@bloggs.org>',\n";
167 0           print SIX. "],\n";
168              
169 0           print CLEAR;
170 0           print THREE. "},\n";
171              
172             }
173              
174 0 0         if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'script')) {
    0          
175 0           print THREE. "'EXE_FILES' => [ (\n";
176 0           print SIX. "'script/...'\n";
177 0           print THREE. ") ],\n";
178             }
179             elsif (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'bin')) {
180 0           print THREE. "'EXE_FILES' => [qw(\n";
181 0           print SIX. "bin/...\n";
182 0           print THREE. ")],\n";
183             }
184              
185 0           print ")\n\n";
186              
187 0           return;
188             }
189              
190 2     2   12 no Moo;
  2         2  
  2         14  
191              
192             1;
193              
194             __END__
195              
196             =pod
197              
198             =encoding UTF-8
199              
200             =head1 NAME
201              
202             App::Midgen::Role::Output::EUMM - Output Format - ExtUtils::MakeMaker,
203             used by L<App::Midgen>
204              
205             =head1 VERSION
206              
207             version: 0.33_05
208              
209             =head1 DESCRIPTION
210              
211             The output format uses colour to add visualization of module version number
212             types, be that mcpan, dual-life or added distribution.
213              
214             =head1 METHODS
215              
216             =over 4
217              
218             =item * header_eumm
219              
220             =item * body_eumm
221              
222             =item * footer_eumm
223              
224             =back
225              
226             =head1 DEPENDENCIES
227              
228             L<Term::ANSIColor>
229              
230             =head1 SEE ALSO
231              
232             L<App::Midgen>
233              
234             =head1 AUTHOR
235              
236             See L<App::Midgen>
237              
238             =head2 CONTRIBUTORS
239              
240             See L<App::Midgen>
241              
242             =head1 COPYRIGHT
243              
244             See L<App::Midgen>
245              
246             =head1 LICENSE
247              
248             This library is free software; you can redistribute it and/or modify
249             it under the same terms as Perl itself.
250              
251             =cut
252