| 1 | package App::Midgen::Role::Output::METAjson; | ||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||
| 3 | 2 | ▶ | use constant { | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 4 | 2 | BLANK => q{ }, | |||||||||||||||||||||||||
| 5 | NONE => q{}, | ||||||||||||||||||||||||||
| 6 | THREE => q{ }, | ||||||||||||||||||||||||||
| 7 | SIX => q{ }, | ||||||||||||||||||||||||||
| 8 | NINE => q{ }, | ||||||||||||||||||||||||||
| 9 | TWELVE => q{ }, | ||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Moo::Role; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 13 | 2 | requires qw( no_index verbose ); | |||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||
| 15 | # Load time and dependencies negate execution time | ||||||||||||||||||||||||||
| 16 | # use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||
| 18 | 2 | our $VERSION = '0.34'; | |||||||||||||||||||||||||
| 19 | 2 | $VERSION = eval $VERSION; ## no critic | |||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||
| 21 | 2 | ▶ | use English qw( -no_match_vars ); # Avoids reg-ex performance penalty | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 22 | 2 | local $OUTPUT_AUTOFLUSH = 1; | |||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Term::ANSIColor qw( :constants colored ); | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 25 | 2 | ▶ | use Data::Printer {caller_info => 1,}; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 26 | 2 | ▶ | use File::Spec; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||
| 28 | ####### | ||||||||||||||||||||||||||
| 29 | # header_metajson | ||||||||||||||||||||||||||
| 30 | ####### | ||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub header_metajson { | ||||||||||||||||||||||||
|
Subroutine
header_metajson: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||||||||||||||||
| 33 | 0 | ▶ | my $package_name = shift || NONE; | ||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||
| 34 | 0 | $package_name =~ s{::}{-}g; | |||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||
| 36 | 0 | print "{\n"; | |||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($self->verbose > 0) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 38 | 0 | print BRIGHT_BLACK THREE | |||||||||||||||||||||||||
| 39 | . '"abstract" : "This is a short description of the purpose of the distribution.",' . "\n"; | ||||||||||||||||||||||||||
| 40 | 0 | print THREE . '"author" : "...",' . "\n"; | |||||||||||||||||||||||||
| 41 | 0 | print THREE . '"dynamic_config" : "0|1",' . "\n"; | |||||||||||||||||||||||||
| 42 | 0 | print THREE . '"generated_by" : "...",' . "\n"; | |||||||||||||||||||||||||
| 43 | 0 | print THREE . '"license" : [' . "\n"; | |||||||||||||||||||||||||
| 44 | 0 | print SIX . '"perl_5"' . "\n"; | |||||||||||||||||||||||||
| 45 | 0 | print THREE . "],\n"; | |||||||||||||||||||||||||
| 46 | 0 | print THREE . '"meta-spec" : {' . "\n"; | |||||||||||||||||||||||||
| 47 | 0 | print SIX . '"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",' . "\n"; | |||||||||||||||||||||||||
| 48 | 0 | print SIX . '"version" : "2"' . "\n"; | |||||||||||||||||||||||||
| 49 | 0 | print THREE . '},'; | |||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||
| 51 | 0 | print CLEAR THREE . '"name" : "' . $package_name . q{",} . "\n"; | |||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ($self->verbose > 0) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 55 | 0 | print BRIGHT_BLACK THREE . '"release_status" : "stable|testing|unstable",' . "\n"; | |||||||||||||||||||||||||
| 56 | 0 | print THREE . '"version" : "...",' . "\n"; | |||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||
| 59 | 0 | return; | |||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||
| 62 | ####### | ||||||||||||||||||||||||||
| 63 | # body_metajson | ||||||||||||||||||||||||||
| 64 | ####### | ||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub body_metajson { | ||||||||||||||||||||||||
|
Subroutine
body_metajson: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||
| 66 | 0 | my $self = shift; | |||||||||||||||||||||||||
| 67 | 0 | my $title = shift; | |||||||||||||||||||||||||
| 68 | 0 | ▶ | my $required_ref = shift || return; | ||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | return if not %{$required_ref}; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ( $title eq 'RuntimeRequires') { | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 73 | 0 | print CLEAR THREE . '"prereqs" : {' . "\n"; | |||||||||||||||||||||||||
| 74 | 0 | print SIX . '"runtime" : {' . "\n"; | |||||||||||||||||||||||||
| 75 | 0 | print NINE . '"requires" : {' . "\n"; | |||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||
| 77 | 0 | $required_ref->{'perl'} = $App::Midgen::Min_Version; | |||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||
| 79 | 0 | foreach my $module_name (sort keys %{$required_ref}) { | |||||||||||||||||||||||||
| 80 | print TWELVE . "\"$module_name\" : \"$required_ref->{$module_name}\",\n" | ||||||||||||||||||||||||||
| 81 | 0 | ▶ | if $required_ref->{$module_name} !~ m/mcpan/; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||
| 83 | 0 | print NINE . '}'; | |||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ($self->verbose > 0) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 86 | 0 | print BRIGHT_BLACK ",\n" . NINE . '"suggests" : {...},' . "\n"; | |||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||
| 88 | 0 | print CLEAR; | |||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||
| 91 | elsif ( $title eq 'RuntimeRecommends') { | ||||||||||||||||||||||||||
| 92 | 0 | print NINE . '"recommends" : {' . "\n"; | |||||||||||||||||||||||||
| 93 | 0 | foreach my $module_name (sort keys %{$required_ref}) { | |||||||||||||||||||||||||
| 94 | print TWELVE . "\"$module_name\" : \"$required_ref->{$module_name}\",\n" | ||||||||||||||||||||||||||
| 95 | 0 | ▶ | if $required_ref->{$module_name} !~ m/mcpan/; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||
| 97 | 0 | print NINE . "}\n"; | |||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||
| 99 | elsif ( $title eq 'TestRequires') { | ||||||||||||||||||||||||||
| 100 | 0 | print SIX . '"test" : {' . "\n"; | |||||||||||||||||||||||||
| 101 | 0 | print NINE . '"requires" : {' . "\n"; | |||||||||||||||||||||||||
| 102 | 0 | foreach my $module_name (sort keys %{$required_ref}) { | |||||||||||||||||||||||||
| 103 | print TWELVE | ||||||||||||||||||||||||||
| 104 | . "\"$module_name\" : \"" | ||||||||||||||||||||||||||
| 105 | . $required_ref->{$module_name} . '",' . "\n" | ||||||||||||||||||||||||||
| 106 | 0 | ▶ | if $required_ref->{$module_name} !~ m/mcpan/; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||
| 108 | 0 | print NINE . '}'; | |||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||
| 110 | elsif ( $title eq 'TestSuggests') { | ||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($required_ref) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 112 | 0 | print ",\n"; | |||||||||||||||||||||||||
| 113 | 0 | print NINE . '"suggests" : {' . "\n"; | |||||||||||||||||||||||||
| 114 | 0 | foreach my $module_name (sort keys %{$required_ref}) { | |||||||||||||||||||||||||
| 115 | print TWELVE | ||||||||||||||||||||||||||
| 116 | . "\"$module_name\" : \"" | ||||||||||||||||||||||||||
| 117 | . $required_ref->{$module_name} . '",' . "\n" | ||||||||||||||||||||||||||
| 118 | 0 | ▶ | if $required_ref->{$module_name} !~ m/mcpan/; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||
| 121 | 0 | print NINE . "}\n"; | |||||||||||||||||||||||||
| 122 | 0 | print SIX . '}'; | |||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||
| 124 | else { | ||||||||||||||||||||||||||
| 125 | 0 | print "\n"; | |||||||||||||||||||||||||
| 126 | 0 | print SIX . '}'; | |||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||
| 130 | elsif ( $title eq 'DevelopRequires') { | ||||||||||||||||||||||||||
| 131 | 0 | ▶ | if ($required_ref) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||
| 133 | 0 | print ",\n"; | |||||||||||||||||||||||||
| 134 | 0 | print SIX . '"develop" : {' . "\n"; | |||||||||||||||||||||||||
| 135 | 0 | print NINE . '"requires" : {' . "\n"; | |||||||||||||||||||||||||
| 136 | 0 | foreach my $module_name (sort keys %{$required_ref}) { | |||||||||||||||||||||||||
| 137 | print TWELVE | ||||||||||||||||||||||||||
| 138 | . "\"$module_name\" : \"" | ||||||||||||||||||||||||||
| 139 | . $required_ref->{$module_name} . '",' . "\n" | ||||||||||||||||||||||||||
| 140 | 0 | ▶ | if $required_ref->{$module_name} !~ m/mcpan/; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||
| 143 | 0 | print NINE . "}\n"; | |||||||||||||||||||||||||
| 144 | 0 | print SIX . '}'; | |||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||
| 147 | # } | ||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||
| 149 | 0 | return; | |||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||
| 152 | ####### | ||||||||||||||||||||||||||
| 153 | # footer_metajson | ||||||||||||||||||||||||||
| 154 | ####### | ||||||||||||||||||||||||||
| 155 | 0 | ▶ | sub footer_metajson { | ||||||||||||||||||||||||
|
Subroutine
footer_metajson: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||
| 156 | 0 | my $self = shift; | |||||||||||||||||||||||||
| 157 | 0 | ▶ | my $package_name = shift || NONE; | ||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||
| 158 | 0 | $package_name =~ s{::}{-}g; | |||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||
| 160 | 0 | print "\n"; | |||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||
| 162 | 0 | print THREE . "},\n"; | |||||||||||||||||||||||||
| 163 | 0 | my @no_index = $self->no_index; | |||||||||||||||||||||||||
| 164 | 0 | ▶ | if (@no_index) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 165 | 0 | print THREE . '"no_index" : {' . "\n"; | |||||||||||||||||||||||||
| 166 | 0 | print SIX . '"directory" : [' . "\n"; | |||||||||||||||||||||||||
| 167 | 0 | foreach my $no_idx (@no_index) { | |||||||||||||||||||||||||
| 168 | 0 | print NINE . q{"} . $no_idx . q{",} . "\n"; | |||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||
| 170 | 0 | print SIX . "]\n"; | |||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ($self->verbose > 0) { | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 174 | 0 | print THREE . '},' . "\n"; | |||||||||||||||||||||||||
| 175 | 0 | print BRIGHT_BLACK THREE . '"resources" : {' . "\n"; | |||||||||||||||||||||||||
| 176 | 0 | print SIX . '"bugtracker" : {' . "\n"; | |||||||||||||||||||||||||
| 177 | 0 | print NINE | |||||||||||||||||||||||||
| 178 | . '"web" : "https://github.com/.../' | ||||||||||||||||||||||||||
| 179 | . $package_name | ||||||||||||||||||||||||||
| 180 | . '/issues"' . "\n"; | ||||||||||||||||||||||||||
| 181 | 0 | print SIX . "},\n"; | |||||||||||||||||||||||||
| 182 | 0 | print SIX . '"homepage" : "https://github.com/.../' . $package_name . q{",} . "\n"; | |||||||||||||||||||||||||
| 183 | 0 | print SIX . '"repository" : {' . "\n"; | |||||||||||||||||||||||||
| 184 | 0 | print NINE . '"type" : "git",' . "\n"; | |||||||||||||||||||||||||
| 185 | 0 | print NINE . '"url" : "https://github.com/.../' . $package_name . q{.git",} . "\n"; | |||||||||||||||||||||||||
| 186 | 0 | print NINE . '"web" : "https://github.com/.../' . $package_name . q{"} . "\n"; | |||||||||||||||||||||||||
| 187 | 0 | print SIX . "}\n"; | |||||||||||||||||||||||||
| 188 | 0 | print THREE . "},\n"; | |||||||||||||||||||||||||
| 189 | 0 | print THREE . '"x_contributors" : [' . "\n"; | |||||||||||||||||||||||||
| 190 | 0 | print SIX . '"brian d foy (ADOPTME) <brian.d.foy@gmail.com>",' . "\n"; | |||||||||||||||||||||||||
| 191 | 0 | print SIX . '"Fred Bloggs <fred@bloggs.org>"' . "\n"; | |||||||||||||||||||||||||
| 192 | 0 | print THREE . q{]} . "\n"; | |||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||
| 194 | else { | ||||||||||||||||||||||||||
| 195 | 0 | print THREE . "}\n"; | |||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||
| 198 | 0 | print CLEAR . "}\n"; | |||||||||||||||||||||||||
| 199 | 0 | print qq{\n}; | |||||||||||||||||||||||||
| 200 | 0 | return; | |||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||
| 204 | 2 | ▶ | no Moo; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||
| 206 | 2 | 1; | |||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||
| 208 | __END__ | ||||||||||||||||||||||||||