| 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::Kwalitee; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # ABSTRACT: Kwalitee badge for Badge::Depot | ||||||||||||||||||||||||||||
| 8 | 2 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||||||||||||||||
| 9 | 2 | our $VERSION = '0.0103'; | |||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||
| 21 | 2 | has author => ( | |||||||||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||||||||||
| 23 | isa => Str, | ||||||||||||||||||||||||||||
| 24 | default => '_', | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | has dist => ( | ||||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||
| 28 | isa => Str, | ||||||||||||||||||||||||||||
| 29 | lazy => 1, | ||||||||||||||||||||||||||||
| 30 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 31 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | 1 | ▶ | if($self->get_meta('dist')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 1 | return $self->_meta->{'dist'}; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||||||||||
| 36 | 2 | ); | |||||||||||||||||||||||||||
| 37 | has version => ( | ||||||||||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||||||||||
| 39 | isa => Str, | ||||||||||||||||||||||||||||
| 40 | lazy => 1, | ||||||||||||||||||||||||||||
| 41 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 42 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 43 | 1 | ▶ | if($self->get_meta('version')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 1 | return $self->_meta->{'version'}; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | }, | ||||||||||||||||||||||||||||
| 47 | 2 | ); | |||||||||||||||||||||||||||
| 48 | 2 | has base_url => ( | |||||||||||||||||||||||||||
| 49 | is => 'ro', | ||||||||||||||||||||||||||||
| 50 | isa => Uri, | ||||||||||||||||||||||||||||
| 51 | coerce => 1, | ||||||||||||||||||||||||||||
| 52 | lazy => 1, | ||||||||||||||||||||||||||||
| 53 | default => 'http://badgedepot.code301.com', | ||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||
| 55 | 2 | has custom_image_url => ( | |||||||||||||||||||||||||||
| 56 | is => 'ro', | ||||||||||||||||||||||||||||
| 57 | isa => Uri, | ||||||||||||||||||||||||||||
| 58 | coerce => 1, | ||||||||||||||||||||||||||||
| 59 | lazy => 1, | ||||||||||||||||||||||||||||
| 60 | builder => 1, | ||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | sub _build_custom_image_url { | ||||||||||||||||||||||||||
|
Subroutine
_build_custom_image_url: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 64 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | 1 | return sprintf '%s/badge/kwalitee/%s/%s/%s', $self->base_url, $self->author, $self->dist, $self->version; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 2 | has _meta => ( | |||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||
| 69 | isa => HashRef, | ||||||||||||||||||||||||||||
| 70 | traits => ['Hash'], | ||||||||||||||||||||||||||||
| 71 | lazy => 1, | ||||||||||||||||||||||||||||
| 72 | predicate => 'has_meta', | ||||||||||||||||||||||||||||
| 73 | builder => '_build_meta', | ||||||||||||||||||||||||||||
| 74 | handles => { | ||||||||||||||||||||||||||||
| 75 | get_meta => 'get', | ||||||||||||||||||||||||||||
| 76 | }, | ||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub _build_meta { | ||||||||||||||||||||||||||
|
Subroutine
_build_meta: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if($self->has_zilla) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | return { | ||||||||||||||||||||||||||||
| 84 | 0 | dist => $self->zilla->name, | |||||||||||||||||||||||||||
| 85 | version => $self->zilla->version, | ||||||||||||||||||||||||||||
| 86 | }; | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return {} if !path('META.json')->exists; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | my $json = path('META.json')->slurp_utf8; | |||||||||||||||||||||||||||
| 92 | 0 | my $data = decode_json($json); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 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"}
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | return { | ||||||||||||||||||||||||||||
| 97 | dist => $data->{'name'}, | ||||||||||||||||||||||||||||
| 98 | 0 | version => $data->{'version'}, | |||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 1 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 104 | 1 | $self->link_url(sprintf 'http://cpants.cpanauthors.org/release/%s/%s-%s', $self->author, $self->dist, $self->version); | |||||||||||||||||||||||||||
| 105 | 1 | $self->image_url($self->custom_image_url); | |||||||||||||||||||||||||||
| 106 | 1 | $self->image_alt('Distribution kwalitee'); | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 2 | 1; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | __END__ | ||||||||||||||||||||||||||||