blib/lib/Statocles/Link.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 88.8% 32 / 36 CC 3 SCAR 7.0
CC
3
Cov
93%
__ANON__
3.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Statocles/Command/deploy.pm ↑ Summary blib/lib/Statocles/Image.pm »
1 package Statocles::Link;
2 101 our $VERSION = '0.099';
3 # ABSTRACT: A link object to build <a> and <link> tags
4  
5 101 ▶use Statocles::Base 'Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 101 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #pod =attr href
9 #pod
10 #pod The URL location being linked to. Sets the C<href> attribute.
11 #pod
12 #pod =cut
13  
14 has href => (
15 is => 'rw',
16 isa => Str,
17 required => 1,
18 144 ▶ coerce => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
19 144 my ( $href ) = @_;
20 144 ▶ if ( blessed $href && $href->isa( 'Mojo::Path' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($href) and $href->isa("Mojo::Path")) 3 141 144
Condition66%2/3
builtin::blessed($href) and $href->isa("Mojo::Path")
!ll&&!rl&&r
14103
MC/DC50%1/2
builtin::blessed($href) and $href->isa("Mojo::Path")
builtin::blessed($href) $href->isa("Mojo::Path")
Truth table66%2/3
A and B
A= builtin::blessed($href)B= $href->isa("Mojo::Path")
ABresult
0X0
100
111
21 3 return $href->to_abs_string;
22 }
23 141 return $href;
24 },
25 101 );
26  
27 #pod =attr text
28 #pod
29 #pod The text inside the link tag. Only useful for <a> links.
30 #pod
31 #pod =cut
32  
33 has text => (
34 is => 'ro',
35 isa => Maybe[Str],
36 lazy => 1,
37 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 # For ease of transition, let's default to title, which we used for the
39 # text prior to this class.
40 0 return $_[0]->title;
41 },
42 101 );
43  
44 #pod =attr title
45 #pod
46 #pod The title of the link. Sets the C<title> attribute.
47 #pod
48 #pod =cut
49  
50 101 has title => (
51 is => 'ro',
52 isa => Str,
53 );
54  
55 #pod =attr rel
56 #pod
57 #pod The relationship of the link. Sets the C<rel> attribute.
58 #pod
59 #pod =cut
60  
61 101 has rel => (
62 is => 'ro',
63 isa => Str,
64 );
65  
66 #pod =attr type
67 #pod
68 #pod The MIME type of the resource being linked to. Sets the C<type> attribute for C<link>
69 #pod tags.
70 #pod
71 #pod =cut
72  
73 101 has type => (
74 is => 'ro',
75 isa => Str,
76 );
77  
78 #pod =method new_from_element
79 #pod
80 #pod my $link = Statocles::Link->new_from_element( $dom_elem );
81 #pod
82 #pod Construct a new Statocles::Link out of a Mojo::DOM element (either an <a> or a <link>).
83 #pod
84 #pod =cut
85  
86 2 ▶sub new_from_element {
Subroutine new_from_element: called CC=1 SCAR=0.0
Pod documented
87 2 my ( $class, $elem ) = @_;
88 return $class->new(
89 2 ( map {; $_ => $elem->attr( $_ ) } grep { $elem->attr( $_ ) } qw( href title rel ) ),
90 2 ( map {; $_ => $elem->$_ } qw( text ) ),
91 );
92 }
93  
94 101 1;
95  
96 __END__
« blib/lib/Statocles/Command/deploy.pm ↑ Summary blib/lib/Statocles/Image.pm »