File Coverage

blib/lib/App/Midgen/Role/Output/MIdsl.pm
Criterion Covered Total %
statement 18 71 25.3
branch 0 26 0.0
condition 0 11 0.0
subroutine 6 9 66.6
pod 3 3 100.0
total 27 120 22.5


line stmt bran cond sub pod time code
1             package App::Midgen::Role::Output::MIdsl;
2              
3 2     2   899 use constant {NONE => q{},};
  2         2  
  2         102  
4              
5 2     2   7 use Moo::Role;
  2         3  
  2         8  
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   3406 use English qw( -no_match_vars ); # Avoids reg-ex performance penalty
  2         4  
  2         10  
15             local $OUTPUT_AUTOFLUSH = 1;
16              
17 2     2   573 use Term::ANSIColor qw( :constants colored );
  2         4  
  2         411  
18 2     2   9 use File::Spec;
  2         2  
  2         1066  
19              
20             #######
21             # header_dsl
22             #######
23             sub header_dsl {
24 0     0 1   my $self = shift;
25 0   0       my $package_name = shift || NONE; # was shift // NONE -> defined $a ? $a : $b
26 0   0       my $mi_ver = shift || NONE; # defined shift ? shift : NONE - don't work as per perl5100delta.pod
27              
28 0           $package_name =~ s{::}{/}g;
29 0           print "\nuse strict;\n";
30 0           print "use warnings;\n";
31 0           print "use inc::Module::Install::DSL "
32             . colored($mi_ver, 'yellow') . ";\n";
33 0 0         if ($package_name ne NONE) {
34 0           print "all_from lib/$package_name.pm\n";
35 0           print "requires_from lib/$package_name.pm\n";
36             }
37              
38 0           print BRIGHT_BLACK . "license perl" . CLEAR . "\n";
39              
40 0           return;
41             }
42             #######
43             # body_dsl
44             #######
45             sub body_dsl {
46 0     0 1   my $self = shift;
47 0           my $title = shift;
48 0   0       my $required_ref = shift || return;
49              
50 0 0         return if not %{$required_ref};
  0            
51              
52 0 0         print 'perl_version ' . $App::Midgen::Min_Version . "\n"
53             if $title eq 'RuntimeRequires';
54 0           print "\n";
55              
56 0           my $pm_length = 0;
57 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
58 0 0         if (length $module_name > $pm_length) {
59 0           $pm_length = length $module_name;
60             }
61             }
62              
63 0           $title =~ s/^RuntimeRequires/requires/;
64 0           $title =~ s/^TestRequires/test_requires/;
65              
66 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
67              
68             next
69             if $title eq 'test_requires'
70 0 0 0       && $required_ref->{$module_name} =~ m/mcpan/;
71              
72 0 0         if ($module_name =~ /^Win32/sxm) {
    0          
    0          
73             printf "%s %-*s %s %s\n", $title, $pm_length, $module_name,
74 0           $required_ref->{$module_name}, colored('if win32', 'bright_green');
75             }
76             elsif ($module_name =~ /XS/sxm) {
77             printf "%s %-*s %s %s\n", $title, $pm_length, $module_name,
78 0           $required_ref->{$module_name}, colored('if can_xs', 'bright_blue');
79             }
80             elsif ($module_name eq 'MRO::Compat') {
81             printf "%s %-*s %s %s\n", $title, $pm_length, $module_name,
82 0           $required_ref->{$module_name},
83             colored('if $] < 5.009005', 'bright_blue');
84             }
85             else {
86             printf "%s %-*s %s\n", lc $title, $pm_length, $module_name,
87 0           $required_ref->{$module_name};
88             }
89             }
90 0           return;
91             }
92             #######
93             # footer_dsl
94             #######
95             sub footer_dsl {
96 0     0 1   my $self = shift;
97 0   0       my $package_name = shift || NONE;
98 0           $package_name =~ s{::}{-}g;
99              
100 0 0         if ($self->verbose > 0) {
101 0           print BRIGHT_BLACK "\n";
102 0           print "homepage https://github.com/.../$package_name\n";
103 0           print "bugtracker https://github.com/.../$package_name/issues\n";
104 0           print "repository git://github.com/.../$package_name.git\n";
105 0           print CLEAR "\n";
106             }
107 0 0         if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'share')) {
108 0           print "install_share\n\n";
109             }
110              
111 0 0         if (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'script')) {
    0          
112 0           print "install_script ...\n\n";
113             }
114             elsif (defined -d File::Spec->catdir($App::Midgen::Working_Dir, 'bin')) {
115 0           print "install_script bin/...\n\n";
116             }
117              
118 0           my @no_index = $self->no_index;
119 0 0         if (@no_index) {
120 0           print "no_index directory qw{ @no_index }\n\n";
121             }
122              
123 0           return;
124             }
125              
126 2     2   9 no Moo;
  2         4  
  2         9  
127              
128             1;
129              
130             __END__
131              
132             =pod
133              
134             =encoding UTF-8
135              
136             =head1 NAME
137              
138             App::Midgen::Role::Output::MIdsl Output Format - Module::Install::DSL,
139             used by L<App::Midgen>
140              
141             =head1 VERSION
142              
143             version: 0.33_05
144              
145             =head1 DESCRIPTION
146              
147             The output format uses colour to add visualization of module version number
148             types, be that mcpan, dual-life or added distribution.
149              
150             =head1 METHODS
151              
152             =over 4
153              
154             =item * header_dsl
155              
156             =item * body_dsl
157              
158             =item * footer_dsl
159              
160             =back
161              
162             =head1 DEPENDENCIES
163              
164             L<Term::ANSIColor>
165              
166             =head1 SEE ALSO
167              
168             L<App::Midgen>
169              
170             =head1 AUTHOR
171              
172             See L<App::Midgen>
173              
174             =head2 CONTRIBUTORS
175              
176             See L<App::Midgen>
177              
178             =head1 COPYRIGHT
179              
180             See L<App::Midgen>
181              
182             =head1 LICENSE
183              
184             This library is free software; you can redistribute it and/or modify
185             it under the same terms as Perl itself.
186              
187             =cut