r27726 - in /trunk/libxml-rss-perl: ./ debian/ inc/Test/Run/Builder/ lib/XML/ lib/XML/RSS/Private/Output/ t/ t/data/2.0/
bricas-guest at users.alioth.debian.org
bricas-guest at users.alioth.debian.org
Thu Dec 4 15:34:48 UTC 2008
Author: bricas-guest
Date: Thu Dec 4 15:34:44 2008
New Revision: 27726
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=27726
Log:
* New upstream release.
* debian/control: Added myself to Uploaders
Added:
trunk/libxml-rss-perl/t/data/2.0/empty-desc.rss
- copied unchanged from r27725, branches/upstream/libxml-rss-perl/current/t/data/2.0/empty-desc.rss
trunk/libxml-rss-perl/t/data/2.0/no-desc.rss
- copied unchanged from r27725, branches/upstream/libxml-rss-perl/current/t/data/2.0/no-desc.rss
trunk/libxml-rss-perl/t/render-upon-init.t
- copied unchanged from r27725, branches/upstream/libxml-rss-perl/current/t/render-upon-init.t
Modified:
trunk/libxml-rss-perl/Changes
trunk/libxml-rss-perl/MANIFEST
trunk/libxml-rss-perl/META.yml
trunk/libxml-rss-perl/TODO
trunk/libxml-rss-perl/debian/changelog
trunk/libxml-rss-perl/debian/control
trunk/libxml-rss-perl/inc/Test/Run/Builder/Manifest.pm
trunk/libxml-rss-perl/lib/XML/RSS.pm
trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm
trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/V2_0.pm
trunk/libxml-rss-perl/t/1.0-parse-2.t
trunk/libxml-rss-perl/t/2.0-modules.t
trunk/libxml-rss-perl/t/2.0-parse-2.t
trunk/libxml-rss-perl/t/encoding.t
trunk/libxml-rss-perl/t/test-generated-items.t
trunk/libxml-rss-perl/t/test_manifest
trunk/libxml-rss-perl/t/version.t
Modified: trunk/libxml-rss-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/Changes?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/Changes (original)
+++ trunk/libxml-rss-perl/Changes Thu Dec 4 15:34:44 2008
@@ -1,5 +1,36 @@
Revision history for Perl module XML::RSS
-
+
+1.41 - December 4, 2008
+ - Made the default keys for the channel link, description and title undef
+ instead of ''. They become '' once they are opened.
+ - http://rt.cpan.org/Public/Bug/Display.html?id=40686
+ - Now keeping track of rdf:resource of <image> in RSS 1.0:
+ - http://rt.cpan.org/Ticket/Display.html?id=3978
+ - Made sure that channel/{link,description,title} are localized to
+ the empty string before rendering, to allow for better backwards
+ compatibility.
+ - http://rt.cpan.org/Public/Bug/Display.html?id=40686
+
+1.40 - December 1, 2008
+ - Now outputting an arrayref of <skipDays>/<day>'s and <skipHours>/<hours>
+ properly.
+ - http://rt.cpan.org/Public/Bug/Display.html?id=40978
+ - Now parsing multiple <category>'ies inside an <item> into an
+ array-reference.
+ - http://rt.cpan.org/Ticket/Display.html?id=38296
+ - Now outputting an arayref of <item>/<category> prpoerly.
+ - http://rt.cpan.org/Ticket/Display.html?id=38296
+ - Parsing multiple <channel>/<category> into arrays.
+ - http://rt.cpan.org/Public/Bug/Display.html?id=9729
+ - Rendering multiple <channel>/<category> elements from array refs.
+ - http://rt.cpan.org/Public/Bug/Display.html?id=9729
+ - Now parsing multiple dc:items into an array
+ reference (at least inside an <item>):
+ - http://rt.cpan.org/Public/Bug/Display.html?id=6000
+ - Added the modules_as_arrays option to parse repeatable module elements
+ into an array ref.
+
+
1.38 - November 27, 2008
- Added support for duplicate items of RSS modules.
- http://rt.cpan.org/Public/Bug/Display.html?id=4495
Modified: trunk/libxml-rss-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/MANIFEST?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/MANIFEST (original)
+++ trunk/libxml-rss-perl/MANIFEST Thu Dec 4 15:34:44 2008
@@ -56,6 +56,8 @@
t/charset1.t
t/data/1.0/rss1.0.exotic.rdf
t/data/1.0/with_content.rdf
+t/data/2.0/empty-desc.rss
+t/data/2.0/no-desc.rss
t/data/2.0/sf-hs-with-lastBuildDate.rss
t/data/2.0/sf-hs-with-pubDate.rss
t/data/freshmeat.rdf
@@ -72,6 +74,7 @@
TODO
t/pod-coverage.t
t/pod.t
+t/render-upon-init.t
t/rss2-gt-encoding.t
t/test-generated-items.t
t/test_manifest
Modified: trunk/libxml-rss-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/META.yml?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/META.yml (original)
+++ trunk/libxml-rss-perl/META.yml Thu Dec 4 15:34:44 2008
@@ -1,6 +1,6 @@
---
name: XML-RSS
-version: 1.38
+version: 1.41
author:
- 'Original code: Jonathan Eisenzopf <eisen at pobox.com>'
- |-
@@ -24,7 +24,7 @@
provides:
XML::RSS:
file: lib/XML/RSS.pm
- version: 1.38
+ version: 1.41
XML::RSS::Private::Output::Base:
file: lib/XML/RSS/Private/Output/Base.pm
XML::RSS::Private::Output::Roles::ImageDims:
Modified: trunk/libxml-rss-perl/TODO
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/TODO?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/TODO (original)
+++ trunk/libxml-rss-perl/TODO Thu Dec 4 15:34:44 2008
@@ -1,15 +1,5 @@
-
http://rt.cpan.org/Public/Dist/Display.html?Name=XML-RSS
-- Add a way (and an option) to parse module items with duplicate keys into
-an array reference.
-
-- Add a way (and an option) to parse multiple dc:items into an array reference:
- - http://rt.cpan.org/Public/Bug/Display.html?id=6000
-
-- Convert an array of skipDays/day's or skipHours/hour's to multiple tags,
-when converting to text.
- - http://rt.cpan.org/Public/Bug/Display.html?id=40978
--- before the next release-ish
@@ -18,7 +8,7 @@
--- soon-ish
-- Make all the date/time interfaces accept and omit DateTime dates (maybe unix
+- Make all the date/time interfaces accept and emit DateTime dates (maybe unix
timestamps too?) instead of strings
--- eventually
@@ -31,3 +21,11 @@
each version)
- auto encode text?
+
+- Investigate parsing multiple dc:items into an array reference when
+inside other elements besides an <item>:
+ - http://rt.cpan.org/Public/Bug/Display.html?id=6000
+
+- Add a way (and an option) to parse module items with duplicate keys into
+an array reference.
+ - check more edge cases with other than <image> elements.
Modified: trunk/libxml-rss-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/debian/changelog?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/debian/changelog (original)
+++ trunk/libxml-rss-perl/debian/changelog Thu Dec 4 15:34:44 2008
@@ -1,3 +1,10 @@
+libxml-rss-perl (1.40-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+ * debian/control: Added myself to Uploaders
+
+ -- Brian Cassidy <brian.cassidy at gmail.com> Thu, 04 Dec 2008 11:30:56 -0400
+
libxml-rss-perl (1.38-1) unstable; urgency=low
* New upstream release.
Modified: trunk/libxml-rss-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/debian/control?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/debian/control (original)
+++ trunk/libxml-rss-perl/debian/control Thu Dec 4 15:34:44 2008
@@ -3,6 +3,7 @@
Priority: optional
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Jay Bonci <jaybonci at debian.org>,
+ Brian Cassidy <brian.cassidy at gmail.com>,
Vincent Danjean <vdanjean at debian.org>, Damyan Ivanov <dmn at debian.org>,
gregor herrmann <gregoa at debian.org>, Gunnar Wolf <gwolf at debian.org>
Standards-Version: 3.8.0
Modified: trunk/libxml-rss-perl/inc/Test/Run/Builder/Manifest.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/inc/Test/Run/Builder/Manifest.pm?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/inc/Test/Run/Builder/Manifest.pm (original)
+++ trunk/libxml-rss-perl/inc/Test/Run/Builder/Manifest.pm Thu Dec 4 15:34:44 2008
@@ -69,5 +69,19 @@
return $test_run->run();
}
+sub ACTION_tags
+{
+ my $self = shift;
+ return
+ $self->do_system(
+ "ctags",
+ qw(-f tags --recurse --totals
+ --exclude=blib/** --exclude=t/lib/**
+ --exclude=**/.svn/** --exclude='*~'),
+ "--exclude=".$self->dist_name()."-*/**",
+ qw(--languages=Perl --langmap=Perl:+.t)
+ );
+}
+
1;
Modified: trunk/libxml-rss-perl/lib/XML/RSS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/lib/XML/RSS.pm?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/lib/XML/RSS.pm (original)
+++ trunk/libxml-rss-perl/lib/XML/RSS.pm Thu Dec 4 15:34:44 2008
@@ -17,7 +17,7 @@
use vars qw($VERSION $AUTOLOAD @ISA $AUTO_ADD);
-$VERSION = '1.38';
+$VERSION = '1.41';
$AUTO_ADD = 0;
@@ -25,9 +25,9 @@
return {
"0.9" => {
channel => {
- title => '',
- description => '',
- link => '',
+ title => undef,
+ description => undef,
+ link => undef,
},
image => {
title => undef,
@@ -43,13 +43,13 @@
},
"0.91" => {
channel => {
- title => '',
+ title => undef,
copyright => undef,
- description => '',
+ description => undef,
docs => undef,
language => undef,
lastBuildDate => undef,
- 'link' => '',
+ 'link' => undef,
managingEditor => undef,
pubDate => undef,
rating => undef,
@@ -74,9 +74,9 @@
},
"2.0" => {
channel => {
- title => '',
- 'link' => '',
- description => '',
+ title => undef,
+ 'link' => undef,
+ description => undef,
language => undef,
copyright => undef,
managingEditor => undef,
@@ -112,9 +112,9 @@
},
'default' => {
channel => {
- title => '',
- description => '',
- link => '',
+ title => undef,
+ description => undef,
+ link => undef,
},
image => {
title => undef,
@@ -534,6 +534,28 @@
return ($self->{output} =~ /\d/) ? $self->{output} : $self->{version};
}
+# This is done to preserve backwards compatibility with older versions
+# of XML-RSS that had the channel/{link,description,title} as the empty
+# string by default.
+sub _output_env {
+ my $self = shift;
+ my $callback = shift;
+
+ local $self->{channel}->{'link'} = $self->{channel}->{'link'};
+ local $self->{channel}->{'description'} = $self->{channel}->{'description'};
+ local $self->{channel}->{'title'} = $self->{channel}->{'title'};
+
+ foreach my $field (qw(link description title))
+ {
+ if (!defined($self->{channel}->{$field}))
+ {
+ $self->{channel}->{$field} = '';
+ }
+ }
+
+ return $callback->();
+}
+
sub as_string {
my $self = shift;
@@ -541,7 +563,9 @@
my $output_method = $self->_get_output_method($version);
- return $self->$output_method();
+ return $self->_output_env(
+ sub { return $self->$output_method(); }
+ );
}
# Checks if inside a possibly namespaced element
@@ -607,8 +631,23 @@
);
}
+sub _get_ns_arrayity {
+ my ($self, $ns) = @_;
+
+ my $is_array =
+ $self->_parse_options()->{'modules_as_arrays'}
+ && (!exists($self->_get_default_modules()->{$ns}))
+ # RDF
+ && ($ns ne "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
+ ;
+
+ my $default_ref = sub { $is_array ? [] : {} };
+
+ return ($is_array, $default_ref);
+}
+
sub _append_text_to_elem_struct {
- my ($self, $struct, $cdata, $mapping_sub) = @_;
+ my ($self, $struct, $cdata, $mapping_sub, $is_array_sub) = @_;
my $elem = $self->_current_element;
@@ -616,15 +655,33 @@
# If it's in the default namespace
if ($verdict) {
- $self->_append_struct($struct, $mapping_sub->($struct, $elem), $cdata);
+ $self->_append_struct(
+ $struct,
+ scalar($mapping_sub->($struct, $elem)),
+ scalar($is_array_sub->($struct, $elem)),
+ $cdata
+ );
}
else {
- # If it's in another namespace
- $struct->{$ns}->{$elem} .= $cdata;
+ my $prefix = $self->{modules}->{$ns};
+
+ my ($is_array, $default_ref) = $self->_get_ns_arrayity($ns);
+
+ $self->_append_struct(
+ ($struct->{$ns} ||= $default_ref->()),
+ $elem,
+ (defined($prefix) && $prefix eq "dc"),
+ $cdata
+ );
# If it's in a module namespace, provide a friendlier prefix duplicate
- if ($self->{modules}->{$ns}) {
- $struct->{$self->{modules}->{$ns}}->{$elem} .= $cdata;
+ if ($prefix) {
+ $self->_append_struct(
+ ($struct->{$prefix} ||= $default_ref->()),
+ $elem,
+ ($prefix eq "dc"),
+ $cdata
+ );
}
}
@@ -632,17 +689,37 @@
}
sub _append_struct {
- my ($self, $struct, $key, $cdata) = @_;
- if (defined $struct->{$key} && ref($struct->{$key}) eq 'HASH') {
- $struct->{$key}->{content} .= $cdata;
- } else {
- $struct->{$key} .= $cdata;
- }
+ my ($self, $struct, $key, $can_be_array, $cdata) = @_;
+
+ if (ref($struct) eq 'ARRAY') {
+ $struct->[-1]->{'val'} .= $cdata;
+ return;
+ }
+ elsif (defined $struct->{$key}) {
+ if (ref($struct->{$key}) eq 'HASH') {
+ $struct->{$key}->{content} .= $cdata;
+ return;
+ }
+ elsif ($can_be_array && ref($struct->{$key}) eq 'ARRAY') {
+ $struct->{$key}->[-1] .= $cdata;
+ return;
+ }
+ }
+
+ $struct->{$key} .= $cdata;
+ return;
}
sub _return_elem {
my ($struct, $elem) = @_;
return $elem;
+}
+
+sub _return_elem_is_array {
+ my ($struct, $elem) = @_;
+
+ # Always return false because no element should be an array.
+ return;
}
sub _append_text_to_elem {
@@ -652,6 +729,7 @@
$self->$ext_tag(),
$cdata,
\&_return_elem,
+ \&_return_elem_is_array,
);
}
@@ -677,6 +755,12 @@
}
}
+sub _return_item_elem_is_array {
+ my ($item, $elem) = @_;
+
+ return ($elem eq "category");
+}
+
sub _append_text_to_item {
my ($self, $cdata) = @_;
@@ -688,6 +772,7 @@
$self->_last_item,
$cdata,
\&_return_item_elem,
+ \&_return_item_elem_is_array
);
}
@@ -740,9 +825,16 @@
}
# channel element
elsif ($self->_my_in_element("channel")) {
- return if $self->_within_topics;
-
- $self->_append_text_to_elem("channel", $cdata);
+ if ($self->_within_topics() || $self->_my_in_element("items")) {
+ return;
+ }
+
+ if ($self->_current_element eq "category") {
+ $self->_append_to_array_elem("channel", $cdata);
+ }
+ else {
+ $self->_append_text_to_elem("channel", $cdata);
+ }
}
}
@@ -765,6 +857,45 @@
);
}
+sub _start_array_element_in_struct {
+ my ($self, $input_struct, $el, $prefix) = @_;
+
+ my ($el_ns, $el_verdict) = $self->_get_elem_namespace($el);
+
+ my ($is_array, $default_ref) = $self->_get_ns_arrayity($el_ns);
+
+ my @structs = (!$el_verdict)
+ ? (
+ (exists($self->{modules}->{$el_ns})
+ ? ($input_struct->{$self->{modules}->{$el_ns}} ||= $default_ref->())
+ : ()
+ ),
+ ($input_struct->{$el_ns} ||= $default_ref->()),
+ )
+ : ($input_struct)
+ ;
+
+ foreach my $struct (@structs)
+ {
+ if (ref($struct) eq 'ARRAY') {
+ push @$struct, { el => $el, val => "", };
+ }
+ # If it's an array - append a new empty element because a new one
+ # was started.
+ elsif (ref($struct->{$el}) eq "ARRAY") {
+ push @{$struct->{$el}}, "";
+ }
+ # If it's not an array but still full (i.e: it's only the second
+ # element), then turn it into an array
+ elsif (defined($struct->{$el}) && length($struct->{$el})) {
+ $struct->{$el} = [$struct->{$el}, ""];
+ }
+ # Else - do nothing and let the function append to the new value
+ #
+ }
+ return 1;
+}
+
sub _start_array_element {
my ($self, $cat, $el) = @_;
@@ -772,18 +903,7 @@
return;
}
- # If it's an array - append a new empty element because a new one
- # was started.
- if (ref($self->{$cat}->{$el}) eq "ARRAY") {
- push @{$self->{$cat}->{$el}}, "";
- }
- # If it's not an array but still full (i.e: it's only the second
- # element), then turn it into an array
- elsif (defined($self->{$cat}->{$el}) && length($self->{$cat}->{$el})) {
- $self->{$cat}->{$el} = [$self->{$cat}->{$el}, ""];
- }
- # Else - do nothing and let the function append to the new array.
-
+ $self->_start_array_element_in_struct($self->{$cat}, $el);
return 1;
}
@@ -799,7 +919,17 @@
my %attribs = @_;
my $parser = $self->_parser;
+
+ my ($el_ns, $el_verdict) = $self->_get_elem_namespace($el);
+ if ($el eq "image")
+ {
+ if (exists($attribs{'resource'}))
+ {
+ $self->image("rdf:resource", $attribs{'resource'});
+ }
+ }
+
# beginning of RSS 0.91
if ($el eq 'rss') {
if (exists($attribs{version})) {
@@ -856,7 +986,6 @@
# beginning of item element
}
- # TODO : Merge skipHours and skipDays
elsif ($self->_start_array_element("skipHours", $el)) {
# Do nothing - already done in the predicate.
}
@@ -894,6 +1023,17 @@
# beginning of taxo li element in item element
#'http://purl.org/rss/1.0/modules/taxonomy/' => 'taxo'
+ }
+ elsif (
+ $self->_current_element eq "item"
+ && (($el eq "category") ||
+ (
+ exists($self->{modules}->{$el_ns})
+ && ($self->{modules}->{$el_ns} eq "dc")
+ )
+ )
+ ) {
+ $self->_start_array_element_in_struct($self->_last_item, $el);
}
elsif (
$parser->within_element(
@@ -950,7 +1090,6 @@
}
}
}
-
# beginning of an item element that stores its info in rdf:resource
elsif ( $parser->namespace($el)
&& $self->_is_rdf_resource($el)
@@ -979,6 +1118,25 @@
elsif ($self->_should_be_hashref($el) and $self->_current_element eq 'item') {
$attribs{'xml:base'} = delete $attribs{base} if defined $attribs{base};
$self->_last_item->{$el} = \%attribs if keys %attribs;
+ }
+ elsif ($self->_start_array_element("image", $el)) {
+ # Do nothing - already done in the predicate.
+ }
+ elsif (($el eq "category") &&
+ (!$parser->within_element("item")) &&
+ $self->_start_array_element("channel", $el)) {
+ # Do nothing - already done in the predicate.
+ }
+ elsif (($self->_current_element eq 'channel') &&
+ ($el_verdict))
+ {
+ # Make sure an opening tag signifies that the element has been
+ # encountered.
+ if ( exists($self->{'channel'}->{$el})
+ && (!defined($self->{'channel'}->{$el})))
+ {
+ $self->{'channel'}->{$el} = "";
+ }
}
}
@@ -1550,6 +1708,13 @@
and there will only be a string. Thus, specifying this option may break
compatibility.
+=item * modules_as_arrays
+
+This option when true, will parse the modules key-value-pairs as an arrayref of
+C<<< { el => $key_name, value => $value, } >>> hash-refs to gracefully
+handle duplicate items (see below). It will not affect the known modules such
+as dc ("Dublin Core").
+
=back
=item parsefile ($file, \%options)
Modified: trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm (original)
+++ trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm Thu Dec 4 15:34:44 2008
@@ -464,6 +464,15 @@
shift->_end_top_level_elem("channel");
}
+sub _output_array_item_tag {
+ my ($self, $item, $tag) = @_;
+
+ if (defined($item->{$tag})) {
+ $self->_out_array_tag($tag, $item->{$tag});
+ }
+
+ return;
+}
sub _output_def_item_tag {
my ($self, $item, $tag) = @_;
@@ -541,13 +550,29 @@
return $self->{_prefer_dc};
}
+sub _calc_channel_dc_field_params {
+ my ($self, $dc_key, $non_dc_key) = @_;
+
+ return
+ (
+ $self->_prefer_dc() ? "dc:$dc_key" : $non_dc_key,
+ $self->_calc_channel_dc_field($dc_key, $non_dc_key)
+ );
+}
sub _out_channel_dc_field {
my ($self, $dc_key, $non_dc_key) = @_;
return $self->_out_defined_tag(
- ($self->_prefer_dc() ? "dc:$dc_key" : $non_dc_key),
- $self->_calc_channel_dc_field($dc_key, $non_dc_key)
+ $self->_calc_channel_dc_field_params($dc_key, $non_dc_key),
+ );
+}
+
+sub _out_channel_array_self_dc_field {
+ my ($self, $key) = @_;
+
+ $self->_out_array_tag(
+ $self->_calc_channel_dc_field_params($key, $key),
);
}
@@ -743,7 +768,7 @@
if (defined($value)) {
$self->_out("<$outer>\n");
- $self->_out_tag($inner, $value);
+ $self->_out_array_tag($inner, $value);
$self->_end_top_level_elem($outer);
}
}
Modified: trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/V2_0.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/V2_0.pm?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/V2_0.pm (original)
+++ trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/V2_0.pm Thu Dec 4 15:34:44 2008
@@ -28,9 +28,9 @@
sub _out_item_2_0_tags {
my ($self, $item) = @_;
- foreach my $tag (qw(author category comments)) {
- $self->_output_def_item_tag($item, $tag);
- }
+ $self->_output_def_item_tag($item, "author");
+ $self->_output_array_item_tag($item, "category");
+ $self->_output_def_item_tag($item, "comments");
$self->_out_guid($item);
@@ -67,7 +67,7 @@
$self->_out_editors;
- $self->_out_channel_self_dc_field("category");
+ $self->_out_channel_array_self_dc_field("category");
$self->_out_channel_self_dc_field("generator");
# Insert cloud support here
Modified: trunk/libxml-rss-perl/t/1.0-parse-2.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/1.0-parse-2.t?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/1.0-parse-2.t (original)
+++ trunk/libxml-rss-perl/t/1.0-parse-2.t Thu Dec 4 15:34:44 2008
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 8;
use XML::RSS;
@@ -74,3 +74,20 @@
"Testing the \"content\" namespace");
}
}
+
+{
+ my $rss = XML::RSS->new();
+
+ $rss->parsefile(
+ File::Spec->catfile(
+ File::Spec->curdir(), "examples", "1.0", "rss1.0.rdf",
+ )
+ );
+
+ # TEST
+ is (
+ $rss->image("rdf:resource"),
+ "http://freshmeat.net/images/fm.mini.jpg",
+ "rdf:resource for image was read correctly.",
+ );
+}
Modified: trunk/libxml-rss-perl/t/2.0-modules.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/2.0-modules.t?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/2.0-modules.t (original)
+++ trunk/libxml-rss-perl/t/2.0-modules.t Thu Dec 4 15:34:44 2008
@@ -7,6 +7,11 @@
{
my $rss = XML::RSS->new( version => '2.0' );
+ $rss->channel(
+ link => "http://www.homesite.tld/",
+ description => "My homesite",
+ title => "With content",
+ );
$rss->add_module(
prefix => 'content',
uri => 'http://purl.org/rss/1.0/modules/content/'
Modified: trunk/libxml-rss-perl/t/2.0-parse-2.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/2.0-parse-2.t?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/2.0-parse-2.t (original)
+++ trunk/libxml-rss-perl/t/2.0-parse-2.t Thu Dec 4 15:34:44 2008
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 10;
use XML::RSS;
use File::Spec;
@@ -78,4 +78,87 @@
[qw(Saturday Sunday)],
"skipDays/day is parsed into an array with indiv elements",
);
+
+ # TEST
+ is_deeply(
+ $rss->{'channel'}->{'category'},
+ [qw(Media Texas)],
+ "Multiple categories",
+ );
}
+
+{
+ my $rss = XML::RSS->new();
+
+ $rss->parsefile(
+ File::Spec->catfile(
+ File::Spec->curdir(),
+ "t", "data", "2.0",
+ "sf-hs-with-pubDate.rss"
+ ),
+ );
+
+ # TEST
+ is_deeply(
+ $rss->{'items'}->[0]->{'category'},
+ [qw(
+ mathml
+ mathematics
+ math
+ dos
+ jokes
+ tucan
+ ideas
+ mathventures
+ unixdoc
+ )],
+ "items/category is an array-ref",
+ );
+}
+
+{
+ my $rss = XML::RSS->new();
+
+ $rss->parsefile(
+ File::Spec->catfile(
+ File::Spec->curdir(),
+ "t", "data", "2.0",
+ "no-desc.rss",
+ ),
+ );
+
+ # TEST
+ ok (!defined($rss->channel("description")),
+ "description is undefined if not present"
+ );
+
+ # TEST
+ ok (!defined($rss->channel("title")),
+ "title is undefined if not present",
+ );
+}
+
+
+{
+ my $rss = XML::RSS->new();
+
+ $rss->parsefile(
+ File::Spec->catfile(
+ File::Spec->curdir(),
+ "t", "data", "2.0",
+ "empty-desc.rss",
+ ),
+ );
+
+ # TEST
+ is ($rss->channel("description"),
+ "",
+ "description is an empty string if an empty tag"
+ );
+
+ # TEST
+ is ($rss->channel("title"),
+ "",
+ "title is an empty string if an empty tasg",
+ );
+}
Modified: trunk/libxml-rss-perl/t/encoding.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/encoding.t?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/encoding.t (original)
+++ trunk/libxml-rss-perl/t/encoding.t Thu Dec 4 15:34:44 2008
@@ -41,6 +41,7 @@
$rss->channel(
title => 'Test RSS',
link => 'http://www.example.com',
+ description => "Hello",
);
}
Modified: trunk/libxml-rss-perl/t/test-generated-items.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/test-generated-items.t?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/test-generated-items.t (original)
+++ trunk/libxml-rss-perl/t/test-generated-items.t Thu Dec 4 15:34:44 2008
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 192;
+use Test::More tests => 198;
use XML::RSS;
use HTML::Entities qw(encode_entities);
@@ -2136,25 +2136,6 @@
"Testing encode_cb with named encodings",
);
}
-{
- my $rss = create_channel_rss({
- version => "0.91",
- image_link => undef,
- channel_params => [ title => undef ],
- });
-
- my $output;
-
- eval
- {
- $output = $rss->as_string();
- };
-
- # TEST
- ok ($@ =~ m{\A\$text is undefined in XML::RSS::_encode},
- "Undefined string throws an exception"
- );
-}
{
my $rss = create_channel_rss({
@@ -3957,6 +3938,12 @@
$rss->{'xml:base'} = 'http://foo.com/';
+ $rss->channel(
+ description => "Foo",
+ title => "Hi",
+ link => "http://www.tld/",
+ );
+
# TEST
ok($rss->add_item(
title => 'foo',
@@ -4064,6 +4051,12 @@
is($rss->{'xml:base'}, 'http://example.com/', 'Got base');
$rss->{'xml:base'} = 'http://foo.com/';
+
+ $rss->channel(
+ title => "freshmeat.net",
+ link => "http://freshmeat.net",
+ description => "the one-stop-shop for all your Linux software needs",
+ );
# TEST
ok($rss->add_item(
@@ -4117,6 +4110,22 @@
"</image>",
'Multiple values for the same key in a module, usign an array ref'
);
+
+ my $parsed_rss = XML::RSS->new(version => '1.0');
+ $parsed_rss->add_module(prefix => "eloq", uri => "http://eloq.tld2/Gorj/");
+ $parsed_rss->parse($rss->as_string(), { modules_as_arrays => 1, });
+
+ # TEST
+ is_deeply(
+ $parsed_rss->{'image'}->{'eloq'},
+ [
+ { 'el' => 'grow', 'val' => "There" },
+ { 'el' => 'grow', 'val' => "Position", },
+ { 'el' => 'show', 'val' => "and tell", },
+ { 'el' => 'show', 'val' => "must go on", },
+ ],
+ "modules_as_arrays parsed the namespace into an array."
+ );
}
{
@@ -4144,4 +4153,105 @@
"</item>\n",
"1.0 - item/multiple dc:subject's"
);
-}
+
+ my $parsed_rss = XML::RSS->new(version => '1.0');
+
+ $parsed_rss->parse($rss->as_string());
+
+ # TEST
+ is_deeply (
+ $parsed_rss->{'items'}->[1]->{'dc'}->{'subject'},
+ [qw(tiger elephant snake)],
+ "Properly parsed dc:subject into an array.",
+ );
+
+ # TEST
+ is(
+ $parsed_rss->{'items'}->[1]->{'dc'}->{'language'},
+ "en-GB",
+ "Properly parsed dc:language.",
+ );
+}
+
+{
+ my $rss = create_skipDays_rss({
+ version => "2.0",
+ skipDays_params => [ day => [qw(Sunday Thursday Saturday)] ],
+ });
+ # TEST
+ contains($rss, ("<skipDays>\n"
+ . "<day>Sunday</day>\n"
+ . "<day>Thursday</day>\n"
+ . "<day>Saturday</day>\n"
+ . "</skipDays>\n"),
+ "Generate skipDays with multiple values (array)."
+ );
+}
+
+
+{
+ my $rss = create_skipHours_rss({
+ version => "2.0",
+ skipHours_params => [ hour => [qw(5 10 16)] ],
+ });
+ # TEST
+ contains($rss, ("<skipHours>\n"
+ . "<hour>5</hour>\n"
+ . "<hour>10</hour>\n"
+ . "<hour>16</hour>\n"
+ . "</skipHours>\n"),
+ "2.0 - skipHours/hour == 0"
+ );
+}
+
+
+{
+ my $rss = create_item_with_0_rss({version => "2.0",
+ item_params =>
+ [
+ title => "Foo&Bar",
+ link => "http://www.mytld/",
+ category => ["OneCat", "TooCat", "3Kitties"],
+ ],
+ }
+ );
+
+ # TEST
+ contains(
+ $rss,
+ ("<item>\n" .
+ "<title>Foo&Bar</title>\n" .
+ "<link>http://www.mytld/</link>\n" .
+ "<category>OneCat</category>\n" .
+ "<category>TooCat</category>\n" .
+ "<category>3Kitties</category>\n" .
+ "</item>"
+ ),
+ "2.0 - item/multiple-category's",
+ );
+}
+
+{
+ # Here we create an RSS 2.0 object and render it as the output
+ # version "3.5" in order to test that version 1.0 is the default
+ # version for output.
+ my $rss = create_channel_rss({
+ version => "2.0",
+ channel_params =>
+ [category => [qw(OneCat TooManyCats KittensGalore)]],
+ omit_date => 1,
+ });
+ # TEST
+ contains($rss, ("<channel>\n" .
+ "<title>freshmeat.net</title>\n" .
+ "<link>http://freshmeat.net</link>\n" .
+ "<description>Linux software</description>\n" .
+ "<category>OneCat</category>\n" .
+ "<category>TooManyCats</category>\n" .
+ "<category>KittensGalore</category>\n" .
+ "\n" .
+ "<item>\n"),
+ "Multiple channel/category elements"
+ );
+}
+
Modified: trunk/libxml-rss-perl/t/test_manifest
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/test_manifest?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/test_manifest (original)
+++ trunk/libxml-rss-perl/t/test_manifest Thu Dec 4 15:34:44 2008
@@ -1,6 +1,7 @@
load.t
pod.t
version.t
+render-upon-init.t
encoding.t
0.9-generate.t
0.9-parse.t
Modified: trunk/libxml-rss-perl/t/version.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/version.t?rev=27726&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/version.t (original)
+++ trunk/libxml-rss-perl/t/version.t Thu Dec 4 15:34:44 2008
@@ -43,6 +43,7 @@
$rss->channel(
title => 'Test RSS',
link => 'http://www.example.com',
+ description => '',
);
}
More information about the Pkg-perl-cvs-commits
mailing list