| 1 | package Dist::Zilla::Plugin::TravisCI::StatusBadge; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Get Travis CI status badge for your markdown README | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Path::Tiny 0.004; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Encode qw(encode); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Dist::Zilla::File::OnDisk; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | our $VERSION = '0.009'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | with qw( | |||||||||||||||||||||||||||||||||||||||||
| 17 | Dist::Zilla::Role::AfterBuild | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | has readme => ( | |||||||||||||||||||||||||||||||||||||||||
| 21 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | predicate => 'has_readme', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | clearer => 'clear_readme', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | has user => ( | |||||||||||||||||||||||||||||||||||||||||
| 28 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | predicate => 'has_user', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | has repo => ( | |||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | predicate => 'has_repo', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | has branch => ( | ||||||||||||||||||||||||||||||||||||||||||
| 40 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 26 | ▶ | default => sub { 'master' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | has vector => ( | ||||||||||||||||||||||||||||||||||||||||||
| 46 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 26 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | has format => ( | ||||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | isa => Moose::Util::TypeConstraints::enum(['markdown', 'pod', '']), | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 25 | ▶ | default => sub { '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | has ext => ( | ||||||||||||||||||||||||||||||||||||||||||
| 58 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 27 | ▶ | default => sub { [qw( md mkdn markdown pod )] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | has names => ( | ||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 27 | ▶ | default => sub { [qw( README Readme )] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | has matrix => ( | ||||||||||||||||||||||||||||||||||||||||||
| 70 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 71 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||||||||||||||||
| 72 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 22 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 22 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 22 | my @combies; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 22 | for my $ext ( @{ $self->ext } ) { | |||||||||||||||||||||||||||||||||||||||||
| 79 | 88 | push @combies, map { $_ . '.' . $ext } @{ $self->names }; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 22 | [ @combies ]; | |||||||||||||||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 27 | ▶ | sub after_build { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_build: called CC=17 SCAR=28.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 27 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | # fill user/repo using distmeta | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 27 | ▶ | $self->_try_distmeta() unless $self->has_user && $self->has_repo; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_user and $self->has_repo
MC/DC100%2/2
$self->has_user and $self->has_repo
$self->has_user
$self->has_repo
Truth table100%3/3
A and B
A= $self->has_userB= $self->has_repo
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 27 | ▶ | unless ( $self->has_user && $self->has_repo ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_user and $self->has_repo
MC/DC100%2/2
$self->has_user and $self->has_repo
$self->has_user
$self->has_repo
Truth table100%3/3
A and B
A= $self->has_userB= $self->has_repo
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 5 | $self->log( "Missing option: user or repo." ); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 22 | my $file = $self->_try_any_readme(); | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 22 | ▶ | unless ( $self->has_readme ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | $self->log( "No README found in root directory." ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 19 | $self->log( "Override " . $self->readme . " in root directory." ); | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 19 | my $readme = Dist::Zilla::File::OnDisk->new( name => "$file" ); | |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 19 | my $edited; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 19 | ▶ | if ($self->format eq 'pod' || ($self->readme =~ /\.pod$/ && $self->format eq '')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->format eq "pod" or $self->readme =~ /\.pod$/ and $self->format eq ""
$self->readme =~ /\.pod$/ and $self->format eq ""
MC/DC66%2/3
$self->format eq "pod" or $self->readme =~ /\.pod$/ and $self->format eq ""
$self->format eq "pod"
$self->readme =~ /\.pod$/
$self->format eq ""
Truth table75%3/4
A or B and C
A= $self->format eq "pod"B= $self->readme =~ /\.pod$/C= $self->format eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | foreach my $line ( split /\n/, $readme->content ) { | |||||||||||||||||||||||||||||||||||||||||
| 113 | 42 | ▶ | if ( $line =~ /^=head1 VERSION/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | $self->log( "Inject build status badge" ); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | $line = join '' => | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 117 | qq(=for html <a href="https://travis-ci.org/%s/%s"><img alt="Build Status" src="https://travis-ci.org/%s/%s.%s?branch=%s" /></a>\n\n) => | ||||||||||||||||||||||||||||||||||||||||||
| 118 | $self->user, $self->repo, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | $self->user, $self->repo, ( $self->vector ? 'svg' : 'png' ), $self->branch, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 121 | $line; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 42 | $edited .= $line . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 17 | foreach my $line ( split /\n/, $readme->content ) { | |||||||||||||||||||||||||||||||||||||||||
| 127 | 306 | ▶ | if ( $line =~ /^# VERSION/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 17 | $self->log( "Inject build status badge" ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 17 | ▶ | $line = join '' => | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 131 | "[](https://travis-ci.org/%s/%s)\n\n" => | ||||||||||||||||||||||||||||||||||||||||||
| 132 | $self->user, $self->repo, ( $self->vector ? 'svg' : 'png' ), $self->branch, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | $self->user, $self->repo | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 135 | $line; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 306 | $edited .= $line . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 19 | ▶ | my $encoding = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | $readme->can( 'encoding' ) | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ? $readme->encoding | ||||||||||||||||||||||||||||||||||||||||||
| 144 | : 'raw' # Dist::Zilla pre-5.0 | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 19 | ▶ | $file->spew_raw( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | $encoding eq 'raw' | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ? $edited | ||||||||||||||||||||||||||||||||||||||||||
| 150 | : encode( $encoding, $edited ) | ||||||||||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 19 | return; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | # attempt to fill user/repo using distmeta resources | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 20 | ▶ | sub _try_distmeta { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_try_distmeta: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 20 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 20 | my $meta = $self->zilla->distmeta; | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 20 | ▶ | return unless exists $meta->{resources}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | # possible list of sources for user/repo: | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # resources.repository.web | ||||||||||||||||||||||||||||||||||||||||||
| 167 | # resources.repository.url | ||||||||||||||||||||||||||||||||||||||||||
| 168 | # resources.homepage | ||||||||||||||||||||||||||||||||||||||||||
| 169 | my @sources = ( | ||||||||||||||||||||||||||||||||||||||||||
| 170 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 171 | exists $meta->{resources}{repository} | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 10 | ▶ | ? grep { defined $_ } @{ $meta->{resources}{repository} }{qw( web url )} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 174 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 175 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 176 | exists $meta->{resources}{homepage} | ||||||||||||||||||||||||||||||||||||||||||
| 177 | ? $meta->{resources}{homepage} | ||||||||||||||||||||||||||||||||||||||||||
| 178 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 17 | ▶ | ), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | # remove duplicates | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 17 | @sources = do { | |||||||||||||||||||||||||||||||||||||||||
| 184 | 17 | my %seen = map { $_ => 1 } @sources; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 17 | sort keys %seen; | |||||||||||||||||||||||||||||||||||||||||
| 186 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 17 | for my $source ( @sources ) { | |||||||||||||||||||||||||||||||||||||||||
| 189 | # dont overwrite | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 17 | ▶ | last if $self->has_user && $self->has_repo; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->has_user and $self->has_repo
MC/DC0%0/2
$self->has_user and $self->has_repo
$self->has_user
$self->has_repo
Truth table33%1/3
A and B
A= $self->has_userB= $self->has_repo
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 17 | ▶ | next unless $source =~ m/github\.com/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # taken from Dist/Zilla/Plugin/GithubMeta.pm | ||||||||||||||||||||||||||||||||||||||||||
| 195 | # thanks to BINGOS! | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 16 | my ( $user, $repo ) = $source =~ m{ | |||||||||||||||||||||||||||||||||||||||||
| 197 | github\.com # the domain | ||||||||||||||||||||||||||||||||||||||||||
| 198 | [:/] ([^/]+) # the username (: for ssh, / for http) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | / ([^/]+?) (?:\.git)? # the repo name | ||||||||||||||||||||||||||||||||||||||||||
| 200 | $ | ||||||||||||||||||||||||||||||||||||||||||
| 201 | }ix; | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 16 | ▶ | next unless defined $user && defined $repo; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $user and defined $repo
MC/DC50%1/2
defined $user and defined $repo
defined $user
defined $repo
Truth table66%2/3
A and B
A= defined $userB= defined $repo
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 15 | $self->user( $user ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 15 | $self->repo( $repo ); | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 15 | last; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | # guess readme filename | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 22 | ▶ | sub _try_any_readme { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_try_any_readme: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 22 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 22 | my $zillafile; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | my @variations = ( | ||||||||||||||||||||||||||||||||||||||||||
| 220 | ( $self->has_readme ? $self->readme : () ), | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 22 | ▶ | @{ $self->matrix }, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 22 | for my $name ( @variations ) { | |||||||||||||||||||||||||||||||||||||||||
| 225 | 65 | ▶ | next unless $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 65 | $self->clear_readme; | |||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 65 | my $file = $self->zilla->root->child( $name ); | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 65 | ▶ | if ( $file->exists ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 19 | $self->readme( $name ); | |||||||||||||||||||||||||||||||||||||||||
| 233 | 19 | $zillafile = $file; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 19 | last; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 22 | return $zillafile; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | __END__ | ||||||||||||||||||||||||||||||||||||||||||