| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::Midgen::Role::Output; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 1084 | use Moo::Role; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 13 |  | 
| 4 |  |  |  |  |  |  | with qw( | 
| 5 |  |  |  |  |  |  | App::Midgen::Role::Output::CPANfile | 
| 6 |  |  |  |  |  |  | App::Midgen::Role::Output::Dist | 
| 7 |  |  |  |  |  |  | App::Midgen::Role::Output::EUMM | 
| 8 |  |  |  |  |  |  | App::Midgen::Role::Output::Infile | 
| 9 |  |  |  |  |  |  | App::Midgen::Role::Output::MB | 
| 10 |  |  |  |  |  |  | App::Midgen::Role::Output::METAjson | 
| 11 |  |  |  |  |  |  | App::Midgen::Role::Output::MIdsl | 
| 12 |  |  |  |  |  |  | App::Midgen::Role::Output::MI | 
| 13 |  |  |  |  |  |  | ); | 
| 14 |  |  |  |  |  |  | requires qw( format distribution_name get_module_version verbose ); | 
| 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 |  | 3916 | use English qw( -no_match_vars );    # Avoids reg-ex performance penalty | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 14 |  | 
| 23 |  |  |  |  |  |  | local $OUTPUT_AUTOFLUSH = 1; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 2 |  |  | 2 |  | 706 | use Try::Tiny; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 1131 |  | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | ####### | 
| 29 |  |  |  |  |  |  | # output_header | 
| 30 |  |  |  |  |  |  | ####### | 
| 31 |  |  |  |  |  |  | sub output_header { | 
| 32 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 0 | 0 |  |  |  |  | if ($self->format eq 'dsl') { | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 35 | 0 |  |  |  |  |  | $self->header_dsl($self->distribution_name, | 
| 36 |  |  |  |  |  |  | $self->get_module_version('inc::Module::Install::DSL')); | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  | elsif ($self->format eq 'mi') { | 
| 39 | 0 |  |  |  |  |  | $self->header_mi($self->distribution_name, | 
| 40 |  |  |  |  |  |  | $self->get_module_version('inc::Module::Install')); | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  | elsif ($self->format eq 'dist') { | 
| 43 | 0 |  |  |  |  |  | $self->header_dist($self->distribution_name); | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  | elsif ($self->format eq 'cpanfile') { | 
| 46 | 0 | 0 |  |  |  |  | $self->header_cpanfile($self->distribution_name, | 
| 47 |  |  |  |  |  |  | $self->get_module_version('inc::Module::Install')) | 
| 48 |  |  |  |  |  |  | if not $self->quiet; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  | elsif ($self->format eq 'eumm') { | 
| 51 | 0 |  |  |  |  |  | $self->header_eumm($self->distribution_name); | 
| 52 |  |  |  |  |  |  | } | 
| 53 |  |  |  |  |  |  | elsif ($self->format eq 'mb') { | 
| 54 | 0 |  |  |  |  |  | $self->header_mb($self->distribution_name); | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  | elsif ($self->format eq 'metajson') { | 
| 57 | 0 |  |  |  |  |  | $self->header_metajson($self->distribution_name); | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  | elsif ($self->format eq 'infile') { | 
| 60 | 0 |  |  |  |  |  | $self->header_infile($self->distribution_name); | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 0 |  |  |  |  |  | return; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | ####### | 
| 67 |  |  |  |  |  |  | # output_main_body | 
| 68 |  |  |  |  |  |  | ####### | 
| 69 |  |  |  |  |  |  | sub output_main_body { | 
| 70 | 0 |  |  | 0 | 1 |  | my $self         = shift; | 
| 71 | 0 |  | 0 |  |  |  | my $title        = shift || 'title missing'; | 
| 72 | 0 |  |  |  |  |  | my $required_ref = shift; | 
| 73 |  |  |  |  |  |  |  | 
| 74 | 0 | 0 |  |  |  |  | if ($self->format eq 'dsl') { | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 75 | 0 |  |  |  |  |  | $self->body_dsl($title, $required_ref); | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  | elsif ($self->format eq 'mi') { | 
| 78 | 0 |  |  |  |  |  | $self->body_mi($title, $required_ref); | 
| 79 |  |  |  |  |  |  | } | 
| 80 |  |  |  |  |  |  | elsif ($self->format eq 'dist') { | 
| 81 | 0 |  |  |  |  |  | $self->body_dist($title, $required_ref); | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  | elsif ($self->format eq 'cpanfile') { | 
| 84 | 0 |  |  |  |  |  | $self->body_cpanfile($title, $required_ref); | 
| 85 |  |  |  |  |  |  | } | 
| 86 |  |  |  |  |  |  | elsif ($self->format eq 'eumm') { | 
| 87 | 0 |  |  |  |  |  | $self->body_eumm($title, $required_ref); | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  | elsif ($self->format eq 'mb') { | 
| 90 | 0 |  |  |  |  |  | $self->body_mb($title, $required_ref); | 
| 91 |  |  |  |  |  |  | } | 
| 92 |  |  |  |  |  |  | elsif ($self->format eq 'metajson') { | 
| 93 | 0 |  |  |  |  |  | $self->body_metajson($title, $required_ref); | 
| 94 |  |  |  |  |  |  | } | 
| 95 |  |  |  |  |  |  | elsif ($self->format eq 'infile') { | 
| 96 | 0 |  |  |  |  |  | $self->body_infile($title, $required_ref); | 
| 97 |  |  |  |  |  |  | } | 
| 98 |  |  |  |  |  |  |  | 
| 99 | 0 |  |  |  |  |  | return; | 
| 100 |  |  |  |  |  |  | } | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | ####### | 
| 103 |  |  |  |  |  |  | # output_footer | 
| 104 |  |  |  |  |  |  | ####### | 
| 105 |  |  |  |  |  |  | sub output_footer { | 
| 106 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 107 |  |  |  |  |  |  |  | 
| 108 | 0 | 0 |  |  |  |  | if ($self->format eq 'dsl') { | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 109 | 0 |  |  |  |  |  | $self->footer_dsl($self->distribution_name); | 
| 110 |  |  |  |  |  |  | } | 
| 111 |  |  |  |  |  |  | elsif ($self->format eq 'mi') { | 
| 112 | 0 |  |  |  |  |  | $self->footer_mi($self->distribution_name); | 
| 113 |  |  |  |  |  |  | } | 
| 114 |  |  |  |  |  |  | elsif ($self->format eq 'dist') { | 
| 115 | 0 |  |  |  |  |  | $self->footer_dist($self->distribution_name); | 
| 116 |  |  |  |  |  |  | } | 
| 117 |  |  |  |  |  |  | elsif ($self->format eq 'cpanfile') { | 
| 118 | 0 |  |  |  |  |  | $self->footer_cpanfile($self->distribution_name); | 
| 119 |  |  |  |  |  |  | } | 
| 120 |  |  |  |  |  |  | elsif ($self->format eq 'eumm') { | 
| 121 | 0 |  |  |  |  |  | $self->footer_eumm($self->distribution_name); | 
| 122 |  |  |  |  |  |  | } | 
| 123 |  |  |  |  |  |  | elsif ($self->format eq 'mb') { | 
| 124 | 0 |  |  |  |  |  | $self->footer_mb($self->distribution_name); | 
| 125 |  |  |  |  |  |  | } | 
| 126 |  |  |  |  |  |  | elsif ($self->format eq 'metajson') { | 
| 127 | 0 |  |  |  |  |  | $self->footer_metajson($self->distribution_name); | 
| 128 |  |  |  |  |  |  | } | 
| 129 |  |  |  |  |  |  | elsif ($self->format eq 'infile') { | 
| 130 | 0 |  |  |  |  |  | $self->footer_infile($self->distribution_name); | 
| 131 |  |  |  |  |  |  | } | 
| 132 |  |  |  |  |  |  |  | 
| 133 | 0 |  |  |  |  |  | return; | 
| 134 |  |  |  |  |  |  | } | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | ####### | 
| 137 |  |  |  |  |  |  | # no_index | 
| 138 |  |  |  |  |  |  | ####### | 
| 139 |  |  |  |  |  |  | sub no_index { | 
| 140 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | #ToDo add more options as and when | 
| 143 |  |  |  |  |  |  | my @dirs_to_check | 
| 144 | 0 |  |  |  |  |  | = qw( corpus eg examples fbp inc maint misc privinc share t xt ); | 
| 145 | 0 |  |  |  |  |  | my @dirs_found; | 
| 146 |  |  |  |  |  |  |  | 
| 147 | 0 |  |  |  |  |  | foreach my $dir (@dirs_to_check) { | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | #ignore syntax warning for global | 
| 150 | 0 | 0 |  |  |  |  | push @dirs_found, $dir | 
| 151 |  |  |  |  |  |  | if -d File::Spec->catdir($App::Midgen::Working_Dir, $dir); | 
| 152 |  |  |  |  |  |  | } | 
| 153 | 0 |  |  |  |  |  | return @dirs_found; | 
| 154 |  |  |  |  |  |  | } | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | ####### | 
| 157 |  |  |  |  |  |  | # in_local_lib | 
| 158 |  |  |  |  |  |  | ####### | 
| 159 |  |  |  |  |  |  | sub in_local_lib { | 
| 160 | 0 |  |  | 0 | 1 |  | my $self         = shift; | 
| 161 | 0 |  |  |  |  |  | my $found_module = shift; | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  | # exemption for perl :) | 
| 164 |  |  |  |  |  |  | # return $PERL_VERSION if $found_module eq 'perl'; | 
| 165 | 0 | 0 |  |  |  |  | return $] if $found_module eq 'perl'; | 
| 166 |  |  |  |  |  |  |  | 
| 167 |  |  |  |  |  |  | try { | 
| 168 |  |  |  |  |  |  | # Show installed version-string | 
| 169 |  |  |  |  |  |  | # hack from Module::Vesrion | 
| 170 | 0 |  |  | 0 |  |  | require ExtUtils::MakeMaker; | 
| 171 | 0 |  |  |  |  |  | return MM->parse_version(MM->_installed_file_for_module($found_module)); | 
| 172 |  |  |  |  |  |  | } | 
| 173 |  |  |  |  |  |  | catch { | 
| 174 |  |  |  |  |  |  | # module not installed in local-lib | 
| 175 | 0 |  |  | 0 |  |  | return colored('Missing  ', 'red'); | 
| 176 | 0 |  |  |  |  |  | }; | 
| 177 |  |  |  |  |  |  | #return; don't follow pbp as it F's-up | 
| 178 |  |  |  |  |  |  | } | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  |  | 
| 181 | 2 |  |  | 2 |  | 1731 | no Moo; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 13 |  | 
| 182 |  |  |  |  |  |  |  | 
| 183 |  |  |  |  |  |  | 1; | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  | __END__ | 
| 186 |  |  |  |  |  |  |  | 
| 187 |  |  |  |  |  |  | =pod | 
| 188 |  |  |  |  |  |  |  | 
| 189 |  |  |  |  |  |  | =encoding UTF-8 | 
| 190 |  |  |  |  |  |  |  | 
| 191 |  |  |  |  |  |  | =head1 NAME | 
| 192 |  |  |  |  |  |  |  | 
| 193 |  |  |  |  |  |  | App::Midgen::Role::Output - A collection of output orientated methods used by L<App::Midgen> | 
| 194 |  |  |  |  |  |  |  | 
| 195 |  |  |  |  |  |  | =head1 VERSION | 
| 196 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  | version: 0.33_05 | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  | The output format uses colour to add visualization of module version number | 
| 202 |  |  |  |  |  |  | types, be that mcpan, dual-life or added distribution. | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | =head1 METHODS | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | =over 4 | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  | =item * output_header | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | =item * output_main_body | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | =item * output_footer | 
| 213 |  |  |  |  |  |  |  | 
| 214 |  |  |  |  |  |  | =item * no_index | 
| 215 |  |  |  |  |  |  |  | 
| 216 |  |  |  |  |  |  | Suggest some of your local directories you can 'no_index' | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  | =item * in_local_lib | 
| 219 |  |  |  |  |  |  |  | 
| 220 |  |  |  |  |  |  | version string from local-lib or corelist | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  | =back | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  | =head1 DEPENDENCIES | 
| 225 |  |  |  |  |  |  |  | 
| 226 |  |  |  |  |  |  | L<Term::ANSIColor> | 
| 227 |  |  |  |  |  |  |  | 
| 228 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 229 |  |  |  |  |  |  |  | 
| 230 |  |  |  |  |  |  | L<App::Midgen> | 
| 231 |  |  |  |  |  |  |  | 
| 232 |  |  |  |  |  |  | =head1 AUTHOR | 
| 233 |  |  |  |  |  |  |  | 
| 234 |  |  |  |  |  |  | See L<App::Midgen> | 
| 235 |  |  |  |  |  |  |  | 
| 236 |  |  |  |  |  |  | =head2 CONTRIBUTORS | 
| 237 |  |  |  |  |  |  |  | 
| 238 |  |  |  |  |  |  | See L<App::Midgen> | 
| 239 |  |  |  |  |  |  |  | 
| 240 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 241 |  |  |  |  |  |  |  | 
| 242 |  |  |  |  |  |  | See L<App::Midgen> | 
| 243 |  |  |  |  |  |  |  | 
| 244 |  |  |  |  |  |  | =head1 LICENSE | 
| 245 |  |  |  |  |  |  |  | 
| 246 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify | 
| 247 |  |  |  |  |  |  | it under the same terms as Perl itself. | 
| 248 |  |  |  |  |  |  |  | 
| 249 |  |  |  |  |  |  | =cut | 
| 250 |  |  |  |  |  |  |  |