Syndication/Thing.pm

filter: Statementstmt 90.0% 36 / 40 Branchbran 61.1% 11 / 18 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 76.4% 52 / 68 SCAR 25.0
CC
11
Cov
79%
init
13.7
BEGIN
1.0
BEGIN
1.0
CRAP 12.2
« Syndication/Writer.pm ↑ Summary Syndication/Feed.pm »
1 package XML::Atom::Syndication::Thing;
2 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 21 ▶use base qw( XML::Atom::Syndication::Object );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 21 XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Person',
8 'author', 'contributor');
9 21 XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Link',
10 'link');
11 21 XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Category',
12 'category');
13 21 XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Text',
14 'rights', 'title');
15 21 XML::Atom::Syndication::Thing->mk_accessors('element', 'id', 'updated');
16  
17 sub init {
18 197 ▶ my $thing = shift;
Subroutine init: called CC=11 SCAR=26.2
Pod undocumented
19 197 ▶ my %param = @_ == 1 ? (Stream => $_[0]) : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 110 87 197
20 197 $thing->set_ns(\%param);
21 197 ▶ if (%param) {
Branch: 1 branch
BranchTrueFalseTotal
if (%param) { } 186 11 197
22 186 ▶ if (my $stream = $param{Stream}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $stream = $param{'Stream'}) { } 110 76 186
elsif ($param{'Elem'}) { } 76 0 76
23 110 my $parser = XML::Elemental->parser;
24 110 ▶ if (ref($stream) eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $stream eq 'SCALAR') { } 0 110 110
elsif (ref $stream eq 'GLOB' or not ref $stream) { } 110 0 110
25 0 $thing->{doc} = $parser->parse_string($$stream);
26 ▶ } elsif (ref $stream eq 'GLOB' || !ref($stream)) {
Condition33%1/3
ref $stream eq "GLOB" or not ref $stream
l!l&&r!l&&!r
11000
MC/DC0%0/2
ref $stream eq "GLOB" or not ref $stream
ref $stream eq "GLOB" not ref $stream
Truth table33%1/3
A or not(B)
A= ref $stream eq "GLOB"B= not ref $stream
ABresult
1X1
011
000
27 110 my $xml;
28 my $fh;
29 110 ▶ unless (ref $stream eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $stream eq 'GLOB') { } 110 0 110
30 0 $fh = gensym();
31 0 ▶ open $fh, $stream or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open $fh, $stream or die $! 0 0 0
32 } else {
33 110 $fh = $stream;
34 }
35 110 { local $/; $xml = <$fh>; }
36 110 ▶ close $fh unless (ref $stream eq 'GLOB');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $stream eq "GLOB" 0 110 110
37 110 $thing->{doc} = $parser->parse_string($xml);
38 } else {
39 0 return;
40 }
41 110 $thing->{elem} = $thing->{doc}->contents->[0];
42 } elsif ($param{Elem}) {
43 76 $thing->{elem} = $param{Elem};
44 }
45 } else {
46 11 require XML::Elemental::Element;
47 11 $thing->{elem} = XML::Elemental::Element->new;
48 11 $thing->{elem}->name('{' . $thing->ns . '}' . $thing->element_name);
49 }
50 197 $thing;
51 }
52  
53 21 1;
« Syndication/Writer.pm ↑ Summary Syndication/Feed.pm »