Syndication/Feed.pm

filter: Statementstmt 100% 40 / 40 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 95.0% 58 / 61 SCAR 19.5
CC
7
Cov
94%
insert_entry
4.0
entries
3.0
add_entry
2.0
CRAP 7.0
« Syndication/Thing.pm ↑ Summary Syndication/Util.pm »
1 package XML::Atom::Syndication::Feed;
2 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 21 ▶use base qw( XML::Atom::Syndication::Thing );
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 21 ▶use XML::Atom::Syndication::Util qw( nodelist );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 21 XML::Atom::Syndication::Feed->mk_accessors('element', 'icon', 'logo');
9 21 XML::Atom::Syndication::Feed->mk_accessors('XML::Atom::Syndication::Generator',
10 'generator');
11 21 XML::Atom::Syndication::Feed->mk_accessors('XML::Atom::Syndication::Text',
12 'subtitle');
13  
14 # deprecated 0.3 accessors
15 21 XML::Atom::Syndication::Feed->mk_accessors('attribute', 'version');
16 21 XML::Atom::Syndication::Feed->mk_accessors('element', 'copyright', 'modified',
17 'created');
18 21 XML::Atom::Syndication::Feed->mk_accessors('XML::Atom::Syndication::Text',
19 'tagline', 'info');
20  
21 4 ▶sub element_name { 'feed' }
Subroutine element_name: called CC=1 SCAR=0.0
Pod documented
22  
23 sub add_entry {
24 2 ▶ my ($feed, $entry) = @_;
Subroutine add_entry: called CC=2 SCAR=7.1
Pod documented
25 2 ▶ $entry = $entry->elem if ref $entry eq 'XML::Atom::Syndication::Entry';
Branch: 1 branch
BranchTrueFalseTotal
if ref $entry eq "XML::Atom::Syndication::Entry" 2 0 2
26 2 $feed->set_element($feed->ns, 'entry', $entry, 1);
27 }
28  
29 sub insert_entry {
30 2 ▶ my ($feed, $entry) = @_;
Subroutine insert_entry: called CC=4 SCAR=13.9
Pod documented
31 2 ▶ $entry = $entry->elem if ref $entry eq 'XML::Atom::Syndication::Entry';
Branch: 1 branch
BranchTrueFalseTotal
if ref $entry eq "XML::Atom::Syndication::Entry" 2 0 2
32 2 my ($first) = nodelist($feed, $feed->ns, 'entry');
33 2 ▶ if ($first) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 1 1 2
34 1 my $e = $feed->elem;
35 1 $entry->parent($e);
36 my @new =
37 1 ▶ map { $_ eq $first ? ($entry, $_) : $_ } @{$e->contents};
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $first ? : 1 5 6
38 1 $e->contents(\@new);
39 } else {
40 1 $feed->set_element($feed->ns, 'entry', $entry, 1);
41 }
42 }
43  
44 sub entries { # why? because read_only????
45 67 ▶ my $feed = shift;
Subroutine entries: called CC=3 SCAR=11.0
Pod documented
46 67 my @nodes = nodelist($feed, $feed->ns, 'entry');
47 67 ▶ return unless @nodes;
Branch: 1 branch
BranchTrueFalseTotal
unless @nodes 0 67 67
48 67 my @entries;
49 67 require XML::Atom::Syndication::Entry;
50 67 foreach my $node (@nodes) {
51 76 my $entry =
52 XML::Atom::Syndication::Entry->new(Elem => $node,
53 Namespace => $feed->ns);
54 76 push @entries, $entry;
55 }
56 67 @entries;
57 }
58  
59 21 1;
60  
61 __END__
« Syndication/Thing.pm ↑ Summary Syndication/Util.pm »