Subject: | [patch] Multiple categories are lost in conversion |
Here is a trivial patch with test and all.
Thanks!
Subject: | xml-feed.diff |
Index: t/16-convert-mult-categories.t
===================================================================
--- t/16-convert-mult-categories.t (revision 0)
+++ t/16-convert-mult-categories.t (revision 0)
@@ -0,0 +1,21 @@
+# $Id$
+
+use strict;
+use Test::More tests => 2;
+use XML::Feed;
+
+my $feed = XML::Feed->parse("t/samples/rss-multiple-categories.xml");
+
+my ($entry) = $feed->entries;
+
+is_deeply(
+ [$entry->category()],
+ ["foo", "bar", "quux", "simon's tags"],
+"Got all categories");
+
+my ($converted_entry) = $feed->convert('Atom')->entries;
+
+is_deeply(
+ [$converted_entry->category()],
+ ["foo", "bar", "quux", "simon's tags"],
+"All categories in place after conversion");
Index: lib/XML/Feed/Entry.pm
===================================================================
--- lib/XML/Feed/Entry.pm (revision 153)
+++ lib/XML/Feed/Entry.pm (working copy)
@@ -34,12 +34,17 @@
my $entry = shift;
my($format) = @_;
my $new = __PACKAGE__->new($format);
- for my $field (qw( title link content summary category author id issued modified lat long )) {
+ for my $field (qw( title link content summary author id issued modified lat long )) {
my $val = $entry->$field();
next unless defined $val;
next if blessed $val && $val->isa('XML::Feed::Content') && ! defined $val->body;
$new->$field($val);
}
+ for my $field (qw( category )) {
+ my @val = $entry->$field();
+ next unless @val;
+ $new->$field(@val);
+ }
$new;
}