| 1 | #ABSTRACT: XML Sitemap url entry | ||||||||||||||||||||||||||||
| 2 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | package WWW::Sitemap::XML::URL; | ||||||||||||||||||||||||||||
| 5 | 15 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 15 | $WWW::Sitemap::XML::URL::AUTHORITY = 'cpan:AJGB'; | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | 15 | $WWW::Sitemap::XML::URL::VERSION = '2.02'; | |||||||||||||||||||||||||||
| 9 | 15 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use WWW::Sitemap::XML::Types qw( Location ChangeFreq Priority ArrayRefOfImageObjects ArrayRefOfVideoObjects ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use MooseX::Types::DateTime::W3C qw( DateTimeW3C ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 15 | ▶ | use WWW::Sitemap::XML::Google::Image; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 15 | ▶ | use WWW::Sitemap::XML::Google::Video; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 15 | has 'loc' => ( | |||||||||||||||||||||||||||
| 19 | is => 'rw', | ||||||||||||||||||||||||||||
| 20 | isa => Location, | ||||||||||||||||||||||||||||
| 21 | required => 1, | ||||||||||||||||||||||||||||
| 22 | coerce => 1, | ||||||||||||||||||||||||||||
| 23 | predicate => 'has_loc', | ||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 15 | has 'lastmod' => ( | |||||||||||||||||||||||||||
| 28 | is => 'rw', | ||||||||||||||||||||||||||||
| 29 | isa => DateTimeW3C, | ||||||||||||||||||||||||||||
| 30 | required => 0, | ||||||||||||||||||||||||||||
| 31 | coerce => 1, | ||||||||||||||||||||||||||||
| 32 | predicate => 'has_lastmod', | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 15 | has 'changefreq' => ( | |||||||||||||||||||||||||||
| 37 | is => 'rw', | ||||||||||||||||||||||||||||
| 38 | isa => ChangeFreq, | ||||||||||||||||||||||||||||
| 39 | required => 0, | ||||||||||||||||||||||||||||
| 40 | coerce => 1, | ||||||||||||||||||||||||||||
| 41 | predicate => 'has_changefreq', | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 15 | has 'priority' => ( | |||||||||||||||||||||||||||
| 46 | is => 'rw', | ||||||||||||||||||||||||||||
| 47 | isa => Priority, | ||||||||||||||||||||||||||||
| 48 | required => 0, | ||||||||||||||||||||||||||||
| 49 | predicate => 'has_priority', | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 15 | has 'images' => ( | |||||||||||||||||||||||||||
| 54 | is => 'rw', | ||||||||||||||||||||||||||||
| 55 | isa => ArrayRefOfImageObjects, | ||||||||||||||||||||||||||||
| 56 | required => 0, | ||||||||||||||||||||||||||||
| 57 | coerce => 1, | ||||||||||||||||||||||||||||
| 58 | predicate => 'has_images', | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 15 | has 'videos' => ( | |||||||||||||||||||||||||||
| 63 | is => 'rw', | ||||||||||||||||||||||||||||
| 64 | isa => ArrayRefOfVideoObjects, | ||||||||||||||||||||||||||||
| 65 | required => 0, | ||||||||||||||||||||||||||||
| 66 | coerce => 1, | ||||||||||||||||||||||||||||
| 67 | predicate => 'has_videos', | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 15 | has 'mobile' => ( | |||||||||||||||||||||||||||
| 72 | is => 'rw', | ||||||||||||||||||||||||||||
| 73 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 74 | required => 0, | ||||||||||||||||||||||||||||
| 75 | coerce => 0, | ||||||||||||||||||||||||||||
| 76 | predicate => 'has_mobile', | ||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 79 | ▶ | sub as_xml { | ||||||||||||||||||||||||||
|
Subroutine
as_xml: called CC=11 SCAR=32.6
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 79 | my $self = shift; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 79 | my $url = XML::LibXML::Element->new('url'); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | do { | ||||||||||||||||||||||||||||
| 86 | 289 | my $name = $_; | |||||||||||||||||||||||||||
| 87 | 289 | my $e = XML::LibXML::Element->new($name); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 289 | $e->appendText( $self->$name ); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 289 | $url->appendChild( $e ); | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 79 | } for 'loc',grep { | |||||||||||||||||||||||||||
| 94 | 237 | ▶ | eval('$self->has_'.$_) || defined $self->$_() | ||||||||||||||||||||||||||
|
Condition66%2/3
eval '$self->has_' . $_ || defined $self->$_
MC/DC50%1/2
eval '$self->has_' . $_ || defined $self->$_
eval '$self->has_' . $_
defined $self->$_
Truth table66%2/3
A || B
A= eval '$self->has_' . $_B= defined $self->$_
| |||||||||||||||||||||||||||||
| 95 | } qw( lastmod changefreq priority ); | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 79 | ▶ | if ( $self->has_images ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | for my $image ( @{ $self->images || [] } ) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->images || []
MC/DC0%0/1
$self->images || []
$self->images
Truth table0%0/2
A
A= $self->images
| |||||||||||||||||||||||||||||
| 99 | 0 | $url->appendChild( $image->as_xml ); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 79 | ▶ | if ( $self->has_videos ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | for my $video ( @{ $self->videos || [] } ) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->videos || []
MC/DC0%0/1
$self->videos || []
$self->videos
Truth table0%0/2
A
A= $self->videos
| |||||||||||||||||||||||||||||
| 105 | 0 | $url->appendChild( $video->as_xml ); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 79 | ▶ | if ( $self->has_mobile && $self->mobile ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->has_mobile and $self->mobile
MC/DC0%0/2
$self->has_mobile and $self->mobile
$self->has_mobile
$self->mobile
Truth table33%1/3
A and B
A= $self->has_mobileB= $self->mobile
| |||||||||||||||||||||||||||||
| 110 | 0 | my $e = XML::LibXML::Element->new('mobile:mobile'); | |||||||||||||||||||||||||||
| 111 | 0 | $url->appendChild( $e ); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 79 | return $url; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 91 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 118 | 91 | my $next = shift; | |||||||||||||||||||||||||||
| 119 | 91 | my $class = shift; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 91 | ▶ | if ( @_ == 1 && ! ref $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and not ref $_[0]
MC/DC100%2/2
@_ == 1 and not ref $_[0]
@_ == 1
not ref $_[0]
Truth table100%3/3
A and not(B)
A= @_ == 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 122 | 1 | return $class->$next(loc => $_[0]); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 90 | return $class->$next( @_ ); | |||||||||||||||||||||||||||
| 126 | 15 | }; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 15 | with 'WWW::Sitemap::XML::URL::Interface'; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 15 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 15 | 1; | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | __END__ | ||||||||||||||||||||||||||||