Skip to content

Commit 7b5fccb

Browse files
committed
Closed a few tickets from the RT queue as an excuse for a new release. Bumped to version 0.46.
1 parent f4278e1 commit 7b5fccb

File tree

7 files changed

+65
-9
lines changed

7 files changed

+65
-9
lines changed

MANIFEST

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ Makefile.PL
6262
META.json
6363
t/19-double3.t
6464
t/samples/rss10-double2.xml
65+
t/20-no-enclosures.t
66+
t/21-rss2-permalinks.t
67+
t/samples/rss20-p.xml
68+

lib/XML/Feed.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use Module::Pluggable search_path => "XML::Feed::Format",
1212
require => 1,
1313
sub_name => 'formatters';
1414

15-
our $VERSION = '0.45';
15+
our $VERSION = '0.46';
1616
our $MULTIPLE_ENCLOSURES = 0;
1717
our @formatters;
1818
BEGIN {
@@ -355,13 +355,13 @@ the current format of the I<$feed> object.
355355
356356
=over 4
357357
358-
=item C<$XML::Feed::RSS::PREFERRED_PARSER>
358+
=item C<$XML::Feed::Format::RSS::PREFERRED_PARSER>
359359
360360
If you want to use another RSS parser class than XML::RSS (default), you can
361-
change the class by setting C<$PREFERRED_PARSER> variable in XML::Feed::RSS
362-
package.
361+
change the class by setting C<$PREFERRED_PARSER> variable in the
362+
XML::Feed::Format::RSS package.
363363
364-
$XML::Feed::RSS::PREFERRED_PARSER = "XML::RSS::LibXML";
364+
$XML::Feed::Format::RSS::PREFERRED_PARSER = "XML::RSS::LibXML";
365365
366366
B<Note:> this will only work for parsing feeds, not creating feeds.
367367

lib/XML/Feed/Format/Atom.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ sub enclosure {
319319
return 1;
320320
} else {
321321
my @links = grep { defined $_->rel && $_->rel eq 'enclosure' } $entry->{entry}->link;
322-
return undef unless @links;
322+
return unless @links;
323323
my @encs = map { XML::Feed::Enclosure->new({ url => $_->href, length => $_->length, type => $_->type }) } @links ;
324324
return ($XML::Feed::MULTIPLE_ENCLOSURES)? @encs : $encs[-1];
325325
}

lib/XML/Feed/Format/RSS.pm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use base qw( XML::Feed );
77
use DateTime::Format::Mail;
88
use DateTime::Format::W3CDTF;
99
use XML::Atom::Util qw(iso2dt);
10+
use XML::Feed::Enclosure;
1011

1112
our $PREFERRED_PARSER = "XML::RSS";
1213

@@ -190,7 +191,9 @@ sub link {
190191
## For RSS 2.0 output from XML::RSS. Sigh.
191192
$entry->{entry}{permaLink} = $_[0];
192193
} else {
193-
$entry->{entry}{link} || $entry->{entry}{guid};
194+
$entry->{entry}{link} ||
195+
$entry->{entry}{permaLink} ||
196+
$entry->{entry}{guid};
194197
}
195198
}
196199

@@ -356,8 +359,12 @@ sub enclosure {
356359
}
357360
} else {
358361
my $tmp = $entry->{entry}->{enclosure};
359-
my @encs = map { XML::Feed::Enclosure->new($_) } (ref $tmp eq 'ARRAY')? @$tmp : ($tmp);
360-
return ($XML::Feed::MULTIPLE_ENCLOSURES)? @encs : $encs[-1];
362+
if (defined $tmp) {
363+
my @encs = map { XML::Feed::Enclosure->new($_) }
364+
(ref $tmp eq 'ARRAY')? @$tmp : ($tmp);
365+
return ($XML::Feed::MULTIPLE_ENCLOSURES)? @encs : $encs[-1];
366+
}
367+
return;
361368
}
362369
}
363370

t/20-no-enclosures.t

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use strict;
2+
use Test::More;
3+
4+
use XML::Feed;
5+
6+
my @formats = qw/rss20 atom/;
7+
8+
plan tests => 2*@formats;
9+
10+
for my $format (@formats) {
11+
ok (my $feed = XML::Feed->parse("t/samples/$format.xml"), "Parsed $format");
12+
my ($entry) = $feed->entries;
13+
my @enclosure = $entry->enclosure;
14+
is(@enclosure, 0);
15+
}

t/21-rss2-permalinks.t

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use strict;
2+
use warnings;
3+
4+
use Test::More tests => 2;
5+
use XML::Feed;
6+
7+
my $file = 't/samples/rss20-p.xml';
8+
my $feed = XML::Feed->parse($file);
9+
isa_ok($feed, 'XML::Feed::Format::RSS');
10+
my $entry = ($feed->entries)[0];
11+
is($entry->link, 'http://creograf.ru/post/regexp -js');

t/samples/rss20-p.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<rss version="2.0"
3+
xmlns:blogChannel="http://backend.userland.com/blogChannelModule">
4+
<channel>
5+
<title>Some title</title>
6+
<link>http://creograf.ru/blog/4progr ammer</link>
7+
<description>Some desc</description>
8+
<language>ru-ru</language>
9+
<pubDate>Sun, 3 Apr 2011 05:42:15 +0300</pubDate>
10+
<lastBuildDate>Sun, 3 Apr 2011 05:42:15 +0300</lastBuildDate>
11+
12+
<item>
13+
<title>Some entry</title>i
14+
<description></description>
15+
<guid isPermaLink="true">http://creograf.ru/post/regexp -js</guid>
16+
<pubDate>Sun, 3 Apr 2011 05:42:12 +0300</pubDate>
17+
</item>
18+
</channel>
19+
</rss>

0 commit comments

Comments
 (0)