| 1 | package XML::FeedWriter::RSS20; | ||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base qw( XML::FeedWriter::Base ); | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||
| 8 | 1 | __PACKAGE__->_alias({ | |||||||||||||||||||||||||
| 9 | creator => 'dc:creator', | ||||||||||||||||||||||||||
| 10 | pubdate => 'pubDate', | ||||||||||||||||||||||||||
| 11 | published => 'pubDate', | ||||||||||||||||||||||||||
| 12 | lastbuilddate => 'lastBuildDate', | ||||||||||||||||||||||||||
| 13 | updated => 'lastBuildDate', | ||||||||||||||||||||||||||
| 14 | webmaster => 'webMaster', | ||||||||||||||||||||||||||
| 15 | managingeditor => 'managingEditor', | ||||||||||||||||||||||||||
| 16 | editor => 'managingEditor', | ||||||||||||||||||||||||||
| 17 | content => 'content:encoded', | ||||||||||||||||||||||||||
| 18 | summary => 'description', | ||||||||||||||||||||||||||
| 19 | }); | ||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||
| 21 | 1 | __PACKAGE__->_requires({ | |||||||||||||||||||||||||
| 22 | channel => [qw( description link title )], | ||||||||||||||||||||||||||
| 23 | cloud => [qw( domain path port protocol registerProcedure )], | ||||||||||||||||||||||||||
| 24 | image => [qw( link title url )], | ||||||||||||||||||||||||||
| 25 | textinput => [qw( description link name title )], | ||||||||||||||||||||||||||
| 26 | enclosure => [qw( length type url )], | ||||||||||||||||||||||||||
| 27 | }); | ||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||
| 29 | 1 | __PACKAGE__->_sort_order({ | |||||||||||||||||||||||||
| 30 | title => 10, | ||||||||||||||||||||||||||
| 31 | link => 9, | ||||||||||||||||||||||||||
| 32 | description => 8, | ||||||||||||||||||||||||||
| 33 | creator => 7, | ||||||||||||||||||||||||||
| 34 | author => 7, | ||||||||||||||||||||||||||
| 35 | pubDate => 6, | ||||||||||||||||||||||||||
| 36 | guid => 5, | ||||||||||||||||||||||||||
| 37 | }); | ||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub _extra_options { | ||||||||||||||||||||||||
|
Subroutine
_extra_options: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||
| 40 | 0 | my ($self, $options) = @_; | |||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||
| 42 | 0 | my $no_cdata = delete $options->{no_cdata}; | |||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||
| 44 | 0 | $self->{_use_cdata} = !$no_cdata; | |||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub _root_element { | ||||||||||||||||||||||||
|
Subroutine
_root_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||
| 48 | 0 | my ($self, $modules) = @_; | |||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||
| 50 | $self->xml->startTag( rss => | ||||||||||||||||||||||||||
| 51 | version => '2.0', | ||||||||||||||||||||||||||
| 52 | 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', | ||||||||||||||||||||||||||
| 53 | 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', | ||||||||||||||||||||||||||
| 54 | 0 | %{ $modules }, | |||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub _channel { | ||||||||||||||||||||||||
|
Subroutine
_channel: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||
| 59 | 0 | my ($self, $channel) = @_; | |||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||
| 61 | 0 | ▶ | $channel->{lastBuildDate} ||= $self->dtx->for_rss20; | ||||||||||||||||||||||||
|
Condition0%0/3
$channel->{"lastBuildDate"} ||= $self->dtx->for_rss20
MC/DC0%0/2
$channel->{"lastBuildDate"} ||= $self->dtx->for_rss20
$channel->{"lastBuildDate"}
$self->dtx->for_rss20
Truth table0%0/3
A ||= B
A= $channel->{"lastBuildDate"}B= $self->dtx->for_rss20
| |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||
| 63 | 0 | $self->xml->startTag('channel'); | |||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||
| 65 | 0 | foreach my $key ( $self->_sort_keys( $channel ) ) { | |||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ( $key eq 'category' ) { | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 68 | 0 | $self->_duplicable_elements( $key => $channel->{$key} ); | |||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||
| 71 | elsif ( $key eq 'cloud' ) { | ||||||||||||||||||||||||||
| 72 | 0 | $self->_empty_element( $key => $channel->{$key} ); | |||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||
| 75 | elsif ( $key =~ /image|textinput/ ) { | ||||||||||||||||||||||||||
| 76 | 0 | $self->_element_with_children( $key => $channel->{$key} ); | |||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||
| 79 | elsif ( $key =~ /lastBuildDate|pubDate/ ) { | ||||||||||||||||||||||||||
| 80 | 0 | $self->_datetime_element( $key => $channel->{$key} ); | |||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||
| 83 | elsif ( my ($type) = $key =~ /skip(Day|Hour)s/ ) { | ||||||||||||||||||||||||||
| 84 | $self->_element_with_duplicable_children( | ||||||||||||||||||||||||||
| 85 | 0 | $key => $channel->{$key}, lc $type | |||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||
| 89 | else { | ||||||||||||||||||||||||||
| 90 | 0 | $self->_data_element( $key => $channel->{$key} ); | |||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub add_items { | ||||||||||||||||||||||||
|
Subroutine
add_items: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||
| 96 | 0 | my ($self, @items) = @_; | |||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | croak "can't add items any longer" if $self->_closed; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||
| 100 | 0 | foreach my $i ( @items ) { | |||||||||||||||||||||||||
| 101 | 0 | my %item = $self->_canonize( $i ); | |||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||
| 103 | 0 | $self->xml->startTag('item'); | |||||||||||||||||||||||||
| 104 | 0 | foreach my $key ( $self->_sort_keys( \%item ) ) { | |||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ( $key eq 'pubDate' ) { | ||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||
| 107 | 0 | $self->_datetime_element( $key => $item{$key} ); | |||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||
| 110 | elsif ( $key eq 'description' ) { | ||||||||||||||||||||||||||
| 111 | 0 | $self->_cdata_element( $key => $item{$key} ); | |||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||
| 114 | elsif ( $key eq 'enclosure' ) { | ||||||||||||||||||||||||||
| 115 | 0 | $self->_empty_element( $key => $item{$key} ); | |||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||
| 118 | elsif ( $key eq 'category' ) { | ||||||||||||||||||||||||||
| 119 | 0 | $self->_duplicable_elements( $key => $item{$key} ); | |||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||
| 122 | else { | ||||||||||||||||||||||||||
| 123 | 0 | $self->_data_element( $key => $item{$key} ); | |||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||
| 126 | 0 | $self->xml->endTag('item'); | |||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub close { | ||||||||||||||||||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||
| 131 | 0 | my $self = shift; | |||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||
| 133 | 0 | ▶ | return if $self->_closed; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||
| 135 | 0 | $self->xml->endTag('channel'); | |||||||||||||||||||||||||
| 136 | 0 | $self->xml->endTag('rss'); | |||||||||||||||||||||||||
| 137 | 0 | $self->xml->end; | |||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||
| 139 | 0 | $self->_closed(1); | |||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||
| 142 | 1 | 1; | |||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||||||||