blib/lib/Badge/Depot/Plugin/Kwalitee.pm

filter: Statementstmt 86.6% 52 / 60 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 93.3% 14 / 15 Podpod 0.0% 0 / 1 totaltotal 74.7% 68 / 91 CC 7 SCAR 20.9
CC
7
Cov
74%
_build_meta
30.0
__ANON__
2.0
__ANON__
2.0
CRAP 8.1
↑ Summary
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
BranchTrueFalseTotal
if ($self->get_meta("dist")) 1 0 1
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
BranchTrueFalseTotal
if ($self->get_meta("version")) 1 0 1
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
BranchTrueFalseTotal
if ($self->has_zilla) 0 0 0
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
BranchTrueFalseTotal
unless path("META.json")->exists 0 0 0
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
BranchTrueFalseTotal
unless exists $data->{"name"} and exists $data->{"version"} 0 0 0
Condition0%0/3
exists $data->{"name"} and exists $data->{"version"}
!ll&&!rl&&r
000
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"}
ABresult
0X0
100
111
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__
↑ Summary