| 1 | #ABSTRACT: XML Sitemap Google extension video entry | ||||||||||||||||||||||||||||
| 2 | 22 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 22 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | package WWW::Sitemap::XML::Google::Video; | ||||||||||||||||||||||||||||
| 5 | 22 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 22 | $WWW::Sitemap::XML::Google::Video::AUTHORITY = 'cpan:AJGB'; | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | 22 | $WWW::Sitemap::XML::Google::Video::VERSION = '2.02'; | |||||||||||||||||||||||||||
| 9 | 22 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 22 | ▶ | use WWW::Sitemap::XML::Types qw( Location VideoPlayer Max100CharsStr Max2048CharsStr ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 22 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 22 | has 'content_loc' => ( | |||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||
| 17 | isa => Location, | ||||||||||||||||||||||||||||
| 18 | coerce => 1, | ||||||||||||||||||||||||||||
| 19 | predicate => 'has_content_loc', | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 22 | has 'player' => ( | |||||||||||||||||||||||||||
| 24 | is => 'rw', | ||||||||||||||||||||||||||||
| 25 | isa => VideoPlayer, | ||||||||||||||||||||||||||||
| 26 | required => 0, | ||||||||||||||||||||||||||||
| 27 | coerce => 1, | ||||||||||||||||||||||||||||
| 28 | predicate => 'has_player', | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 22 | has 'title' => ( | |||||||||||||||||||||||||||
| 33 | is => 'rw', | ||||||||||||||||||||||||||||
| 34 | isa => Max100CharsStr, | ||||||||||||||||||||||||||||
| 35 | required => 1, | ||||||||||||||||||||||||||||
| 36 | predicate => 'has_title', | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 22 | has 'description' => ( | |||||||||||||||||||||||||||
| 41 | is => 'rw', | ||||||||||||||||||||||||||||
| 42 | isa => Max2048CharsStr, | ||||||||||||||||||||||||||||
| 43 | required => 1, | ||||||||||||||||||||||||||||
| 44 | predicate => 'has_description', | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 22 | has 'thumbnail_loc' => ( | |||||||||||||||||||||||||||
| 49 | is => 'rw', | ||||||||||||||||||||||||||||
| 50 | isa => Location, | ||||||||||||||||||||||||||||
| 51 | required => 1, | ||||||||||||||||||||||||||||
| 52 | predicate => 'has_thumbnail_loc', | ||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub as_xml { | ||||||||||||||||||||||||||
|
Subroutine
as_xml: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | my $video = XML::LibXML::Element->new('video:video'); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | do { | ||||||||||||||||||||||||||||
| 62 | 0 | my $name = $_; | |||||||||||||||||||||||||||
| 63 | 0 | my $e = XML::LibXML::Element->new("video:$name"); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | $e->appendText( $self->$name ); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | $video->appendChild( $e ); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | } for 'content_loc',grep { | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | eval('$self->has_'.$_) || defined $self->$_() | ||||||||||||||||||||||||||
|
Condition0%0/3
eval '$self->has_' . $_ || defined $self->$_
MC/DC0%0/2
eval '$self->has_' . $_ || defined $self->$_
eval '$self->has_' . $_
defined $self->$_
Truth table0%0/3
A || B
A= eval '$self->has_' . $_B= defined $self->$_
| |||||||||||||||||||||||||||||
| 71 | } qw( title description thumbnail_loc ); | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( $self->has_player) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | $video->appendChild( $self->player->as_xml ); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | return $video; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 4 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||
| 81 | 4 | my $next = shift; | |||||||||||||||||||||||||||
| 82 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 4 | ▶ | if ( @_ == 1 && ! ref $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and not ref $_[0]
MC/DC0%0/2
@_ == 1 and not ref $_[0]
@_ == 1
not ref $_[0]
Truth table33%1/3
A and not(B)
A= @_ == 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 85 | 0 | return $class->$next(content_loc => $_[0]); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 4 | return $class->$next( @_ ); | |||||||||||||||||||||||||||
| 89 | 22 | }; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 22 | with 'WWW::Sitemap::XML::Google::Video::Interface'; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 22 | 1; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | __END__ | ||||||||||||||||||||||||||||