| 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
| |||||||||||||||||||||
| 20 | 197 | $thing->set_ns(\%param); | |||||||||||||||||||
| 21 | 197 | ▶ | if (%param) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 186 | ▶ | if (my $stream = $param{Stream}) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 23 | 110 | my $parser = XML::Elemental->parser; | |||||||||||||||||||
| 24 | 110 | ▶ | if (ref($stream) eq 'SCALAR') { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 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
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
| |||||||||||||||||||||
| 27 | 110 | my $xml; | |||||||||||||||||||
| 28 | my $fh; | ||||||||||||||||||||
| 29 | 110 | ▶ | unless (ref $stream eq 'GLOB') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 0 | $fh = gensym(); | |||||||||||||||||||
| 31 | 0 | ▶ | open $fh, $stream or die $!; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | } else { | ||||||||||||||||||||
| 33 | 110 | $fh = $stream; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | 110 | { local $/; $xml = <$fh>; } | |||||||||||||||||||
| 36 | 110 | ▶ | close $fh unless (ref $stream eq 'GLOB'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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; | |||||||||||||||||||