r34930 - in /trunk/libxml-feed-perl: ./ debian/ 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:17:45 UTC 2009


Author: ryan52-guest
Date: Fri May  8 06:17:39 2009
New Revision: 34930

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=34930
Log:
New upstream release

Added:
    trunk/libxml-feed-perl/t/14-multi-enclosures.t
      - copied unchanged from r34928, branches/upstream/libxml-feed-perl/current/t/14-multi-enclosures.t
Modified:
    trunk/libxml-feed-perl/Changes
    trunk/libxml-feed-perl/MANIFEST
    trunk/libxml-feed-perl/META.yml
    trunk/libxml-feed-perl/Makefile.PL
    trunk/libxml-feed-perl/debian/changelog
    trunk/libxml-feed-perl/lib/XML/Feed.pm
    trunk/libxml-feed-perl/lib/XML/Feed/Format/Atom.pm
    trunk/libxml-feed-perl/lib/XML/Feed/Format/RSS.pm
    trunk/libxml-feed-perl/t/samples/atom-multi-enclosure.xml
    trunk/libxml-feed-perl/t/samples/rss20-multi-enclosure.xml

Modified: trunk/libxml-feed-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/Changes?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/Changes (original)
+++ trunk/libxml-feed-perl/Changes Fri May  8 06:17:39 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: trunk/libxml-feed-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/MANIFEST?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/MANIFEST (original)
+++ trunk/libxml-feed-perl/MANIFEST Fri May  8 06:17:39 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: trunk/libxml-feed-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/META.yml?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/META.yml (original)
+++ trunk/libxml-feed-perl/META.yml Fri May  8 06:17:39 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: trunk/libxml-feed-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/Makefile.PL?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/Makefile.PL (original)
+++ trunk/libxml-feed-perl/Makefile.PL Fri May  8 06:17:39 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: trunk/libxml-feed-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/debian/changelog?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/debian/changelog (original)
+++ trunk/libxml-feed-perl/debian/changelog Fri May  8 06:17:39 2009
@@ -1,3 +1,9 @@
+libxml-feed-perl (0.43+dfsg-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Ryan Niebur <ryanryan52 at gmail.com>  Thu, 07 May 2009 23:15:54 -0700
+
 libxml-feed-perl (0.42+dfsg-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libxml-feed-perl/lib/XML/Feed.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/lib/XML/Feed.pm?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/lib/XML/Feed.pm (original)
+++ trunk/libxml-feed-perl/lib/XML/Feed.pm Fri May  8 06:17:39 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: trunk/libxml-feed-perl/lib/XML/Feed/Format/Atom.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/lib/XML/Feed/Format/Atom.pm?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/lib/XML/Feed/Format/Atom.pm (original)
+++ trunk/libxml-feed-perl/lib/XML/Feed/Format/Atom.pm Fri May  8 06:17:39 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: trunk/libxml-feed-perl/lib/XML/Feed/Format/RSS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/lib/XML/Feed/Format/RSS.pm?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/lib/XML/Feed/Format/RSS.pm (original)
+++ trunk/libxml-feed-perl/lib/XML/Feed/Format/RSS.pm Fri May  8 06:17:39 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];
     }
 }
 

Modified: trunk/libxml-feed-perl/t/samples/atom-multi-enclosure.xml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/t/samples/atom-multi-enclosure.xml?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/t/samples/atom-multi-enclosure.xml (original)
+++ trunk/libxml-feed-perl/t/samples/atom-multi-enclosure.xml Fri May  8 06:17:39 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: trunk/libxml-feed-perl/t/samples/rss20-multi-enclosure.xml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/t/samples/rss20-multi-enclosure.xml?rev=34930&op=diff
==============================================================================
--- trunk/libxml-feed-perl/t/samples/rss20-multi-enclosure.xml (original)
+++ trunk/libxml-feed-perl/t/samples/rss20-multi-enclosure.xml Fri May  8 06:17:39 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