blib/lib/Badge/Depot.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 8 / 8 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 100% 68 / 68 CC 7 SCAR 8.1
CC
7
Cov
100%
to_markdown
4.0
to_html
3.0
__ANON__
2.0
CRAP 2.2
↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Badge::Depot;
5  
6 # ABSTRACT: A framework for badges
7 2 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
8 2 our $VERSION = '0.0104';
9  
10 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Types::URI qw/Uri/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Types::Standard qw/Str InstanceOf/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use MooseX::AttributeShortcuts;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 has image_url => (
17 is => 'rw',
18 isa => Uri,
19 init_arg => undef,
20 coerce => 1,
21 predicate => 1,
22 );
23 2 has image_alt => (
24 is => 'rw',
25 isa => Str,
26 init_arg => undef,
27 predicate => 1,
28 );
29 2 has link_url => (
30 is => 'rw',
31 isa => Uri,
32 init_arg => undef,
33 coerce => 1,
34 predicate => 1,
35 );
36 2 has zilla => (
37 is => 'ro',
38 isa => InstanceOf['Dist::Zilla'],
39 predicate => 1,
40 );
41  
42  
43 10 ▶around qw/to_html to_markdown/ => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
44 10 my $next = shift;
45 10 my $self = shift;
46  
47 10 ▶ return '' if !$self->has_image_url;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_image_url 2 8 10
48 8 $self->$next;
49 2 };
50  
51 4 ▶sub to_html {
Subroutine to_html: called CC=3 SCAR=11.0
Pod documented
52 4 my $self = shift;
53  
54 4 ▶ my $image_text = $self->has_image_alt ? sprintf ' alt="%s"', $self->image_alt : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->has_image_alt ? : 2 2 4
55  
56 4 ▶ if($self->has_link_url) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_link_url) { } 2 2 4
57 2 return sprintf q{<a href="%s"><img src="%s"%s /></a>}, $self->link_url, $self->image_url, $image_text;
58 }
59 else {
60 2 return sprintf q{<img src="%s"%s />}, $self->image_url, $image_text;
61 }
62 }
63 4 ▶sub to_markdown {
Subroutine to_markdown: called CC=4 SCAR=13.9
Pod documented
64 4 my $self = shift;
65  
66 4 ▶ if($self->has_link_url) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_link_url) { } 2 2 4
67 2 ▶ return sprintf q<[![%s](%s)](%s)>, $self->image_alt // '', $self->image_url, $self->link_url;
Condition100%2/2
$self->image_alt // ""
l!l
11
MC/DC100%1/1
$self->image_alt // ""
$self->image_alt
Truth table100%2/2
A
A= $self->image_alt
Aresult
11
00
68 }
69 else {
70 2 ▶ return sprintf q<![%s](%s)>, $self->image_alt // '', $self->image_url;
Condition100%2/2
$self->image_alt // ""
l!l
11
MC/DC100%1/1
$self->image_alt // ""
$self->image_alt
Truth table100%2/2
A
A= $self->image_alt
Aresult
11
00
71 }
72 }
73  
74 2 1;
75  
76 __END__
↑ Summary