| 1 | package XML::Atom::Syndication::Thing; | ||||||||||||||||||||
| 2 | 22 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 22 | ▶ | use base qw( XML::Atom::Syndication::Object ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 22 | ▶ | use Symbol; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 22 | ▶ | use XML::Elemental; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 22 | XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Person', | |||||||||||||||||||
| 10 | 'author', 'contributor'); | ||||||||||||||||||||
| 11 | 22 | XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Link', | |||||||||||||||||||
| 12 | 'link'); | ||||||||||||||||||||
| 13 | 22 | XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Category', | |||||||||||||||||||
| 14 | 'category'); | ||||||||||||||||||||
| 15 | 22 | XML::Atom::Syndication::Thing->mk_accessors('XML::Atom::Syndication::Text', | |||||||||||||||||||
| 16 | 'rights', 'title'); | ||||||||||||||||||||
| 17 | 22 | XML::Atom::Syndication::Thing->mk_accessors('element', 'id', 'updated'); | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 202 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: called CC=11 SCAR=26.2
Pod
undocumented
| |||||||||||||||||||||
| 20 | 202 | my $thing = shift; | |||||||||||||||||||
| 21 | 202 | ▶ | my %param = @_ == 1 ? (Stream => $_[0]) : @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 202 | $thing->set_ns(\%param); | |||||||||||||||||||
| 23 | 202 | ▶ | if (%param) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 191 | ▶ | if (my $stream = $param{Stream}) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 25 | 113 | my $parser = XML::Elemental->parser; | |||||||||||||||||||
| 26 | 113 | ▶ | if (ref($stream) eq 'SCALAR') { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 27 | 0 | $thing->{doc} = $parser->parse_string($$stream); | |||||||||||||||||||
| 28 | ▶ | } 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
| |||||||||||||||||||||
| 29 | 113 | my $xml; | |||||||||||||||||||
| 30 | my $fh; | ||||||||||||||||||||
| 31 | 113 | ▶ | unless (ref $stream eq 'GLOB') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 0 | $fh = gensym(); | |||||||||||||||||||
| 33 | 0 | ▶ | open $fh, $stream or die $!; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||
| 35 | 113 | $fh = $stream; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | 113 | { local $/; $xml = <$fh>; } | |||||||||||||||||||
| 38 | 113 | ▶ | close $fh unless (ref $stream eq 'GLOB'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 113 | $thing->{doc} = $parser->parse_string($xml); | |||||||||||||||||||
| 40 | } else { | ||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | 113 | $thing->{elem} = $thing->{doc}->contents->[0]; | |||||||||||||||||||
| 44 | } elsif ($param{Elem}) { | ||||||||||||||||||||
| 45 | 78 | $thing->{elem} = $param{Elem}; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | } else { | ||||||||||||||||||||
| 48 | 11 | require XML::Elemental::Element; | |||||||||||||||||||
| 49 | 11 | $thing->{elem} = XML::Elemental::Element->new; | |||||||||||||||||||
| 50 | 11 | $thing->{elem}->name('{' . $thing->ns . '}' . $thing->element_name); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | 202 | $thing; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 3 | ▶ | sub inner_atom { | ||||||||||||||||||
|
Subroutine
inner_atom: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 56 | 3 | my ($thing, $str) = @_; | |||||||||||||||||||
| 57 | 3 | my $name = $thing->element_name; | |||||||||||||||||||
| 58 | 3 | my $ns = $thing->ns; | |||||||||||||||||||
| 59 | 3 | my $parser = XML::Elemental->parser; | |||||||||||||||||||
| 60 | 3 | my $doc = $parser->parse_string("<$name xmlns='$ns'>$str</$name>"); | |||||||||||||||||||
| 61 | 3 | my $pseudo = $doc->contents->[0]; | |||||||||||||||||||
| 62 | 3 | my $parent = $thing->elem; | |||||||||||||||||||
| 63 | 3 | $_->parent($parent) for @{$pseudo->contents}; | |||||||||||||||||||
| 64 | 3 | $parent->contents($pseudo->contents); | |||||||||||||||||||
| 65 | 3 | $pseudo->contents([]); | |||||||||||||||||||
| 66 | 3 | 1; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 22 | 1; | |||||||||||||||||||