| 1 | 2 | ▶ | use strict; use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | package Swim::Plugin::cpan; | ||||||||||||||||||||
| 3 | 2 | our $VERSION = '0.0.7'; | |||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Swim::Pod; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | sub block_func_cpan_head { | ||||||||||||||||||
|
Subroutine
block_func_cpan_head: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 8 | 1 | my ($self, $args) = @_; | |||||||||||||||||||
| 9 | 1 | $self->create_output($args, [ qw(name badge version) ]); | |||||||||||||||||||
| 10 | } | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | sub block_func_cpan_tail { | ||||||||||||||||||
|
Subroutine
block_func_cpan_tail: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||
| 13 | 1 | my ($self, $args) = @_; | |||||||||||||||||||
| 14 | 1 | my $meta = $self->meta; | |||||||||||||||||||
| 15 | $meta->{author} = [ $meta->{author} ] | ||||||||||||||||||||
| 16 | 1 | ▶ | unless ref($meta->{author}) eq 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 17 | 1 | ▶ | $meta->{author}[0]{copyright} ||= $meta->{copyright}; | ||||||||||||||||||
|
Condition33%1/3
$meta->{"author"}[0]{"copyright"} ||= $meta->{"copyright"}
MC/DC0%0/2
$meta->{"author"}[0]{"copyright"} ||= $meta->{"copyright"}
$meta->{"author"}[0]{"copyright"}
$meta->{"copyright"}
Truth table33%1/3
A ||= B
A= $meta->{"author"}[0]{"copyright"}B= $meta->{"copyright"}
| |||||||||||||||||||||
| 18 | 1 | $self->create_output($args, [ qw(author copyright) ]); | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 2 | ▶ | sub create_output { | ||||||||||||||||||
|
Subroutine
create_output: called CC=8 SCAR=21.4
Pod
undocumented
| |||||||||||||||||||||
| 22 | 2 | my ($self, $args, $sections) = @_; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 2 | my @args = grep $_, split /\s+/, $args; | |||||||||||||||||||
| 25 | 2 | ▶ | if (@args) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 2 | ▶ | if (not grep /^[-+]/, @args) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 0 | @$sections = @args; | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | else { | ||||||||||||||||||||
| 30 | 2 | for my $arg (@args) { | |||||||||||||||||||
| 31 | 2 | ▶ | if ($arg =~ /^-(.*)/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 1 | @$sections = grep { $_ ne $1 } @$sections; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | else { | ||||||||||||||||||||
| 35 | 1 | $arg =~ s/^\+//; | |||||||||||||||||||
| 36 | 1 | @$sections = grep { $_ ne $arg } @$sections; | |||||||||||||||||||
| 37 | 1 | ▶ | if ($arg =~ /^(see)/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 1 | unshift @$sections, $arg; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||
| 41 | 0 | push @$sections, $arg; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 2 | my @output; | |||||||||||||||||||
| 49 | 2 | for my $section (@$sections) { | |||||||||||||||||||
| 50 | 5 | my $method = "add_$section"; | |||||||||||||||||||
| 51 | 5 | ▶ | my $output = $self->$method or next; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 5 | push @output, $output; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | 2 | return join "\n", @output; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 1 | ▶ | sub add_name { | ||||||||||||||||||
|
Subroutine
add_name: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 58 | 1 | my ($self) = @_; | |||||||||||||||||||
| 59 | 1 | my $meta = $self->meta; | |||||||||||||||||||
| 60 | 1 | my $uc = $self->option->{'pod-upper-head'}; | |||||||||||||||||||
| 61 | 1 | ▶ | my $head_name = $uc ? 'NAME' : 'Name'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 1 | (my $name = $meta->{name}) =~ s/-/::/g; | |||||||||||||||||||
| 63 | 1 | return <<"..."; | |||||||||||||||||||
| 64 | =head1 $head_name | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | $name - $meta->{abstract} | ||||||||||||||||||||
| 67 | ... | ||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 1 | ▶ | sub add_badge { | ||||||||||||||||||
|
Subroutine
add_badge: called CC=6 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||
| 71 | 1 | my ($self) = @_; | |||||||||||||||||||
| 72 | 1 | my $meta = $self->meta; | |||||||||||||||||||
| 73 | 1 | my $out = ''; | |||||||||||||||||||
| 74 | 1 | while (1) { | |||||||||||||||||||
| 75 | 1 | ▶ | my $badge = $self->{meta}{badge} or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 1 | ▶ | $badge = [$badge] unless ref $badge; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 77 | 1 | ▶ | my $repo = $meta->{devel}{git} or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 1 | ▶ | $repo =~ s!.*[:/]([^/]+)/([^/]+?)(?:\.git)?$!$1/$2! | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 79 | or return; | ||||||||||||||||||||
| 80 | 1 | ▶ | eval "require Swim::Plugin::badge; 1" or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | 1 | $out .= "\n" . $self->phrase_func_badge("@$badge $repo"); | |||||||||||||||||||
| 82 | 1 | $out =~ s/\n+\z/\n/; | |||||||||||||||||||
| 83 | 1 | $out =~ s/\A\n+//; | |||||||||||||||||||
| 84 | 1 | return $out; | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | ▶ | sub add_version { | ||||||||||||||||||
|
Subroutine
add_version: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 89 | 0 | my ($self) = @_; | |||||||||||||||||||
| 90 | 0 | my $uc = $self->option->{'pod-upper-head'}; | |||||||||||||||||||
| 91 | 0 | ▶ | my $head_version = $uc ? 'VERSION' : 'Version'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | 0 | my $meta = $self->meta; | |||||||||||||||||||
| 93 | 0 | (my $name = $meta->{name}) =~ s/-/::/g; | |||||||||||||||||||
| 94 | 0 | return <<"..."; | |||||||||||||||||||
| 95 | =head1 $head_version | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | This document describes L<$name> version B<$meta->{version}>. | ||||||||||||||||||||
| 98 | ... | ||||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 1 | ▶ | sub add_see { | ||||||||||||||||||
|
Subroutine
add_see: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||
| 102 | 1 | my ($self, $args) = @_; | |||||||||||||||||||
| 103 | 1 | my $meta = $self->meta; | |||||||||||||||||||
| 104 | 1 | my $uc = $self->option->{'pod-upper-head'}; | |||||||||||||||||||
| 105 | 1 | ▶ | my $head_see = $uc ? 'SEE ALSO' : 'See Also'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 106 | 1 | my $out = ''; | |||||||||||||||||||
| 107 | 1 | ▶ | if (my $see = $meta->{see}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 108 | 1 | $out .= "=head1 $head_see\n\n=over\n\n"; | |||||||||||||||||||
| 109 | 1 | ▶ | $see = [$see] unless ref $see; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 110 | 1 | for (@$see) { | |||||||||||||||||||
| 111 | 2 | $out .= "=item * L<$_>\n\n"; | |||||||||||||||||||
| 112 | } | ||||||||||||||||||||
| 113 | 1 | $out .= "=back\n"; | |||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | 1 | return $out; | |||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 1 | ▶ | sub add_author { | ||||||||||||||||||
|
Subroutine
add_author: called CC=5 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||
| 119 | 1 | my ($self) = @_; | |||||||||||||||||||
| 120 | 1 | my $meta = $self->meta; | |||||||||||||||||||
| 121 | 1 | my $uc = $self->option->{'pod-upper-head'}; | |||||||||||||||||||
| 122 | 1 | ▶ | my $head_author = $uc ? 'AUTHOR' : 'Author'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 123 | 1 | my $authors = $meta->{author}; | |||||||||||||||||||
| 124 | 1 | ▶ | if (@$authors > 1) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 125 | 0 | ▶ | $head_author = $uc ? 'AUTHORS' : 'Authors'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 126 | } | ||||||||||||||||||||
| 127 | 1 | my $out .= "=head1 $head_author\n\n"; | |||||||||||||||||||
| 128 | 1 | for my $author (@$authors) { | |||||||||||||||||||
| 129 | 1 | $out .= "$author->{name} <$author->{email}>\n\n"; | |||||||||||||||||||
| 130 | } | ||||||||||||||||||||
| 131 | 1 | chomp $out; | |||||||||||||||||||
| 132 | 1 | return $out; | |||||||||||||||||||
| 133 | } | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | 1 | ▶ | sub add_copyright { | ||||||||||||||||||
|
Subroutine
add_copyright: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||
| 136 | 1 | my ($self, $args) = @_; | |||||||||||||||||||
| 137 | 1 | my $meta = $self->meta; | |||||||||||||||||||
| 138 | 1 | my $uc = $self->option->{'pod-upper-head'}; | |||||||||||||||||||
| 139 | 1 | ▶ | my $head_copyright = $uc | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 140 | ? 'COPYRIGHT AND LICENSE' | ||||||||||||||||||||
| 141 | : 'Copyright and License'; | ||||||||||||||||||||
| 142 | 1 | my $authors = $meta->{author}; | |||||||||||||||||||
| 143 | 1 | my $out = "=head1 $head_copyright\n\n"; | |||||||||||||||||||
| 144 | 1 | for my $author (@$authors) { | |||||||||||||||||||
| 145 | 1 | ▶ | if ($author->{copyright}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 146 | 1 | $out .= "Copyright $author->{copyright}. $author->{name}.\n\n"; | |||||||||||||||||||
| 147 | } | ||||||||||||||||||||
| 148 | } | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | 1 | return $out . <<'...'; | |||||||||||||||||||
| 151 | This program is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 152 | the same terms as Perl itself. | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | See L<http://www.perl.com/perl/misc/Artistic.html> | ||||||||||||||||||||
| 155 | ... | ||||||||||||||||||||
| 156 | } | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | 2 | 1; | |||||||||||||||||||