| 1 | 2 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Badge::Depot::Plugin::Cpantesters; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # ABSTRACT: CPAN testers plugin for Badge::Depot | ||||||||||||||||||||||||||||
| 8 | 2 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||||||||||
| 9 | 2 | our $VERSION = '0.0101'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use MooseX::AttributeShortcuts; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Types::Standard qw/Str HashRef/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Types::URI qw/Uri/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use JSON::MaybeXS 'decode_json'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 2 | with 'Badge::Depot'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | has dist => ( | ||||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||
| 22 | isa => Str, | ||||||||||||||||||||||||||||
| 23 | lazy => 1, | ||||||||||||||||||||||||||||
| 24 | default => sub { | ||||||||||||||||||||||||||||
| 25 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | if($self->get_meta('dist')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 1 | return $self->_meta->{'dist'}; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||
| 30 | 2 | ); | |||||||||||||||||||||||||||
| 31 | has version => ( | ||||||||||||||||||||||||||||
| 32 | is => 'ro', | ||||||||||||||||||||||||||||
| 33 | isa => Str, | ||||||||||||||||||||||||||||
| 34 | lazy => 1, | ||||||||||||||||||||||||||||
| 35 | default => sub { | ||||||||||||||||||||||||||||
| 36 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | if($self->get_meta('version')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 1 | return $self->_meta->{'version'}; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||
| 41 | 2 | ); | |||||||||||||||||||||||||||
| 42 | 2 | has base_url => ( | |||||||||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||||||||||
| 44 | isa => Uri, | ||||||||||||||||||||||||||||
| 45 | coerce => 1, | ||||||||||||||||||||||||||||
| 46 | lazy => 1, | ||||||||||||||||||||||||||||
| 47 | default => 'https://badgedepot.code301.com', | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | 2 | has custom_image_url => ( | |||||||||||||||||||||||||||
| 50 | is => 'ro', | ||||||||||||||||||||||||||||
| 51 | isa => Uri, | ||||||||||||||||||||||||||||
| 52 | coerce => 1, | ||||||||||||||||||||||||||||
| 53 | lazy => 1, | ||||||||||||||||||||||||||||
| 54 | builder => 1, | ||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | sub _build_custom_image_url { | ||||||||||||||||||||||||||||
| 58 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_custom_image_url: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 1 | return sprintf '%s/badge/cpantesters/%s/%s', $self->base_url, $self->dist, $self->version; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 2 | has _meta => ( | |||||||||||||||||||||||||||
| 62 | is => 'ro', | ||||||||||||||||||||||||||||
| 63 | isa => HashRef, | ||||||||||||||||||||||||||||
| 64 | traits => ['Hash'], | ||||||||||||||||||||||||||||
| 65 | lazy => 1, | ||||||||||||||||||||||||||||
| 66 | predicate => 'has_meta', | ||||||||||||||||||||||||||||
| 67 | builder => '_build_meta', | ||||||||||||||||||||||||||||
| 68 | handles => { | ||||||||||||||||||||||||||||
| 69 | get_meta => 'get', | ||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | sub _build_meta { | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_meta: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if($self->has_zilla) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | return { | ||||||||||||||||||||||||||||
| 78 | 0 | dist => $self->zilla->name, | |||||||||||||||||||||||||||
| 79 | version => $self->zilla->version, | ||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | return {} if !path('META.json')->exists; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | my $json = path('META.json')->slurp_utf8; | |||||||||||||||||||||||||||
| 86 | 0 | my $data = decode_json($json); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return {} if !exists $data->{'name'} || !exists $data->{'version'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $data->{"name"} and exists $data->{"version"}
MC/DC0%0/2
exists $data->{"name"} and exists $data->{"version"}
exists $data->{"name"}
exists $data->{"version"}
Truth table0%0/3
A and B
A= exists $data->{"name"}B= exists $data->{"version"}
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | return { | ||||||||||||||||||||||||||||
| 91 | dist => $data->{'name'}, | ||||||||||||||||||||||||||||
| 92 | 0 | version => $data->{'version'}, | |||||||||||||||||||||||||||
| 93 | }; | ||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | sub BUILD { | ||||||||||||||||||||||||||||
| 97 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 98 | 1 | ▶ | $self->link_url(sprintf 'http://matrix.cpantesters.org/?dist=%s %s', $self->dist, $self->version eq 'latest' ? '' : $self->version); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 1 | $self->image_url($self->custom_image_url); | |||||||||||||||||||||||||||
| 100 | 1 | $self->image_alt('CPAN Testers result'); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | 1; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | __END__ | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =pod | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head1 NAME | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | Badge::Depot::Plugin::Cpantesters - CPAN testers plugin for Badge::Depot | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =begin html | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | <p> | ||||||||||||||||||||||||||||
| 122 | <img src="https://img.shields.io/badge/perl-5.10+-blue.svg" alt="Requires Perl 5.10+" /> | ||||||||||||||||||||||||||||
| 123 | <a href="https://travis-ci.org/Csson/p5-Badge-Depot-Plugin-CpanTesters"><img src="https://api.travis-ci.org/Csson/p5-Badge-Depot-Plugin-CpanTesters.svg?branch=master" alt="Travis status" /></a> | ||||||||||||||||||||||||||||
| 124 | <a href="http://cpants.cpanauthors.org/dist/Badge-Depot-Plugin-Cpantesters-0.0101"><img src="https://badgedepot.code301.com/badge/kwalitee/Badge-Depot-Plugin-Cpantesters/0.0101" alt="Distribution kwalitee" /></a> | ||||||||||||||||||||||||||||
| 125 | <a href="http://matrix.cpantesters.org/?dist=Badge-Depot-Plugin-Cpantesters%200.0101"><img src="https://badgedepot.code301.com/badge/cpantesters/Badge-Depot-Plugin-Cpantesters/0.0101" alt="CPAN Testers result" /></a> | ||||||||||||||||||||||||||||
| 126 | <img src="https://img.shields.io/badge/coverage-70.6%-red.svg" alt="coverage 70.6%" /> | ||||||||||||||||||||||||||||
| 127 | </p> | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =end html | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =head1 VERSION | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | Version 0.0101, released 2016-02-22. | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | If used standalone: | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | use Badge::Depot::Plugin::Cpantesters; | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | my $badge = Badge::Depot::Plugin::Cpantesters->new(dist => 'The-Dist', version => '0.1002'); | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | print $badge->to_html; | ||||||||||||||||||||||||||||
| 144 | # prints: | ||||||||||||||||||||||||||||
| 145 | <a href="http://matrix.cpantesters.org/?dist=The-Dist%200.1002"> | ||||||||||||||||||||||||||||
| 146 | <img src="https://badgedepot.code301.com/badge/cpantesters/The-Dist/0.1002" alt="CPAN Testers result" /> | ||||||||||||||||||||||||||||
| 147 | </a> | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | If used with L<Pod::Weaver::Section::Badges>, in weaver.ini: | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | [Badges] | ||||||||||||||||||||||||||||
| 152 | ; other settings | ||||||||||||||||||||||||||||
| 153 | badge = cpantesters | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | Creates a L<CpanTesters|http://cpantesters.org> badge for a distribution. | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | This class consumes the L<Badge::Depot> role. | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | This badge tries to use distribution meta data to set the attributes. If that is available no attributes need to be set manually. The following checks are made: | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | =over 4 | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =item 1 | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | If the badge is used via L<Pod::Weaver::Section::Badges> during a L<Dist::Zilla> build, then C<version> and C<dist> are set to the values in the Dist::Zilla object. | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =item 2 | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | If there is a C<META.json> in the distribution root then that is used to set C<version> and C<dist>. | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | =back | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | If neither of those are true then C<dist> and C<version> should passed to the constructor. | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =over 4 | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =back | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =head2 dist | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | Distribution name. With dashes, not colons. | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | =head2 version | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | Distribution version. | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =head2 base_url | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | Default: C<https://badgedepot.code301.com> | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | Set this if you wish to use another instance of L<Badge::Depot::App>. | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =over 4 | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | =item * | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | L<Badge::Depot> | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | =item * | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | L<Task::Badge::Depot> | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | =back | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | =head1 SOURCE | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | L<https://github.com/Csson/p5-Badge-Depot-Plugin-CpanTesters> | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | =head1 HOMEPAGE | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | L<https://metacpan.org/release/Badge-Depot-Plugin-Cpantesters> | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | Erik Carlsson <info@code301.com> | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | This software is copyright (c) 2016 by Erik Carlsson. | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 230 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||||||||||