« blib/lib/Dist/Zilla/Plugin/Author/Plicease/Init2.pm
↑ Summary
blib/lib/Dist/Zilla/Plugin/Author/Plicease/Tests.pm »
| 1 | 3 | package Dist::Zilla::Plugin::Author::Plicease::ReadmeAnyFromPod 2.81 { | |||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.022; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use experimental qw( signatures ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use URI::Escape (); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use File::Which (); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Ref::Util qw( is_plain_hashref ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use experimental qw( postderef ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||
| 11 | # ABSTRACT: Personal subclass of Dist::Zilla::Plugin::ReadmeAnyFromPod | ||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||
| 14 | 3 | extends 'Dist::Zilla::Plugin::ReadmeAnyFromPod'; | |||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||
| 16 | 9 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||
| 17 | 9 | my $orig = shift; | |||||||||||||||||||||||||||||||||||
| 18 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||
| 20 | 9 | ▶ | my %args = @_ == 1 && is_plain_hashref($_[0]) ? $_[0]->%* : @_; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and is_plain_hashref($_[0])
MC/DC0%0/2
@_ == 1 and is_plain_hashref($_[0])
@_ == 1
is_plain_hashref($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= is_plain_hashref($_[0])
| |||||||||||||||||||||||||||||||||||||
| 21 | 9 | foreach my $key (keys %args) | |||||||||||||||||||||||||||||||||||
| 22 | { | ||||||||||||||||||||||||||||||||||||
| 23 | 41 | ▶ | die "removed key: $key" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 24 | if $key =~ /^(travis_.*|appveyor_user|appveyor)$/; | ||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||
| 27 | 5 | return $class->$orig(@_); | |||||||||||||||||||||||||||||||||||
| 28 | 3 | }; | |||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||
| 30 | 3 | has github_user => ( | |||||||||||||||||||||||||||||||||||
| 31 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 32 | default => 'plicease', | ||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||
| 35 | has github_repo => ( | ||||||||||||||||||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 37 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | default => sub ($self) { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 39 | 1 | $self->zilla->name | |||||||||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||||||||||
| 41 | 3 | ); | |||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | has workflow => ( | ||||||||||||||||||||||||||||||||||||
| 44 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 45 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||
| 46 | 3 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 47 | 3 | ); | |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | has default_branch => ( | ||||||||||||||||||||||||||||||||||||
| 50 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 51 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | default => sub ($self) { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if(File::Which::which('git')) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||||||||||
| 55 | 0 | my %b = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||
| 56 | 0 | map { s/\s$//r } | |||||||||||||||||||||||||||||||||||
| 57 | 0 | map { s/^\*?\s*//r } | |||||||||||||||||||||||||||||||||||
| 58 | `git branch`; | ||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if($b{main} && $b{master}) | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$b{"main"} and $b{"master"}
MC/DC0%0/2
$b{"main"} and $b{"master"}
$b{"main"}
$b{"master"}
Truth table0%0/3
A and B
A= $b{"main"}B= $b{"master"}
| |||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||
| 61 | 0 | $self->log("!! You have both a main and master branch, please switch to just a main branch (or explicitly set default_branch) !!"); | |||||||||||||||||||||||||||||||||||
| 62 | 0 | return 'main'; | |||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||
| 64 | elsif($b{main}) | ||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->log("deteching main as default branch"); | |||||||||||||||||||||||||||||||||||
| 67 | 0 | return 'main'; | |||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||
| 69 | elsif($b{master}) | ||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->log("!! Please switch to using main as the main branch (or explicitly set default_branch) !!"); | |||||||||||||||||||||||||||||||||||
| 72 | 0 | return 'master'; | |||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||
| 74 | else | ||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->log("!! cannot find either a main or master branch please create one or explicitly set default_branch !!"); | |||||||||||||||||||||||||||||||||||
| 77 | 0 | return 'main'; | |||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->log("unable to detect default branch assuming main"); | |||||||||||||||||||||||||||||||||||
| 81 | 0 | return 'main'; # may need to update the repo | |||||||||||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||||||||||
| 83 | 3 | ); | |||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||
| 85 | 9 | ▶ | sub mvp_multivalue_args { qw( workflow ) } | ||||||||||||||||||||||||||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | around get_readme_content => sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||
| 88 | 3 | my $orig = shift; | |||||||||||||||||||||||||||||||||||
| 89 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||
| 91 | 3 | my $content = do { | |||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||
| 94 | # The super class at some point changes its behavior to escape URLs | ||||||||||||||||||||||||||||||||||||
| 95 | # so that IPv6 addresses could be properly used in markdown. | ||||||||||||||||||||||||||||||||||||
| 96 | # Unfortunately this also meant that class names with :: also got | ||||||||||||||||||||||||||||||||||||
| 97 | # escaped making them hard to read. Since I never use literal IPv6 | ||||||||||||||||||||||||||||||||||||
| 98 | # addresses in URLs and I do very often have links to Perl | ||||||||||||||||||||||||||||||||||||
| 99 | # documentation with :: that was not a useful change. | ||||||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | local *URI::Escape::uri_escape = sub { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 101 | 2 | my($uri) = @_; | |||||||||||||||||||||||||||||||||||
| 102 | 2 | $uri; | |||||||||||||||||||||||||||||||||||
| 103 | 3 | }; | |||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||
| 105 | 3 | $self->$orig(@_); | |||||||||||||||||||||||||||||||||||
| 106 | }; | ||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||
| 108 | 3 | ▶ | return $content unless $self->type eq 'gfm'; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||
| 110 | 2 | my $status = ''; | |||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||
| 112 | 2 | foreach my $workflow ($self->workflow->@*) | |||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||
| 114 | 2 | $status .= " "; | |||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||
| 117 | 2 | $content =~ s{# NAME\s+(.*?) - (.*?#)}{# $1$status\n\n$2}s; | |||||||||||||||||||||||||||||||||||
| 118 | 2 | $content =~ s{# VERSION\s+version (\d+\.|)\d+\.\d+(\\_\d+|)\s+#}{#}a; | |||||||||||||||||||||||||||||||||||
| 119 | 2 | return $content; | |||||||||||||||||||||||||||||||||||
| 120 | 3 | }; | |||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||
| 122 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||
| 125 | 3 | 1; | |||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||
| 127 | __END__ | ||||||||||||||||||||||||||||||||||||