r34927 - in /branches/upstream/libxml-feed-perl/current: ./ lib/XML/ lib/XML/Feed/Format/ t/ t/samples/
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Fri May 8 06:14:32 UTC 2009
Author: ryan52-guest
Date: Fri May 8 06:14:26 2009
New Revision: 34927
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=34927
Log:
[svn-upgrade] Integrating new upstream version, libxml-feed-perl (0.43+dfsg)
Added:
branches/upstream/libxml-feed-perl/current/t/14-multi-enclosures.t
Modified:
branches/upstream/libxml-feed-perl/current/Changes
branches/upstream/libxml-feed-perl/current/MANIFEST
branches/upstream/libxml-feed-perl/current/META.yml
branches/upstream/libxml-feed-perl/current/Makefile.PL
branches/upstream/libxml-feed-perl/current/lib/XML/Feed.pm
branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/Atom.pm
branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/RSS.pm
branches/upstream/libxml-feed-perl/current/t/samples/atom-multi-enclosure.xml
branches/upstream/libxml-feed-perl/current/t/samples/rss20-multi-enclosure.xml
Modified: branches/upstream/libxml-feed-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/Changes?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/Changes (original)
+++ branches/upstream/libxml-feed-perl/current/Changes Fri May 8 06:14:26 2009
@@ -1,6 +1,9 @@
-# $Id: Changes 148 2009-04-03 15:16:38Z swistow $
+# $Id: Changes 150 2009-05-07 00:47:58Z swistow $
Revision history for XML::Feed
+
+0.43
+ - Add optional multi enclosure support
0.42
- Fix conversion of multi value fields
Modified: branches/upstream/libxml-feed-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/MANIFEST?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/MANIFEST (original)
+++ branches/upstream/libxml-feed-perl/current/MANIFEST Fri May 8 06:14:26 2009
@@ -28,6 +28,7 @@
t/12-multi-subjects-rss.t
t/13-category-hash-bug.t
t/14-enclosures.t
+t/14-multi-enclosures.t
t/pod-coverage.t
t/pod.t
t/samples/atom-10-example.xml
Modified: branches/upstream/libxml-feed-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/META.yml?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/META.yml (original)
+++ branches/upstream/libxml-feed-perl/current/META.yml Fri May 8 06:14:26 2009
@@ -1,6 +1,6 @@
---
name: XML-Feed
-version: 0.42
+version: 0.43
author: []
abstract: XML Syndication Feed Support
license: perl
@@ -20,11 +20,11 @@
URI::Fetch: 0
XML::Atom: 0.32
XML::LibXML: 1.66
- XML::RSS: 1.40
+ XML::RSS: 1.44
provides:
XML::Feed:
file: lib/XML/Feed.pm
- version: 0.42
+ version: 0.43
XML::Feed::Content:
file: lib/XML/Feed/Content.pm
XML::Feed::Enclosure:
Modified: branches/upstream/libxml-feed-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/Makefile.PL?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/Makefile.PL (original)
+++ branches/upstream/libxml-feed-perl/current/Makefile.PL Fri May 8 06:14:26 2009
@@ -18,7 +18,7 @@
'URI::Fetch' => '0',
'XML::Atom' => '0.32',
'XML::LibXML' => '1.66',
- 'XML::RSS' => '1.40'
+ 'XML::RSS' => '1.44'
},
'INSTALLDIRS' => 'site',
'EXE_FILES' => [],
Modified: branches/upstream/libxml-feed-perl/current/lib/XML/Feed.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/lib/XML/Feed.pm?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/lib/XML/Feed.pm (original)
+++ branches/upstream/libxml-feed-perl/current/lib/XML/Feed.pm Fri May 8 06:14:26 2009
@@ -1,4 +1,4 @@
-# $Id: Feed.pm 147 2009-04-03 15:16:10Z swistow $
+# $Id: Feed.pm 150 2009-05-07 00:47:58Z swistow $
package XML::Feed;
use strict;
@@ -12,7 +12,8 @@
require => 1,
sub_name => 'formatters';
-our $VERSION = '0.42';
+our $VERSION = '0.43';
+our $MULTIPLE_ENCLOSURES = 0;
our @formatters;
BEGIN {
@formatters = __PACKAGE__->formatters;
@@ -366,7 +367,20 @@
B<Note:> Only C<XML::RSS::LibXML> version 0.3004 is known to work at the moment.
+=item C<$XML::Feed::MULTIPLE_ENCLOSURES>
+
+Although the RSS specification states that there can be at most one enclosure per item
+some feeds break this rule.
+
+If this variable is set then C<XML::Feed> captures all of them and makes them available as a list.
+
+Otherwise it returns the last enclosure parsed.
+
+B<Note:> C<XML::RSS> version 1.44 is needed for this to work.
+
=back
+
+=cut
=head1 VALID FEEDS
Modified: branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/Atom.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/Atom.pm?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/Atom.pm (original)
+++ branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/Atom.pm Fri May 8 06:14:26 2009
@@ -1,4 +1,4 @@
-# $Id: Atom.pm 145 2009-04-03 15:07:25Z swistow $
+# $Id: Atom.pm 150 2009-05-07 00:47:58Z swistow $
package XML::Feed::Format::Atom;
use strict;
@@ -299,15 +299,16 @@
if (@_) {
my $enclosure = shift;
- # TODO Atom can have multiple enclosures
- $entry->{entry}->link({ rel => 'enclosure', href => $enclosure->{url},
+ my $method = ($XML::Feed::MULTIPLE_ENCLOSURES)? 'add_link' : 'link';
+ $entry->{entry}->$method({ rel => 'enclosure', href => $enclosure->{url},
length => $enclosure->{length},
type => $enclosure->{type} });
return 1;
} else {
- my $l = first { defined $_->rel && $_->rel eq 'enclosure' } $entry->{entry}->link;
- return undef unless $l;
- return XML::Feed::Enclosure->new({ url => $l->href, length => $l->length, type => $l->type });
+ my @links = grep { defined $_->rel && $_->rel eq 'enclosure' } $entry->{entry}->link;
+ return undef unless @links;
+ my @encs = map { XML::Feed::Enclosure->new({ url => $_->href, length => $_->length, type => $_->type }) } @links ;
+ return ($XML::Feed::MULTIPLE_ENCLOSURES)? @encs : $encs[-1];
}
}
Modified: branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/RSS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/RSS.pm?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/RSS.pm (original)
+++ branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/RSS.pm Fri May 8 06:14:26 2009
@@ -1,4 +1,4 @@
-# $Id: RSS.pm 145 2009-04-03 15:07:25Z swistow $
+# $Id: RSS.pm 150 2009-05-07 00:47:58Z swistow $
package XML::Feed::Format::RSS;
use strict;
@@ -33,8 +33,12 @@
my $feed = shift;
my($str) = @_;
$feed->init_empty;
+ my $opts = {
+ hashrefs_instead_of_strings => 1,
+ };
+ $opts->{allow_multiple} = [ 'enclosure' ] if $XML::Feed::MULTIPLE_ENCLOSURES;
if ($str) {
- $feed->{rss}->parse($$str, { hashrefs_instead_of_strings => 1 } );
+ $feed->{rss}->parse($$str, $opts );
}
$feed;
}
@@ -334,13 +338,20 @@
if (@_) {
my $enclosure = shift;
- $entry->{entry}->{enclosure} = {
+ my $val = {
url => $enclosure->{url},
type => $enclosure->{type},
length => $enclosure->{length}
- };
- } else {
- return XML::Feed::Enclosure->new($entry->{entry}->{enclosure});
+ };
+ if ($XML::Feed::MULTIPLE_ENCLOSURES) {
+ push @{$entry->{entry}->{enclosure}}, $val;
+ } else {
+ $entry->{entry}->{enclosure} = $val;
+ }
+ } else {
+ my $tmp = $entry->{entry}->{enclosure};
+ my @encs = map { XML::Feed::Enclosure->new($_) } (ref $tmp eq 'ARRAY')? @$tmp : ($tmp);
+ return ($XML::Feed::MULTIPLE_ENCLOSURES)? @encs : $encs[-1];
}
}
Added: branches/upstream/libxml-feed-perl/current/t/14-multi-enclosures.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/t/14-multi-enclosures.t?rev=34927&op=file
==============================================================================
--- branches/upstream/libxml-feed-perl/current/t/14-multi-enclosures.t (added)
+++ branches/upstream/libxml-feed-perl/current/t/14-multi-enclosures.t Fri May 8 06:14:26 2009
@@ -1,0 +1,59 @@
+#!perl -w
+
+use strict;
+use Test::More;
+use XML::Feed;
+use XML::Feed::Enclosure;
+
+$XML::Feed::MULTIPLE_ENCLOSURES=1;
+
+my @formats = qw(atom rss20);
+plan tests => scalar(@formats)*38;
+
+foreach my $format (@formats) {
+ ok (my $feed = XML::Feed->parse("t/samples/$format-multi-enclosure.xml"), "Parsed $format");
+ my ($entry) = $feed->entries;
+ ok (my @enclosures = $entry->enclosure, "Got enclosure");
+ ok ($enclosures[0]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
+ is ($enclosures[0]->type, "audio/mpeg", "Got the enclosure mime type");
+ is ($enclosures[0]->length, "2478719", "Got enclosure length");
+ is ($enclosures[0]->url, "http://example.com/sample_podcast.mp3", "Got enclosure url");
+ ok ($enclosures[1]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
+ is ($enclosures[1]->type, "video/mpeg", "Got the enclosure mime type");
+ is ($enclosures[1]->length, "8888", "Got enclosure length");
+ is ($enclosures[1]->url, "http://example.com/sample_movie.mpg", "Got enclosure url");
+
+ ok (my $tmp = XML::Feed::Enclosure->new({ type => "image/jpeg" }), "Created a new enclosure");
+ is ($tmp->type, "image/jpeg", "Got type back");
+ ok ($tmp->url("http://example.com/sample_image.jpg"), "Set url");
+ ok ($tmp->length("1337"), "Set length");
+ ok ($entry->enclosure($tmp), "Set the enclosure");
+
+ ok (@enclosures = $entry->enclosure, "Got enclosure again");
+ ok ($enclosures[-1]->isa("XML::Feed::Enclosure"), "Object still isa XML::Feed::Enclosure");
+ is ($enclosures[-1]->type, "image/jpeg", "Got the enclosure mime type");
+ is ($enclosures[-1]->length, "1337", "Got enclosure length again");
+ is ($enclosures[-1]->url, "http://example.com/sample_image.jpg", "Got enclosure url again");
+
+ my $xml = $feed->as_xml;
+ ok ($feed = XML::Feed->parse(\$xml), "Parsed xml again");
+ ok (@enclosures = $entry->enclosure, "Got enclosure again");
+ ok ($enclosures[0]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
+ is ($enclosures[0]->type, "audio/mpeg", "Got the enclosure mime type");
+ is ($enclosures[0]->length, "2478719", "Got enclosure length");
+ is ($enclosures[0]->url, "http://example.com/sample_podcast.mp3", "Got enclosure url");
+ ok ($enclosures[1]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
+ is ($enclosures[1]->type, "video/mpeg", "Got the enclosure mime type");
+ is ($enclosures[1]->length, "8888", "Got enclosure length");
+ is ($enclosures[1]->url, "http://example.com/sample_movie.mpg", "Got enclosure url");
+ ok ($enclosures[2]->isa("XML::Feed::Enclosure"), "Object still isa XML::Feed::Enclosure");
+ is ($enclosures[2]->type, "image/jpeg", "Got the enclosure mime type");
+ is ($enclosures[2]->length, "1337", "Got enclosure length again");
+ is ($enclosures[2]->url, "http://example.com/sample_image.jpg", "Got enclosure url again");
+ ok ($enclosures[-1]->isa("XML::Feed::Enclosure"), "Object still isa XML::Feed::Enclosure");
+ is ($enclosures[-1]->type, "image/jpeg", "Got the enclosure mime type");
+ is ($enclosures[-1]->length, "1337", "Got enclosure length again");
+ is ($enclosures[-1]->url, "http://example.com/sample_image.jpg", "Got enclosure url again");
+
+
+}
Modified: branches/upstream/libxml-feed-perl/current/t/samples/atom-multi-enclosure.xml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/t/samples/atom-multi-enclosure.xml?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/t/samples/atom-multi-enclosure.xml (original)
+++ branches/upstream/libxml-feed-perl/current/t/samples/atom-multi-enclosure.xml Fri May 8 06:14:26 2009
@@ -8,7 +8,7 @@
<updated>2004-11-02T14:44:33</updated>
<content>description</content>
<link rel="enclosure" href="http://example.com/sample_podcast.mp3" length="2478719" type="audio/mpeg" />
- <link rel="enclosure" href="http://example.com/sample_movie.mpg" length="2478719" type="video/mpeg" />
+ <link rel="enclosure" href="http://example.com/sample_movie.mpg" length="8888" type="video/mpeg" />
</entry>
</feed>
Modified: branches/upstream/libxml-feed-perl/current/t/samples/rss20-multi-enclosure.xml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-feed-perl/current/t/samples/rss20-multi-enclosure.xml?rev=34927&op=diff
==============================================================================
--- branches/upstream/libxml-feed-perl/current/t/samples/rss20-multi-enclosure.xml (original)
+++ branches/upstream/libxml-feed-perl/current/t/samples/rss20-multi-enclosure.xml Fri May 8 06:14:26 2009
@@ -11,7 +11,7 @@
<pubDate>Tue, 02 Nov 2004 09:44:33 -0500</pubDate>
<description>description</description>
<enclosure url="http://example.com/sample_podcast.mp3" length="2478719" type="audio/mpeg" />
- <enclosure url="http://example.com/sample_movie.mpg" length="2478719" type="video/mpeg" />
+ <enclosure url="http://example.com/sample_movie.mpg" length="8888" type="video/mpeg" />
</item>
</channel>
</rss>
More information about the Pkg-perl-cvs-commits
mailing list