| 1 | package XML::Feed::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 ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 35 | ▶ | use XML::Atom::Feed; | ||||||||||||||||||||||||||
|
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 List::Util qw( first ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 35 | ▶ | use HTML::Entities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 35 | ▶ | use XML::Atom::Entry; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 35 | XML::Atom::Entry->mk_elem_accessors(qw( lat long ), ['http://www.w3.org/2003/01/geo/wgs84_pos#']); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 35 | ▶ | use XML::Atom::Content; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 35 | ▶ | use XML::Feed::Entry::Format::Atom; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 36 | ▶ | sub identify { | ||||||||||||||||||||||||||
|
Subroutine
identify: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 36 | my $class = shift; | |||||||||||||||||||||||||||
| 22 | 36 | my $xml = shift; | |||||||||||||||||||||||||||
| 23 | 36 | my $tag = $class->_get_first_tag($xml); | |||||||||||||||||||||||||||
| 24 | 36 | return ($tag eq 'feed'); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 7 | ▶ | sub init_empty { | ||||||||||||||||||||||||||
|
Subroutine
init_empty: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 7 | my ($feed, %args) = @_; | |||||||||||||||||||||||||||
| 30 | 7 | ▶ | $args{'Version'} //= '1.0'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{"Version"} //= "1.0"
MC/DC0%0/1
$args{"Version"} //= "1.0"
$args{"Version"}
Truth table50%1/2
A
A= $args{"Version"}
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 7 | $feed->{atom} = XML::Atom::Feed->new(%args); | |||||||||||||||||||||||||||
| 33 | 7 | $feed; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 18 | ▶ | sub init_string { | ||||||||||||||||||||||||||
|
Subroutine
init_string: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 18 | my $feed = shift; | |||||||||||||||||||||||||||
| 38 | 18 | my($str) = @_; | |||||||||||||||||||||||||||
| 39 | 18 | ▶ | if ($str) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 18 | ▶ | $feed->{atom} = XML::Atom::Feed->new(Stream => $str) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | or return $feed->error(XML::Atom::Feed->errstr); | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 18 | $feed; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | ▶ | sub format { 'Atom' } | ||||||||||||||||||||||||||
|
Subroutine
format: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 16 | ▶ | sub title { shift->{atom}->title(@_) } | ||||||||||||||||||||||||||
|
Subroutine
title: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 12 | ▶ | sub link { | ||||||||||||||||||||||||||
|
Subroutine
link: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 12 | my $feed = shift; | |||||||||||||||||||||||||||
| 51 | 12 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 5 | $feed->{atom}->add_link({ rel => 'alternate', href => $_[0], | |||||||||||||||||||||||||||
| 53 | type => 'text/html', }); | ||||||||||||||||||||||||||||
| 54 | } else { | ||||||||||||||||||||||||||||
| 55 | 7 | ▶ | my $l = first { !defined $_->rel || $_->rel eq 'alternate' } $feed->{atom}->link; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 7 | ▶ | $l ? $l->href : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 8 | ▶ | sub _rel_link { | ||||||||||||||||||||||||||
|
Subroutine
_rel_link: called CC=4 SCAR=22.4
| |||||||||||||||||||||||||||||
| 61 | 8 | my $feed = shift; | |||||||||||||||||||||||||||
| 62 | 8 | my $rel = shift; | |||||||||||||||||||||||||||
| 63 | 8 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 8 | my $uri = shift; | |||||||||||||||||||||||||||
| 65 | 8 | $feed->{atom}->add_link({type => "application/atom+xml", rel => $rel, href => $uri}); | |||||||||||||||||||||||||||
| 66 | 8 | return $uri; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | else | ||||||||||||||||||||||||||||
| 69 | { | ||||||||||||||||||||||||||||
| 70 | 0 | my $l; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($rel eq 'self') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | $l = first | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | { !defined $_->rel || $_->rel eq 'self' } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | $feed->{atom}->link; | |||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||||
| 77 | $l = first | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | { !defined $_->rel || $_->rel eq $rel } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | $feed->{atom}->link; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return $l ? $l->href : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1 | ▶ | sub self_link { shift->_rel_link( 'self', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
self_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 87 | 1 | ▶ | sub first_link { shift->_rel_link( 'first', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
first_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 1 | ▶ | sub last_link { shift->_rel_link( 'last', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
last_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub next_link { shift->_rel_link( 'next', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
next_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 1 | ▶ | sub previous_link { shift->_rel_link( 'previous', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
previous_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 1 | ▶ | sub current_link { shift->_rel_link( 'current', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
current_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | sub prev_archive_link { shift->_rel_link( 'prev-archive', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
prev_archive_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 1 | ▶ | sub next_archive_link { shift->_rel_link( 'next-archive', @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
next_archive_link: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 14 | ▶ | sub description { shift->{atom}->tagline(@_) } | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 5 | ▶ | sub copyright { shift->{atom}->copyright(@_) } | ||||||||||||||||||||||||||
|
Subroutine
copyright: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 6 | ▶ | sub language { shift->{atom}->language(@_) } | ||||||||||||||||||||||||||
|
Subroutine
language: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | 5 | ▶ | sub generator { shift->{atom}->generator(@_) } | ||||||||||||||||||||||||||
|
Subroutine
generator: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 2 | ▶ | sub id { shift->{atom}->id(@_) } | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub updated { shift->modified(@_) } | ||||||||||||||||||||||||||
|
Subroutine
updated: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub add_link { shift->{atom}->add_link(@_) } | ||||||||||||||||||||||||||
|
Subroutine
add_link: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 102 | 4 | ▶ | sub base { shift->{atom}->base(@_) } | ||||||||||||||||||||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 6 | ▶ | sub author { | ||||||||||||||||||||||||||
|
Subroutine
author: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 6 | my $feed = shift; | |||||||||||||||||||||||||||
| 106 | 6 | ▶ | 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]
| |||||||||||||||||||||||||||||
| 107 | 2 | my $person = XML::Atom::Person->new(Version => 1.0); | |||||||||||||||||||||||||||
| 108 | 2 | $person->name($_[0]); | |||||||||||||||||||||||||||
| 109 | 2 | $feed->{atom}->author($person); | |||||||||||||||||||||||||||
| 110 | } else { | ||||||||||||||||||||||||||||
| 111 | 4 | ▶ | $feed->{atom}->author ? $feed->{atom}->author->name : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub image { | ||||||||||||||||||||||||||
|
Subroutine
image: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 116 | 0 | return; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 9 | ▶ | sub modified { | ||||||||||||||||||||||||||
|
Subroutine
modified: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 9 | my $feed = shift; | |||||||||||||||||||||||||||
| 121 | 9 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 3 | $feed->{atom}->modified(format_w3cdtf($_[0])); | |||||||||||||||||||||||||||
| 123 | } else { | ||||||||||||||||||||||||||||
| 124 | 6 | ▶ | parse_datetime($feed->{atom}->modified || $feed->{atom}->updated); | ||||||||||||||||||||||||||
|
Condition66%2/3
$feed->{'atom'}->modified || $feed->{'atom'}->updated
MC/DC50%1/2
$feed->{'atom'}->modified || $feed->{'atom'}->updated
$feed->{'atom'}->modified
$feed->{'atom'}->updated
Truth table66%2/3
A || B
A= $feed->{'atom'}->modifiedB= $feed->{'atom'}->updated
| |||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 19 | ▶ | sub entries { | ||||||||||||||||||||||||||
|
Subroutine
entries: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 19 | my @entries; | |||||||||||||||||||||||||||
| 130 | 19 | for my $entry ($_[0]->{atom}->entries) { | |||||||||||||||||||||||||||
| 131 | 26 | push @entries, XML::Feed::Entry::Format::Atom->wrap($entry); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 19 | @entries; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 8 | ▶ | sub add_entry { | ||||||||||||||||||||||||||
|
Subroutine
add_entry: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 138 | 8 | my $feed = shift; | |||||||||||||||||||||||||||
| 139 | 8 | ▶ | my $entry = shift || return; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 140 | 8 | $entry = $feed->_convert_entry($entry); | |||||||||||||||||||||||||||
| 141 | 8 | $feed->{atom}->add_entry($entry->unwrap); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 16 | ▶ | sub as_xml { $_[0]->{atom}->as_xml } | ||||||||||||||||||||||||||
|
Subroutine
as_xml: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 35 | 1; | |||||||||||||||||||||||||||