File Coverage

lib/Pod/PseudoPod/Book/Command/buildcredits.pm
Criterion Covered Total %
statement 15 39 38.4
branch 0 6 0.0
condition 0 2 0.0
subroutine 5 6 83.3
pod 1 1 100.0
total 21 54 38.8


line stmt bran cond sub pod time code
1             package Pod::PseudoPod::Book::Command::buildcredits;
2             # ABSTRACT: command module for C<ppbook buildcredits>
3              
4 2     2   2463 use strict;
  2         5  
  2         83  
5 2     2   12 use warnings;
  2         6  
  2         89  
6              
7 2     2   11 use parent 'Pod::PseudoPod::Book::Command';
  2         5  
  2         19  
8              
9 2     2   150 use autodie;
  2         17  
  2         16  
10 2     2   11598 use File::Spec::Functions 'catfile';
  2         7  
  2         1298  
11              
12             sub execute
13             {
14 0     0 1   my ($self, $opt, $args) = @_;
15 0           my $conf = $self->config;
16 0 0         return unless $conf->{book}{build_credits};
17              
18             my $author_name = $opt->{author_name}
19             || $conf->{book}{author_name}
20 0   0       || '';
21              
22 0           open my $fh, '<:utf8', 'CREDITS';
23 0           my @names;
24              
25 0           while (<$fh>)
26             {
27 0 0         next unless /^N: (.+)$/;
28 0 0         next if $1 eq $author_name;
29 0           push @names, $1;
30             }
31              
32 0           my @sorted = map { local $" = ' '; "@$_" }
  0            
33 0           sort { $a->[-1] cmp $b->[-1] }
34 0           map { [ (split / /, $_) ] }
  0            
35             @names;
36              
37 0           my $last = pop @sorted;
38 0           my $dir = $conf->{layout}{subchapter_directory};
39              
40 0           open my $out_fh, '>:utf8', catfile( $dir, 'credits.pod' );
41 0           print {$out_fh} "Z<credits>\n";
  0            
42              
43 0           print {$out_fh} "$_,\n" for @sorted;
  0            
44 0           print {$out_fh} "and $last.\n";
  0            
45             }
46              
47             1;
48              
49             __END__
50              
51             =pod
52              
53             =encoding UTF-8
54              
55             =head1 NAME
56              
57             Pod::PseudoPod::Book::Command::buildcredits - command module for C<ppbook buildcredits>
58              
59             =head1 VERSION
60              
61             version 1.20210620.2051
62              
63             =head1 AUTHOR
64              
65             chromatic <chromatic@wgz.org>
66              
67             =head1 COPYRIGHT AND LICENSE
68              
69             This software is copyright (c) 2011 by chromatic.
70              
71             This is free software; you can redistribute it and/or modify it under
72             the same terms as the Perl 5 programming language system itself.
73              
74             =cut