| 1 | package XML::Generator::RSS10; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 10 | $XML::Generator::RSS10::VERSION = '0.02'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use base 'XML::SAX::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Params::Validate qw( validate SCALAR ARRAYREF BOOLEAN OBJECT ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use XML::Generator::RSS10::dc; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 10 | ▶ | use XML::Generator::RSS10::sy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 10 | ▶ | use constant NEW_SPEC => { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | modules => { | ||||||||||||||||||||||||||||
| 19 | type => ARRAYREF, | ||||||||||||||||||||||||||||
| 20 | default => [ 'dc', 'sy' ], | ||||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||
| 22 | pretty => { type => BOOLEAN, default => 0 }, | ||||||||||||||||||||||||||||
| 23 | Handler => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 24 | 10 | }; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 28 | 0 | my %p = validate( @_, NEW_SPEC ); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | my %mod; | |||||||||||||||||||||||||||
| 31 | 0 | foreach my $prefix ( @{ delete $p{modules} } ) { | |||||||||||||||||||||||||||
| 32 | 0 | my $package = __PACKAGE__ . "::$prefix"; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | unless ( $package->can('Prefix') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | eval "require $package"; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | $mod{$prefix} = $package; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my $self = bless { | |||||||||||||||||||||||||||
| 43 | %p, | ||||||||||||||||||||||||||||
| 44 | state => {}, | ||||||||||||||||||||||||||||
| 45 | modules => \%mod, | ||||||||||||||||||||||||||||
| 46 | }; | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | $self->{state}{indent} = 0; | |||||||||||||||||||||||||||
| 49 | 0 | $self->{state}{items} = []; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | $self->_start; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | return $self; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 0 | die __PACKAGE__ . " does not implement RSS parsing\n"; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub _start { | ||||||||||||||||||||||||||
|
Subroutine
_start: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | $self->start_document; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | $self->processing_instruction( | |||||||||||||||||||||||||||
| 66 | { Target => 'xml', Data => 'version="1.0"' } ); | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | $self->_declare_namespaces; | |||||||||||||||||||||||||||
| 69 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | $self->_start_element( 'rdf', 'RDF' ); | |||||||||||||||||||||||||||
| 72 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 10 | ▶ | use constant ITEM_SPEC => ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | title => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 77 | link => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 78 | description => { type => SCALAR, optional => 1 }, | ||||||||||||||||||||||||||||
| 79 | 10 | ); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub item { | ||||||||||||||||||||||||||
|
Subroutine
item: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 83 | my %p = validate( | ||||||||||||||||||||||||||||
| 84 | @_, | ||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||
| 86 | ITEM_SPEC, | ||||||||||||||||||||||||||||
| 87 | 0 | map { $_ => { optional => 1 } } | |||||||||||||||||||||||||||
| 88 | 0 | keys %{ $self->{namespace_prefixes} }, | |||||||||||||||||||||||||||
| 89 | }, | ||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | $self->_start_element( | ||||||||||||||||||||||||||||
| 93 | '', 'item', | ||||||||||||||||||||||||||||
| 94 | 0 | [ 'rdf', 'about' => $p{link} ], | |||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||
| 96 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | $self->_contents( \%p, qw( title link ) ); | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | $self->_call_modules( \%p ); | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ( defined $p{description} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | $self->_element_with_cdata( '', 'description', $p{description} ); | |||||||||||||||||||||||||||
| 104 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | $self->_end_element( '', 'item' ); | |||||||||||||||||||||||||||
| 108 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | push @{ $self->{state}{items} }, $p{link}; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 10 | ▶ | use constant IMAGE_SPEC => ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 115 | title => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 116 | link => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 117 | url => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 118 | 10 | ); | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub image { | ||||||||||||||||||||||||||
|
Subroutine
image: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 122 | my %p = validate( | ||||||||||||||||||||||||||||
| 123 | @_, | ||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||
| 125 | IMAGE_SPEC, | ||||||||||||||||||||||||||||
| 126 | 0 | map { $_ => { optional => 1 } } | |||||||||||||||||||||||||||
| 127 | 0 | keys %{ $self->{namespace_prefixes} }, | |||||||||||||||||||||||||||
| 128 | }, | ||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | die "Cannot call image() more than once.\n" | ||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if $self->{state}{image}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | die "Cannot call image() after calling channel().\n" | ||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if $self->{state}{finished}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | $self->_start_element( | ||||||||||||||||||||||||||||
| 138 | '', 'image', | ||||||||||||||||||||||||||||
| 139 | 0 | [ 'rdf', 'about' => $p{url} ], | |||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||
| 141 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | $self->_contents( \%p, qw( title url link ) ); | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | $self->_call_modules( \%p ); | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | $self->{state}{image} = $p{url}; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | $self->_end_element( '', 'image' ); | |||||||||||||||||||||||||||
| 150 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 10 | ▶ | use constant TEXTINPUT_SPEC => ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 154 | title => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 155 | description => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 156 | name => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 157 | url => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 158 | 10 | ); | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub textinput { | ||||||||||||||||||||||||||
|
Subroutine
textinput: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 161 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 162 | my %p = validate( | ||||||||||||||||||||||||||||
| 163 | @_, | ||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||
| 165 | TEXTINPUT_SPEC, | ||||||||||||||||||||||||||||
| 166 | 0 | map { $_ => { optional => 1 } } | |||||||||||||||||||||||||||
| 167 | 0 | keys %{ $self->{namespace_prefixes} }, | |||||||||||||||||||||||||||
| 168 | }, | ||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | die "Cannot call textinput() more than once().\n" | ||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if $self->{state}{textinput}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | die "Cannot call textinput() after calling channel().\n" | ||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if $self->{state}{finished}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | $self->_start_element( | ||||||||||||||||||||||||||||
| 178 | '', 'textinput', | ||||||||||||||||||||||||||||
| 179 | 0 | [ 'rdf', 'about' => $p{url} ], | |||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||
| 181 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 0 | $self->_contents( \%p, qw( title description name url ) ); | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | $self->_call_modules( \%p ); | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | $self->{state}{textinput} = $p{url}; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | $self->_end_element( '', 'textinput' ); | |||||||||||||||||||||||||||
| 190 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 10 | ▶ | use constant CHANNEL_SPEC => ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 194 | title => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 195 | link => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 196 | description => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 197 | 10 | ); | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub channel { | ||||||||||||||||||||||||||
|
Subroutine
channel: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | my %p = validate( | ||||||||||||||||||||||||||||
| 202 | @_, | ||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||
| 204 | CHANNEL_SPEC, | ||||||||||||||||||||||||||||
| 205 | 0 | map { $_ => { optional => 1 } } | |||||||||||||||||||||||||||
| 206 | 0 | keys %{ $self->{namespace_prefixes} }, | |||||||||||||||||||||||||||
| 207 | }, | ||||||||||||||||||||||||||||
| 208 | ); | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | die "Cannot call channel() without any items.\n" | ||||||||||||||||||||||||||||
| 211 | 0 | ▶ | unless @{ $self->{state}{items} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | die "Cannot call channel() more than once.\n" | ||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if $self->{state}{finished}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | $self->_start_element( | ||||||||||||||||||||||||||||
| 217 | '', 'channel', | ||||||||||||||||||||||||||||
| 218 | 0 | [ 'rdf', 'about' => $p{link} ], | |||||||||||||||||||||||||||
| 219 | ); | ||||||||||||||||||||||||||||
| 220 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | $self->_contents( \%p, qw( title link ) ); | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | $self->_element_with_cdata( '', 'description', $p{description} ); | |||||||||||||||||||||||||||
| 225 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | foreach my $elt ( grep { $self->{state}{$_} } qw( image textinput ) ) { | |||||||||||||||||||||||||||
| 228 | $self->_element( | ||||||||||||||||||||||||||||
| 229 | '', $elt, | ||||||||||||||||||||||||||||
| 230 | 0 | [ 'rdf', 'resource' => $self->{state}{$elt} ], | |||||||||||||||||||||||||||
| 231 | ); | ||||||||||||||||||||||||||||
| 232 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | $self->_start_element( '', 'items' ); | |||||||||||||||||||||||||||
| 236 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | $self->_start_element( 'rdf', 'Seq' ); | |||||||||||||||||||||||||||
| 239 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | foreach my $i ( @{ $self->{state}{items} } ) { | |||||||||||||||||||||||||||
| 242 | 0 | $self->_element( | |||||||||||||||||||||||||||
| 243 | 'rdf', 'li', | ||||||||||||||||||||||||||||
| 244 | [ 'rdf', 'resource' => $i ], | ||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||
| 246 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | $self->_end_element( 'rdf', 'Seq' ); | |||||||||||||||||||||||||||
| 250 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | $self->_end_element( '', 'items' ); | |||||||||||||||||||||||||||
| 253 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | $self->_call_modules( \%p ); | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | foreach my $mod ( values %{ $self->{modules} } ) { | |||||||||||||||||||||||||||
| 258 | 0 | ▶ | $mod->channel_hook($self) if $mod->can('channel_hook'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | $self->_end_element( '', 'channel' ); | |||||||||||||||||||||||||||
| 262 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | $self->_finish; | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 0 | $self->{state}{finished} = 1; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub _finish { | ||||||||||||||||||||||||||
|
Subroutine
_finish: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 270 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | $self->_end_element( 'rdf', 'RDF' ); | |||||||||||||||||||||||||||
| 273 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | $self->end_document; | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub _contents { | ||||||||||||||||||||||||||
|
Subroutine
_contents: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 279 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 280 | 0 | my $p = shift; | |||||||||||||||||||||||||||
| 281 | 0 | my @required = @_; | |||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 0 | for my $elt (@required) { | |||||||||||||||||||||||||||
| 284 | 0 | $self->_element_with_data( '', $elt, $p->{$elt} ); | |||||||||||||||||||||||||||
| 285 | 0 | $self->_newline_if_pretty; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub _call_modules { | ||||||||||||||||||||||||||
|
Subroutine
_call_modules: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 290 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 291 | 0 | my $p = shift; | |||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 0 | foreach my $pre ( sort keys %{ $self->{modules} } ) { | |||||||||||||||||||||||||||
| 294 | 0 | ▶ | next unless exists $p->{$pre}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 0 | $self->{modules}{$pre}->contents( $self, $p->{$pre} ); | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 0 | ▶ | sub _element { | ||||||||||||||||||||||||||
|
Subroutine
_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 301 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 0 | $self->_start_element(@_); | |||||||||||||||||||||||||||
| 304 | 0 | $self->_end_element(@_); | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub _element_with_data { | ||||||||||||||||||||||||||
|
Subroutine
_element_with_data: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 308 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 309 | 0 | my $data = pop; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | $self->_start_element(@_); | |||||||||||||||||||||||||||
| 312 | 0 | ▶ | $self->characters( { Data => $data } ) if length $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | 0 | $self->_end_element(@_); | |||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | sub _element_with_cdata { | ||||||||||||||||||||||||||
|
Subroutine
_element_with_cdata: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 317 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 318 | 0 | my $data = pop; | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | $self->_start_element(@_); | |||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ( length $data ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 0 | $self->start_cdata; | |||||||||||||||||||||||||||
| 323 | 0 | $self->characters( { Data => $data } ); | |||||||||||||||||||||||||||
| 324 | 0 | $self->end_cdata; | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | 0 | $self->_end_element(@_); | |||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub _start_element { | ||||||||||||||||||||||||||
|
Subroutine
_start_element: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 330 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 331 | 0 | my ( $name, $prefix ) = ( shift, shift ); | |||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 0 | my %att; | |||||||||||||||||||||||||||
| 334 | 0 | foreach my $a ( grep { @$_ } @_ ) { | |||||||||||||||||||||||||||
| 335 | 0 | my ( $k, $v ) = $self->_rss_att(@$a); | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | $att{$k} = $v; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | $self->ignorable_whitespace( { Data => ' ' x $self->{state}{indent} } ) | ||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if $self->{pretty} && $self->{state}{indent}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"pretty"} and $self->{"state"}{"indent"}
MC/DC0%0/2
$self->{"pretty"} and $self->{"state"}{"indent"}
$self->{"pretty"}
$self->{"state"}{"indent"}
Truth table0%0/3
A and B
A= $self->{"pretty"}B= $self->{"state"}{"indent"}
| |||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 0 | $self->start_element( | |||||||||||||||||||||||||||
| 344 | { | ||||||||||||||||||||||||||||
| 345 | $self->_rss_name_and_prefix( $name, $prefix ), | ||||||||||||||||||||||||||||
| 346 | Attributes => \%att, | ||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | ); | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 0 | $self->{state}{indent}++; | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub _end_element { | ||||||||||||||||||||||||||
|
Subroutine
_end_element: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 354 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ( $self->{pretty} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 357 | 0 | ▶ | unless ( ( caller(1) )[3] =~ /(?:_element|_element_with_c?data)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | $self->ignorable_whitespace( | ||||||||||||||||||||||||||||
| 359 | { Data => ' ' x ( $self->{state}{indent} - 1 ) } ) | ||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if $self->{state}{indent} > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 0 | $self->end_element( { $self->_rss_name_and_prefix(@_) } ); | |||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 0 | $self->{state}{indent}--; | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub _newline_if_pretty { | ||||||||||||||||||||||||||
|
Subroutine
_newline_if_pretty: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $_[0]->ignorable_whitespace( { Data => "\n" } ) if $_[0]->{pretty}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | { | ||||||||||||||||||||||||||||
| 374 | 10 | my %ns = ( | |||||||||||||||||||||||||||
| 375 | '' => 'http://purl.org/rss/1.0/', | ||||||||||||||||||||||||||||
| 376 | rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub _declare_namespaces { | ||||||||||||||||||||||||||
|
Subroutine
_declare_namespaces: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 380 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | ▶ | while ( my ( $p, $uri ) = each %ns ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | 0 | $self->SUPER::start_prefix_mapping( | |||||||||||||||||||||||||||
| 384 | { Prefix => $p, NamespaceURI => $uri } ); | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 0 | $self->{namespace_prefixes}{$p} = $uri; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | foreach my $package ( values %{ $self->{modules} } ) { | |||||||||||||||||||||||||||
| 390 | 0 | my $p = $package->Prefix; | |||||||||||||||||||||||||||
| 391 | 0 | my $uri = $package->NamespaceURI; | |||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | 0 | $self->SUPER::start_prefix_mapping( | |||||||||||||||||||||||||||
| 394 | { Prefix => $p, NamespaceURI => $uri } ); | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 0 | $self->{namespace_prefixes}{$p} = $uri; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub _rss_name_and_prefix { | ||||||||||||||||||||||||||
|
Subroutine
_rss_name_and_prefix: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 401 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 402 | 0 | my $prefix = shift; | |||||||||||||||||||||||||||
| 403 | 0 | my $local = shift; | |||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | die "Invalid prefix ($prefix)" | ||||||||||||||||||||||||||||
| 406 | 0 | ▶ | unless exists $self->{namespace_prefixes}{$prefix}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 0 | ▶ | my $name = $prefix ? "$prefix:$local" : $local; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | return ( | ||||||||||||||||||||||||||||
| 411 | Name => $name, | ||||||||||||||||||||||||||||
| 412 | LocalName => $local, | ||||||||||||||||||||||||||||
| 413 | Prefix => $prefix, | ||||||||||||||||||||||||||||
| 414 | 0 | NamespaceURI => $self->{namespace_prefixes}{$prefix} | |||||||||||||||||||||||||||
| 415 | ); | ||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub _rss_att { | ||||||||||||||||||||||||||
|
Subroutine
_rss_att: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 419 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 420 | 0 | my $prefix = shift; | |||||||||||||||||||||||||||
| 421 | 0 | my $att = shift; | |||||||||||||||||||||||||||
| 422 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | die "Invalid prefix ($prefix)" | ||||||||||||||||||||||||||||
| 425 | 0 | ▶ | unless exists $self->{namespace_prefixes}{$prefix}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | return ( | ||||||||||||||||||||||||||||
| 428 | 0 | "{$self->{namespace_prefixes}{$prefix}}$att" => { | |||||||||||||||||||||||||||
| 429 | $self->_rss_name_and_prefix( $prefix, $att ), | ||||||||||||||||||||||||||||
| 430 | Value => $value, | ||||||||||||||||||||||||||||
| 431 | }, | ||||||||||||||||||||||||||||
| 432 | ); | ||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | 10 | 1; | |||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | # ABSTRACT: Generate SAX events for RSS | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | =pod | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =head1 NAME | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | XML::Generator::RSS10 - Generate SAX events for RSS | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | =head1 VERSION | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | version 0.02 | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | use XML::Generator::RSS10; | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | my $rss = XML::Generator::RSS10->new( Handler => $sax_handler ); | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | $rss->item( title => 'Exciting News About my Pants!', | ||||||||||||||||||||||||||||
| 459 | link => 'http://pants.example.com/my/news.html', | ||||||||||||||||||||||||||||
| 460 | description => 'My pants are full of ants!', | ||||||||||||||||||||||||||||
| 461 | ); | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | $rss->channel( title => 'Pants', | ||||||||||||||||||||||||||||
| 464 | link => 'http://pants.example.com/', | ||||||||||||||||||||||||||||
| 465 | description => 'A fascinating pants site', | ||||||||||||||||||||||||||||
| 466 | ); | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | This module generates SAX events which will create an RSS 1.0 | ||||||||||||||||||||||||||||
| 471 | document, based on easy to use RSS-related methods like C<item()> and | ||||||||||||||||||||||||||||
| 472 | C<channel()>. | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | =head1 METHODS | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | =head2 new | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | This is the constructor for this class. | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | It takes several parameters, though only one, "Handler", is required: | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | =over 4 | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | =item * Handler | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | This should be a SAX2 handler. If you are looking to write RSS to a | ||||||||||||||||||||||||||||
| 487 | file or store it in a string, you probably want to use | ||||||||||||||||||||||||||||
| 488 | C<XML::SAX::Writer>. | ||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | This parameter is required. | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | =item * pretty | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | If this is true, the generated XML document will include extra spaces | ||||||||||||||||||||||||||||
| 495 | and newlines in an effort to make it look pretty. This defaults to | ||||||||||||||||||||||||||||
| 496 | false. | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | =item * modules | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | This parameter can be used to make additional RSS 1.0 modules | ||||||||||||||||||||||||||||
| 501 | available when creating a feed. It should be an array reference to a | ||||||||||||||||||||||||||||
| 502 | list of module prefixes. | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | You can specify any prefix you like, and this module will try to load | ||||||||||||||||||||||||||||
| 505 | a module named C<< XML::Generator::RSS10::<prefix> >>. | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | This module comes with support for the core RSS 1.0 modules, which are | ||||||||||||||||||||||||||||
| 508 | Content (content), Dublin Core (dc), and Syndication (sy). It also | ||||||||||||||||||||||||||||
| 509 | include a module supporting the proposed Administrative (admin) and | ||||||||||||||||||||||||||||
| 510 | Creative Commons (cc) modules. See the docs for | ||||||||||||||||||||||||||||
| 511 | C<XML::Generator::RSS10::content>, C<XML::Generator::RSS10::dc>, | ||||||||||||||||||||||||||||
| 512 | C<XML::Generator::RSS10::sy>, C<XML::Generator::RSS10::admin>, and | ||||||||||||||||||||||||||||
| 513 | C<XML::Generator::RSS10::cc> for details on how to use them. | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | The Dublin Core and Syndication modules are loaded by default if this | ||||||||||||||||||||||||||||
| 516 | parameter is not specified. | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | =back | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | The constructor begins the RSS document and returns a new | ||||||||||||||||||||||||||||
| 521 | C<XML::Generator::RSS10> object. | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | =head2 item | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | This method is used to add item elements to the document. It accepts | ||||||||||||||||||||||||||||
| 526 | the following parameters: | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | =over 4 | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | =item * title | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | The item's title. Required. | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | =item * link | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | The item's link. Required. | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | =item * description | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | The item's link. Optional. | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | This element will be formatted as CDATA since many people like to put | ||||||||||||||||||||||||||||
| 543 | HTML in it. | ||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | =back | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | =head2 image | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | This method is used to add an image element to the document. It may | ||||||||||||||||||||||||||||
| 550 | only be called once. It accepts the following parameters: | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | =over 4 | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =item * title | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | The image's title. Required. | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | =item * link | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | The image's link. Required. | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | =item * url | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | The image's URL. Required. | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | =back | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | =head2 textinput | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | This method is used to add an textinput element to the document. It | ||||||||||||||||||||||||||||
| 571 | may only be called once. It accepts the following parameters: | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | =over 4 | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | =item * title | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | The textinput's title. Required. | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =item * description | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | The textinput's description. Required. | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | =item * name | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | The textinput's name. Required. | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | =item * url | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | The textinput's URL. Required. | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | =back | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | =head2 channel | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | This method is used add the channel element to the document. It also | ||||||||||||||||||||||||||||
| 596 | finishes the document. You must have added at least one item to the | ||||||||||||||||||||||||||||
| 597 | document prior to calling this method. | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | B<You may not call any other methods after this one is called>. | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | =over 4 | ||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | =item * title | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | The channel's title. Required. | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | =item * link | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | The channel's link. Required. | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | =item * description | ||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | The channel's description. Required. | ||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | This element will be formatted as CDATA since many people like to put | ||||||||||||||||||||||||||||
| 616 | HTML in it. | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | =back | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | =head1 RSS 1.0 MODULES | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | To add module output to a document, you can pass extra hash keys when | ||||||||||||||||||||||||||||
| 623 | calling any of the output-generating methods. The extra keys should | ||||||||||||||||||||||||||||
| 624 | be the module prefixes, and the values should be something expected by | ||||||||||||||||||||||||||||
| 625 | the relevant module. | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | For example, to add some Dublin Core elements to the channel element, | ||||||||||||||||||||||||||||
| 628 | you can write this: | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | $rss->channel( title => 'Pants', | ||||||||||||||||||||||||||||
| 631 | link => 'http://pants.example.com/', | ||||||||||||||||||||||||||||
| 632 | description => 'A fascinating pants site', | ||||||||||||||||||||||||||||
| 633 | dc => { publisher => 'The Pants People', | ||||||||||||||||||||||||||||
| 634 | rights => 'Mine, all mine!', | ||||||||||||||||||||||||||||
| 635 | date => $date, | ||||||||||||||||||||||||||||
| 636 | }, | ||||||||||||||||||||||||||||
| 637 | ); | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | The values for the "dc" key will be passed to | ||||||||||||||||||||||||||||
| 640 | C<XML::Generator::RSS10::dc>, which will add them to the output | ||||||||||||||||||||||||||||
| 641 | stream appropriately. | ||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | =head1 XML::Generator::RSS10 VERSUS XML::RSS | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | This module is less flexible than C<XML::RSS> in many ways. However, | ||||||||||||||||||||||||||||
| 646 | it does have two features that C<XML::RSS> does not provide: | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | =over 4 | ||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | =item * | ||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||
| 652 | Because it generates SAX events, this module can be used to write a | ||||||||||||||||||||||||||||
| 653 | document to a handle as a stream. C<XML::RSS> requires you to create | ||||||||||||||||||||||||||||
| 654 | the entire document in memory first. | ||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | =item * | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | It has support for arbitrary RSS 1.0 modules, including ones you | ||||||||||||||||||||||||||||
| 659 | create. | ||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||
| 661 | =back | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | However, if you don't need any of these features you may be better off | ||||||||||||||||||||||||||||
| 664 | using C<XML::RSS> instead. | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | =head1 BUGS | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||
| 669 | C<bug-xml-generator-rss10@rt.cpan.org>, or through the web interface | ||||||||||||||||||||||||||||
| 670 | at L<http://rt.cpan.org>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 671 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | Dave Rolsky <autarch@urth.org> | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | This software is Copyright (c) 2011 by Dave Rolsky. | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | This is free software, licensed under: | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | =cut | ||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | __END__ | ||||||||||||||||||||||||||||