| 1 | package XML::Feed::Entry::Format::Atom; | ||||||||||||||||||||||||||||
| 2 | 35 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 35 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 35 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 35 | our $VERSION = '1.0.1'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 35 | ▶ | use base qw( XML::Feed::Entry ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 35 | ▶ | use XML::Feed::Content; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 35 | ▶ | use XML::Feed::Util qw( format_w3cdtf parse_datetime ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 35 | ▶ | use XML::Atom::Entry; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 35 | ▶ | use List::Util qw( first ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | sub init_empty { | ||||||||||||||||||||||||||
|
Subroutine
init_empty: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 8 | my $entry = shift; | |||||||||||||||||||||||||||
| 16 | 8 | $entry->{entry} = XML::Atom::Entry->new(Version => 1.0); | |||||||||||||||||||||||||||
| 17 | 8 | 1; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub format { 'Atom' } | ||||||||||||||||||||||||||
|
Subroutine
format: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 13 | ▶ | sub title { shift->{entry}->title(@_) } | ||||||||||||||||||||||||||
|
Subroutine
title: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub source { shift->{entry}->source(@_) } | ||||||||||||||||||||||||||
|
Subroutine
source: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub updated { shift->modified(@_) } | ||||||||||||||||||||||||||
|
Subroutine
updated: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 4 | ▶ | sub base { shift->{entry}->base(@_) } | ||||||||||||||||||||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 15 | ▶ | sub link { | ||||||||||||||||||||||||||
|
Subroutine
link: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 15 | my $entry = shift; | |||||||||||||||||||||||||||
| 29 | 15 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 6 | $entry->{entry}->add_link({ rel => 'alternate', href => $_[0], | |||||||||||||||||||||||||||
| 31 | type => 'text/html', }); | ||||||||||||||||||||||||||||
| 32 | } else { | ||||||||||||||||||||||||||||
| 33 | 9 | ▶ | my $l = first { !defined $_->rel || $_->rel eq 'alternate' } $entry->{entry}->link; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 9 | ▶ | $l ? $l->href : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 9 | ▶ | sub summary { | ||||||||||||||||||||||||||
|
Subroutine
summary: called CC=9 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 9 | my $entry = shift; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 9 | my %type_correction = ( | |||||||||||||||||||||||||||
| 42 | html => 'text/html', | ||||||||||||||||||||||||||||
| 43 | text => 'text/plain', | ||||||||||||||||||||||||||||
| 44 | xhtml => 'text/html', | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 9 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 3 | my %param; | |||||||||||||||||||||||||||
| 49 | 3 | ▶ | if (ref($_[0]) eq 'XML::Feed::Content') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 2 | %param = (Body => $_[0]->body); | |||||||||||||||||||||||||||
| 51 | } else { | ||||||||||||||||||||||||||||
| 52 | 1 | %param = (Body => $_[0]); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 3 | $entry->{entry}->summary(XML::Atom::Content->new(%param, Version => 1.0)); | |||||||||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||||||||||
| 56 | 6 | my $s = $entry->{entry}->summary; | |||||||||||||||||||||||||||
| 57 | # map Atom types to MIME types | ||||||||||||||||||||||||||||
| 58 | 6 | ▶ | my $type = ($s && ref($s) eq 'XML::Feed::Content') ? $s->type : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$s and ref $s eq "XML::Feed::Content"
MC/DC0%0/2
$s and ref $s eq "XML::Feed::Content"
$s
ref $s eq "XML::Feed::Content"
Truth table66%2/3
A and B
A= $sB= ref $s eq "XML::Feed::Content"
| |||||||||||||||||||||||||||||
| 59 | 6 | ▶ | if ($type and exists $type_correction{$type}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type and exists $type_correction{$type}
MC/DC0%0/2
$type and exists $type_correction{$type}
$type
exists $type_correction{$type}
Truth table33%1/3
A and B
A= $typeB= exists $type_correction{$type}
| |||||||||||||||||||||||||||||
| 60 | 0 | $type = $type_correction{$type}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | 6 | my $body = $s; | |||||||||||||||||||||||||||
| 63 | 6 | ▶ | if (defined $s && ref($s) eq 'XML::Feed::Content') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $s and ref $s eq "XML::Feed::Content"
MC/DC0%0/2
defined $s and ref $s eq "XML::Feed::Content"
defined $s
ref $s eq "XML::Feed::Content"
Truth table66%2/3
A and B
A= defined $sB= ref $s eq "XML::Feed::Content"
| |||||||||||||||||||||||||||||
| 64 | 0 | $body = $s->body; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 6 | XML::Feed::Content->wrap({ type => $type, | |||||||||||||||||||||||||||
| 67 | body => $body }); | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 35 | my %types = ( | |||||||||||||||||||||||||||
| 72 | 'text/xhtml' => 'xhtml', | ||||||||||||||||||||||||||||
| 73 | 'text/html' => 'html', | ||||||||||||||||||||||||||||
| 74 | 'text/plain' => 'text', | ||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 23 | ▶ | sub content { | ||||||||||||||||||||||||||
|
Subroutine
content: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 23 | my $entry = shift; | |||||||||||||||||||||||||||
| 79 | 23 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 7 | return $entry->set_content(@_); | |||||||||||||||||||||||||||
| 81 | } else { | ||||||||||||||||||||||||||||
| 82 | 16 | return $entry->get_content; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 7 | ▶ | sub set_content { | ||||||||||||||||||||||||||
|
Subroutine
set_content: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 7 | my $entry = shift; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 7 | my %param; | |||||||||||||||||||||||||||
| 90 | my $base; | ||||||||||||||||||||||||||||
| 91 | 7 | my $orig_body; | |||||||||||||||||||||||||||
| 92 | 7 | ▶ | if (ref($_[0]) eq 'XML::Feed::Content') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 4 | $orig_body = $_[0]->body; | |||||||||||||||||||||||||||
| 94 | 4 | ▶ | if (defined $_[0]->type && defined $types{$_[0]->type}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0]->type and defined $types{$_[0]->type}
MC/DC0%0/2
defined $_[0]->type and defined $types{$_[0]->type}
defined $_[0]->type
defined $types{$_[0]->type}
Truth table33%1/3
A and B
A= defined $_[0]->typeB= defined $types{$_[0]->type}
| |||||||||||||||||||||||||||||
| 95 | 4 | %param = (Body => $orig_body, Type => $types{$_[0]->type}); | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 4 | ▶ | if ($param{'Type'} eq "html") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 3 | $param{'Body'} = HTML::Entities::encode_entities($param{'Body'}); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | } else { | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | 4 | ▶ | $base = $_[0]->base if defined $_[0]->base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||
| 104 | 3 | $orig_body = $_[0]; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | 7 | ▶ | if (!exists($param{Body})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||
| 108 | 3 | $param{Body} = $orig_body; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 7 | $entry->{entry}->content(XML::Atom::Content->new(%param, Version => 1.0)); | |||||||||||||||||||||||||||
| 111 | # Assigning again so the type will be normalized. This seems to be | ||||||||||||||||||||||||||||
| 112 | # an XML-Atom do-what-I-don't-meannery. | ||||||||||||||||||||||||||||
| 113 | 7 | $entry->{entry}->content->body($orig_body); | |||||||||||||||||||||||||||
| 114 | 7 | ▶ | $entry->{entry}->content->base($base) if defined $base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 16 | ▶ | sub get_content { | ||||||||||||||||||||||||||
|
Subroutine
get_content: called CC=8 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 118 | 16 | my $entry = shift; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 16 | my $c = $entry->{entry}->content; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | # map Atom types to MIME types | ||||||||||||||||||||||||||||
| 123 | 16 | ▶ | my $type = $c ? $c->type : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 16 | ▶ | if ($type) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 16 | ▶ | $type = 'text/html' if $type eq 'xhtml' || $type eq 'html'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type eq "xhtml" or $type eq "html"
MC/DC50%1/2
$type eq "xhtml" or $type eq "html"
$type eq "xhtml"
$type eq "html"
Truth table66%2/3
A or B
A= $type eq "xhtml"B= $type eq "html"
| |||||||||||||||||||||||||||||
| 126 | 16 | ▶ | $type = 'text/plain' if $type eq 'text'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 16 | ▶ | XML::Feed::Content->wrap({ type => $type, | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 130 | base => $c ? $c->base : undef, | ||||||||||||||||||||||||||||
| 131 | body => $c ? $c->body : undef }); | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 16 | ▶ | sub category { | ||||||||||||||||||||||||||
|
Subroutine
category: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | 16 | my $entry = shift; | |||||||||||||||||||||||||||
| 136 | 16 | my $ns = XML::Atom::Namespace->new(dc => 'http://purl.org/dc/elements/1.1/'); | |||||||||||||||||||||||||||
| 137 | 16 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 5 | $entry->{entry}->add_category({ term => $_ }) for @_; | |||||||||||||||||||||||||||
| 139 | 5 | return 1; | |||||||||||||||||||||||||||
| 140 | } else { | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 11 | ▶ | my @category = ($entry->{entry}->can('categories')) ? $entry->{entry}->categories : $entry->{entry}->category; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | my @return = @category | ||||||||||||||||||||||||||||
| 145 | 16 | ▶ | ? (map { $_->label // $_->term } @category) | ||||||||||||||||||||||||||
|
Condition33%1/3
$_->label // $_->term
MC/DC0%0/2
$_->label // $_->term
$_->label
$_->term
Truth table33%1/3
A // B
A= $_->labelB= $_->term
| |||||||||||||||||||||||||||||
| 146 | 11 | ▶ | : $entry->{entry}->getlist($ns, 'subject'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 11 | ▶ | return wantarray? @return : $return[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 10 | ▶ | sub author { | ||||||||||||||||||||||||||
|
Subroutine
author: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 153 | 10 | my $entry = shift; | |||||||||||||||||||||||||||
| 154 | 10 | ▶ | if (@_ && $_[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and $_[0]
MC/DC50%1/2
@_ and $_[0]
@_
$_[0]
Truth table66%2/3
A and B
A= @_B= $_[0]
| |||||||||||||||||||||||||||||
| 155 | 5 | my $person = XML::Atom::Person->new(Version => 1.0); | |||||||||||||||||||||||||||
| 156 | 5 | $person->name($_[0]); | |||||||||||||||||||||||||||
| 157 | 5 | $entry->{entry}->author($person); | |||||||||||||||||||||||||||
| 158 | } else { | ||||||||||||||||||||||||||||
| 159 | 5 | ▶ | $entry->{entry}->author ? $entry->{entry}->author->name : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 16 | ▶ | sub id { shift->{entry}->id(@_) } | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 9 | ▶ | sub issued { | ||||||||||||||||||||||||||
|
Subroutine
issued: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 166 | 9 | my $entry = shift; | |||||||||||||||||||||||||||
| 167 | 9 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 3 | ▶ | $entry->{entry}->issued(format_w3cdtf($_[0])) if $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||
| 170 | 6 | ▶ | parse_datetime($entry->{entry}->issued || $entry->{entry}->published); | ||||||||||||||||||||||||||
|
Condition66%2/3
$entry->{'entry'}->issued || $entry->{'entry'}->published
MC/DC50%1/2
$entry->{'entry'}->issued || $entry->{'entry'}->published
$entry->{'entry'}->issued
$entry->{'entry'}->published
Truth table66%2/3
A || B
A= $entry->{'entry'}->issuedB= $entry->{'entry'}->published
| |||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 11 | ▶ | sub modified { | ||||||||||||||||||||||||||
|
Subroutine
modified: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 175 | 11 | my $entry = shift; | |||||||||||||||||||||||||||
| 176 | 11 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 4 | ▶ | $entry->{entry}->modified(format_w3cdtf($_[0])) if $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | } else { | ||||||||||||||||||||||||||||
| 179 | 7 | ▶ | parse_datetime($entry->{entry}->modified || $entry->{entry}->updated); | ||||||||||||||||||||||||||
|
Condition66%2/3
$entry->{'entry'}->modified || $entry->{'entry'}->updated
MC/DC50%1/2
$entry->{'entry'}->modified || $entry->{'entry'}->updated
$entry->{'entry'}->modified
$entry->{'entry'}->updated
Truth table66%2/3
A || B
A= $entry->{'entry'}->modifiedB= $entry->{'entry'}->updated
| |||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 3 | ▶ | sub lat { | ||||||||||||||||||||||||||
|
Subroutine
lat: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 184 | 3 | my $entry = shift; | |||||||||||||||||||||||||||
| 185 | 3 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | $entry->{entry}->lat($_[0]) if $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | } else { | ||||||||||||||||||||||||||||
| 188 | 3 | $entry->{entry}->lat; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 3 | ▶ | sub long { | ||||||||||||||||||||||||||
|
Subroutine
long: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 193 | 3 | my $entry = shift; | |||||||||||||||||||||||||||
| 194 | 3 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | $entry->{entry}->long($_[0]) if $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | } else { | ||||||||||||||||||||||||||||
| 197 | 3 | $entry->{entry}->long; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 8 | ▶ | sub enclosure { | ||||||||||||||||||||||||||
|
Subroutine
enclosure: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 203 | 8 | my $entry = shift; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 8 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 2 | my $enclosure = shift; | |||||||||||||||||||||||||||
| 207 | 2 | ▶ | my $method = ($XML::Feed::MULTIPLE_ENCLOSURES)? 'add_link' : 'link'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | $entry->{entry}->$method({ rel => 'enclosure', href => $enclosure->{url}, | ||||||||||||||||||||||||||||
| 209 | length => $enclosure->{length}, | ||||||||||||||||||||||||||||
| 210 | 2 | type => $enclosure->{type} }); | |||||||||||||||||||||||||||
| 211 | 2 | return 1; | |||||||||||||||||||||||||||
| 212 | } else { | ||||||||||||||||||||||||||||
| 213 | 6 | ▶ | my @links = grep { defined $_->rel && $_->rel eq 'enclosure' } $entry->{entry}->link; | ||||||||||||||||||||||||||
|
Condition33%1/3
defined $_->rel && $_->rel eq 'enclosure'
MC/DC0%0/2
defined $_->rel && $_->rel eq 'enclosure'
defined $_->rel
$_->rel eq 'enclosure'
Truth table33%1/3
A && B
A= defined $_->relB= $_->rel eq 'enclosure'
| |||||||||||||||||||||||||||||
| 214 | 6 | ▶ | return unless @links; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | my @encs = map { | ||||||||||||||||||||||||||||
| 216 | 6 | XML::Feed::Enclosure->new({ | |||||||||||||||||||||||||||
| 217 | url => $_->href, length => $_->length, type => $_->type | ||||||||||||||||||||||||||||
| 218 | }) | ||||||||||||||||||||||||||||
| 219 | } @links ; | ||||||||||||||||||||||||||||
| 220 | 6 | ▶ | return ($XML::Feed::MULTIPLE_ENCLOSURES)? @encs : $encs[-1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 35 | 1; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||