File Coverage

blib/lib/App/Midgen/Role/Output/METAjson.pm
Criterion Covered Total %
statement 21 123 17.0
branch 0 36 0.0
condition 0 6 0.0
subroutine 7 10 70.0
pod 3 3 100.0
total 31 178 17.4


line stmt bran cond sub pod time code
1             package App::Midgen::Role::Output::METAjson;
2              
3             use constant {
4 2         151 BLANK => q{ },
5             NONE => q{},
6             THREE => q{ },
7             SIX => q{ },
8             NINE => q{ },
9             TWELVE => q{ },
10 2     2   913 };
  2         3  
11              
12 2     2   7 use Moo::Role;
  2         3  
  2         11  
13             requires qw( no_index 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   3341 use English qw( -no_match_vars ); # Avoids reg-ex performance penalty
  2         2  
  2         10  
22             local $OUTPUT_AUTOFLUSH = 1;
23              
24 2     2   527 use Term::ANSIColor qw( :constants colored );
  2         2  
  2         512  
25 2     2   12 use Data::Printer {caller_info => 1,};
  2         3  
  2         15  
26 2     2   1522 use File::Spec;
  2         2  
  2         1995  
27              
28             #######
29             # header_metajson
30             #######
31             sub header_metajson {
32 0     0 1   my $self = shift;
33 0   0       my $package_name = shift || NONE;
34 0           $package_name =~ s{::}{-}g;
35              
36 0           print "{\n";
37 0 0         if ($self->verbose > 0) {
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 0         if ($self->verbose > 0) {
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             sub body_metajson {
66 0     0 1   my $self = shift;
67 0           my $title = shift;
68 0   0       my $required_ref = shift || return;
69              
70 0 0         return if not %{$required_ref};
  0            
71              
72 0 0         if ( $title eq 'RuntimeRequires') {
    0          
    0          
    0          
    0          
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}) {
  0            
80             print TWELVE . "\"$module_name\" : \"$required_ref->{$module_name}\",\n"
81 0 0         if $required_ref->{$module_name} !~ m/mcpan/;
82             }
83 0           print NINE . '}';
84              
85 0 0         if ($self->verbose > 0) {
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}) {
  0            
94             print TWELVE . "\"$module_name\" : \"$required_ref->{$module_name}\",\n"
95 0 0         if $required_ref->{$module_name} !~ m/mcpan/;
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}) {
  0            
103             print TWELVE
104             . "\"$module_name\" : \""
105             . $required_ref->{$module_name} . '",' . "\n"
106 0 0         if $required_ref->{$module_name} !~ m/mcpan/;
107             }
108 0           print NINE . '}';
109             }
110             elsif ( $title eq 'TestSuggests') {
111 0 0         if ($required_ref) {
112 0           print ",\n";
113 0           print NINE . '"suggests" : {' . "\n";
114 0           foreach my $module_name (sort keys %{$required_ref}) {
  0            
115             print TWELVE
116             . "\"$module_name\" : \""
117             . $required_ref->{$module_name} . '",' . "\n"
118 0 0         if $required_ref->{$module_name} !~ m/mcpan/;
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 0         if ($required_ref) {
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}) {
  0            
137             print TWELVE
138             . "\"$module_name\" : \""
139             . $required_ref->{$module_name} . '",' . "\n"
140 0 0         if $required_ref->{$module_name} !~ m/mcpan/;
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             sub footer_metajson {
156 0     0 1   my $self = shift;
157 0   0       my $package_name = shift || NONE;
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 0         if (@no_index) {
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 0         if ($self->verbose > 0) {
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     2   10 no Moo;
  2         2  
  2         10  
205              
206             1;
207              
208             __END__
209              
210             =pod
211              
212             =encoding UTF-8
213              
214             =head1 NAME
215              
216             App::Midgen::Role::Output::METAjson - Output Format - META.json,
217             used by L<App::Midgen>
218              
219             =head1 VERSION
220              
221             version: 0.33_05
222              
223             =head1 DESCRIPTION
224              
225             The output format uses colour to add visualization of module version number
226             types, be that mcpan, dual-life or added distribution.
227              
228             =head1 METHODS
229              
230             =over 4
231              
232             =item * header_metajson
233              
234             =item * body_metajson
235              
236             =item * footer_metajson
237              
238             =back
239              
240             =head1 DEPENDENCIES
241              
242             L<Term::ANSIColor>
243              
244             =head1 SEE ALSO
245              
246             L<App::Midgen>
247              
248             =head1 AUTHOR
249              
250             See L<App::Midgen>
251              
252             =head2 CONTRIBUTORS
253              
254             See L<App::Midgen>
255              
256             =head1 COPYRIGHT
257              
258             See L<App::Midgen>
259              
260             =head1 LICENSE
261              
262             This library is free software; you can redistribute it and/or modify
263             it under the same terms as Perl itself.
264              
265             =cut
266              
267             255: To save a full .LOG file rerun with -g