r26682 - in /trunk/libxml-feed-perl: ./ debian/ lib/XML/ lib/XML/Feed/ lib/XML/Feed/Format/ t/ t/samples/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Thu Nov 6 20:08:07 UTC 2008
Author: gregoa
Date: Thu Nov 6 20:08:04 2008
New Revision: 26682
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=26682
Log:
New upstream release, includes a fix for "very hard to handle relative links in
feeds" (closes: #381359).
Added:
trunk/libxml-feed-perl/lib/XML/Feed/Format/
- copied from r26681, branches/upstream/libxml-feed-perl/current/lib/XML/Feed/Format/
trunk/libxml-feed-perl/t/04-splice-atom.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/04-splice-atom.t
trunk/libxml-feed-perl/t/04-splice-rss.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/04-splice-rss.t
trunk/libxml-feed-perl/t/09-missing-content-bug.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/09-missing-content-bug.t
trunk/libxml-feed-perl/t/10-mix-and-match.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/10-mix-and-match.t
trunk/libxml-feed-perl/t/11-xml-base-atom.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/11-xml-base-atom.t
trunk/libxml-feed-perl/t/11-xml-base-rss.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/11-xml-base-rss.t
trunk/libxml-feed-perl/t/pod-coverage.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/pod-coverage.t
trunk/libxml-feed-perl/t/pod.t
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/pod.t
trunk/libxml-feed-perl/t/samples/base_atom.xml
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/samples/base_atom.xml
trunk/libxml-feed-perl/t/samples/base_rss.xml
- copied unchanged from r26681, branches/upstream/libxml-feed-perl/current/t/samples/base_rss.xml
Removed:
trunk/libxml-feed-perl/Build.PL
trunk/libxml-feed-perl/lib/XML/Feed/Atom.pm
trunk/libxml-feed-perl/lib/XML/Feed/RSS.pm
trunk/libxml-feed-perl/t/04-splice.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/Content.pm
trunk/libxml-feed-perl/lib/XML/Feed/Entry.pm
trunk/libxml-feed-perl/t/00-compile.t
trunk/libxml-feed-perl/t/01-parse.t
trunk/libxml-feed-perl/t/02-create.t
Modified: trunk/libxml-feed-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/Changes?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/Changes (original)
+++ trunk/libxml-feed-perl/Changes Thu Nov 6 20:08:04 2008
@@ -1,6 +1,43 @@
-# $Id: Changes 67 2008-10-15 18:11:12Z swistow $
+# $Id: Changes 101 2008-11-04 22:09:14Z swistow $
Revision history for XML::Feed
+
+0.3 2008-11-04
+ - Allow more flexible identification of Formats
+ https://rt.cpan.org/Ticket/Display.html?id=14725
+ (Brian Cassidy BRICAS)
+
+0.23 2008-10-23
+ - Fix mixing and matching of RSS and Atom
+ http://rt.cpan.org/Ticket/Display.html?id=21335
+ (Shlomi Fish SHLOMIF)
+ - Note that multiple categories was fixed at some point
+ http://rt.cpan.org/Ticket/Display.html?id=30234
+ (mattn)
+ - Work with xml:base (depending on version of XML::RSS)
+ http://rt.cpan.org/Ticket/Display.html?id=21135
+ http://bugs.debian.org/381359
+ (Gregor Herrmann and Joey Hess)
+
+0.22 2008-10-22
+ - Correct namespace for terms in RSS
+ http://rt.cpan.org/Ticket/Display.html?id=25393
+ (Kent Cowgill KCOWGILL)
+ - Up the minimum requirement for XML::RSS to 1.31
+ http://rt.cpan.org/Ticket/Display.html?id=23588
+ (Andreas König ANDK)
+ - Created test for
+ http://rt.cpan.org/Ticket/Display.html?id=18810
+ (Ryan Tate)
+ - Allow creation of a self link
+ http://rt.cpan.org/Ticket/Display.html?id=39924
+ (Shlomi Fish SHLOMIF)
+ - Add support for GEORSS
+ http://rt.cpan.org/Ticket/Display.html?id=39924
+ (Scott Gifford GIFF)
+ - Fix fetching through proxies
+ http://rt.cpan.org/Ticket/Display.html?id=36233
+ (Trevor Vallender)
0.21 2008.10.15
- Remove the inc directory because it's not needed anymore
Modified: trunk/libxml-feed-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/MANIFEST?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/MANIFEST (original)
+++ trunk/libxml-feed-perl/MANIFEST Thu Nov 6 20:08:04 2008
@@ -1,10 +1,9 @@
-Build.PL
Changes
lib/XML/Feed.pm
-lib/XML/Feed/Atom.pm
lib/XML/Feed/Content.pm
lib/XML/Feed/Entry.pm
-lib/XML/Feed/RSS.pm
+lib/XML/Feed/Format/Atom.pm
+lib/XML/Feed/Format/RSS.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
@@ -13,15 +12,24 @@
t/00-compile.t
t/01-parse.t
t/02-create.t
-t/04-splice.t
+t/04-splice-atom.t
+t/04-splice-rss.t
t/05-atom10-link.t
t/06-atom10.t
t/07-atom10-create.t
t/08-convert-summary-bug.t
+t/09-missing-content-bug.t
+t/10-mix-and-match.t
+t/11-xml-base-atom.t
+t/11-xml-base-rss.t
t/samples/atom-10-example.xml
t/samples/atom-full.xml
t/samples/atom.xml
+t/samples/base_atom.xml
+t/samples/base_rss.xml
t/samples/rss10-invalid-date.xml
t/samples/rss10.xml
t/samples/rss20-no-summary.xml
t/samples/rss20.xml
+t/pod.t
+t/pod-coverage.t
Modified: trunk/libxml-feed-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/META.yml?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/META.yml (original)
+++ trunk/libxml-feed-perl/META.yml Thu Nov 6 20:08:04 2008
@@ -1,6 +1,6 @@
---
name: XML-Feed
-version: 0.21
+version: 0.3
author: []
abstract: XML Syndication Feed Support
license: perl
@@ -15,27 +15,28 @@
HTML::TokeParser: 0
LWP::UserAgent: 0
List::Util: 0
+ Module::Pluggable: 0
Test::More: 0
URI::Fetch: 0
XML::Atom: 0.23
XML::LibXML: 1.66
- XML::RSS: 1.01
+ XML::RSS: 1.31
provides:
XML::Feed:
file: lib/XML/Feed.pm
- version: 0.21
- XML::Feed::Atom:
- file: lib/XML/Feed/Atom.pm
+ version: 0.3
XML::Feed::Content:
file: lib/XML/Feed/Content.pm
XML::Feed::Entry:
file: lib/XML/Feed/Entry.pm
- XML::Feed::Entry::Atom:
- file: lib/XML/Feed/Atom.pm
- XML::Feed::Entry::RSS:
- file: lib/XML/Feed/RSS.pm
- XML::Feed::RSS:
- file: lib/XML/Feed/RSS.pm
+ XML::Feed::Entry::Format::Atom:
+ file: lib/XML/Feed/Format/Atom.pm
+ XML::Feed::Entry::Format::RSS:
+ file: lib/XML/Feed/Format/RSS.pm
+ XML::Feed::Format::Atom:
+ file: lib/XML/Feed/Format/Atom.pm
+ XML::Feed::Format::RSS:
+ file: lib/XML/Feed/Format/RSS.pm
generated_by: Module::Build version 0.2808
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
Modified: trunk/libxml-feed-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/Makefile.PL?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/Makefile.PL (original)
+++ trunk/libxml-feed-perl/Makefile.PL Thu Nov 6 20:08:04 2008
@@ -13,11 +13,12 @@
'HTML::TokeParser' => '0',
'LWP::UserAgent' => '0',
'List::Util' => '0',
+ 'Module::Pluggable' => '0',
'Test::More' => '0',
'URI::Fetch' => '0',
'XML::Atom' => '0.23',
'XML::LibXML' => '1.66',
- 'XML::RSS' => '1.01'
+ 'XML::RSS' => '1.31'
},
'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=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/debian/changelog (original)
+++ trunk/libxml-feed-perl/debian/changelog Thu Nov 6 20:08:04 2008
@@ -1,7 +1,9 @@
-libxml-feed-perl (0.21-2) UNRELEASED; urgency=low
+libxml-feed-perl (0.30-1) UNRELEASED; urgency=low
* debian/watch: add uversionmangle, upstream now uses 1 digit instead of 2
for minor versions.
+ * New upstream release, includes a fix for "very hard to handle relative links in
+ feeds" (closes: #381359).
-- gregor herrmann <gregoa at debian.org> Thu, 06 Nov 2008 21:00:46 +0100
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=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/lib/XML/Feed.pm (original)
+++ trunk/libxml-feed-perl/lib/XML/Feed.pm Thu Nov 6 20:08:04 2008
@@ -6,17 +6,25 @@
use base qw( Class::ErrorHandler );
use Feed::Find;
use URI::Fetch;
+use LWP::UserAgent;
use Carp;
-
-our $VERSION = '0.21';
+use Module::Pluggable search_path => "XML::Feed::Format",
+ require => 1,
+ sub_name => 'formatters';
+
+our $VERSION = '0.3';
+our @formatters;
+BEGIN {
+ @formatters = __PACKAGE__->formatters;
+}
sub new {
my $class = shift;
my $format = shift || 'Atom';
- my $format_class = 'XML::Feed::' . $format;
+ my $format_class = 'XML::Feed::Format::' . $format;
eval "use $format_class";
Carp::croak("Unsupported format $format: $@") if $@;
- my $feed = bless {}, join('::', __PACKAGE__, $format);
+ my $feed = bless {}, join('::', __PACKAGE__, "Format", $format);
$feed->init_empty(@_) or return $class->error($feed->errstr);
$feed;
}
@@ -30,7 +38,9 @@
my $feed = bless {}, $class;
my $xml = '';
if (UNIVERSAL::isa($stream, 'URI')) {
- my $res = URI::Fetch->fetch($stream)
+ my $ua = LWP::UserAgent->new;
+ $ua->env_proxy; # force allowing of proxies
+ my $res = URI::Fetch->fetch($stream, UserAgent => $ua)
or return $class->error(URI::Fetch->errstr);
return $class->error("This feed has been permanently removed")
if $res->status == URI::Fetch::URI_GONE();
@@ -58,7 +68,7 @@
$format = $feed->identify_format(\$xml) or return $class->error($feed->errstr);
}
- my $format_class = join '::', __PACKAGE__, $format;
+ my $format_class = join '::', __PACKAGE__, "Format", $format;
eval "use $format_class";
return $class->error("Unsupported format $format: $@") if $@;
bless $feed, $format_class;
@@ -67,8 +77,23 @@
}
sub identify_format {
- my $feed = shift;
- my($xml) = @_;
+ my $feed = shift;
+ my($xml) = @_;
+ foreach my $class (@formatters) {
+ my ($name) = ($class =~ m!([^:]+)$!);
+ # TODO ugly
+ my $tmp = $$xml;
+ return $name if eval { $class->identify(\$tmp) };
+ return $feed->error($@) if $@;
+ }
+ return $feed->error("Cannot detect feed type");
+}
+
+sub _get_first_tag {
+ my $class = shift;
+ my ($xml) = @_;
+
+
## Auto-detect feed type based on first element. This is prone
## to breakage, but then again we don't want to parse the whole
## feed ourselves.
@@ -78,15 +103,9 @@
my $first = substr $t, 0, 1;
$tag = $t, last unless $first eq '?' || $first eq '!';
}
- return $feed->error("Cannot find first element") unless $tag;
+ die ("Cannot find first element") unless $tag;
$tag =~ s/^.*://;
- if ($tag eq 'rss' || $tag eq 'RDF') {
- return 'RSS';
- } elsif ($tag eq 'feed') {
- return 'Atom';
- } else {
- return $feed->error("Cannot detect feed type");
- }
+ return $tag;
}
sub find_feeds {
@@ -100,7 +119,7 @@
sub convert {
my $feed = shift;
my($format) = @_;
- my $new = __PACKAGE__->new($format);
+ my $new = XML::Feed->new($format);
for my $field (qw( title link description language author copyright modified generator )) {
my $val = $feed->$field();
next unless defined $val;
@@ -121,9 +140,20 @@
}
}
+sub _convert_entry {
+ my $feed = shift;
+ my $entry = shift;
+ my $feed_format = ref($feed); $feed_format =~ s!^XML::Feed::Format::!!;
+ my $entry_format = ref($entry); $entry_format =~ s!^XML::Feed::Entry::Format::!!;
+ return $entry if $entry_format eq $feed_format;
+ return $entry->convert($feed_format);
+}
+
+sub base;
sub format;
sub title;
sub link;
+sub self_link;
sub description;
sub language;
sub author;
@@ -133,6 +163,7 @@
sub add_entry;
sub entries;
sub as_xml;
+sub id;
sub tagline { shift->description(@_) }
sub items { $_[0]->entries }
@@ -192,6 +223,10 @@
Creates a new empty I<XML::Feed> object using the format I<$format>.
+ $feed = XML::Feed->new('Atom');
+ $feed = XML::Feed->new('RSS');
+ $feed = XML::Feed->new('RSS', version => '0.91');
+
=head2 XML::Feed->parse($stream)
=head2 XML::Feed->parse($stream, $format)
@@ -219,7 +254,7 @@
=back
-C<$format> allows you to override format guessing.
+I<$format> allows you to override format guessing.
=head2 XML::Feed->find_feeds($uri)
@@ -228,6 +263,10 @@
Returns a list of feed URIs.
+=head2 XML::Feed->identify_format($xml)
+
+Given the xml of a feed return what format it is in (C<Atom>, or some version of C<RSS>).
+
=head2 $feed->convert($format)
Converts the I<XML::Feed> object into the I<$format> format, and returns
@@ -246,6 +285,10 @@
The title of the feed/channel.
+=head2 $feed->base([ $base ])
+
+The url base of the feed/channel.
+
=head2 $feed->link([ $uri ])
The permalink of the feed/channel.
@@ -279,11 +322,23 @@
=head2 $feed->generator([ $generator ])
The generator of the feed.
+
+=head2 $feed->self_link ([ $uri ])
+
+The Atom Self-link of the feed:
+
+L<http://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html>
+
+A string.
=head2 $feed->entries
A list of the entries/items in the feed. Returns an array containing
I<XML::Feed::Entry> objects.
+
+=head2 $feed->items
+
+A synonym for I<$feed->entries>.
=head2 $feed->add_entry($entry)
@@ -311,6 +366,46 @@
=back
+=head1 VALID FEEDS
+
+For reference, this cgi script will create valid, albeit nonsensical feeds
+(according to C<http://feedvalidator.org> anyway) for Atom 1.0 and RSS 0.90,
+0.91, 1.0 and 2.0.
+
+ #!perl -w
+
+ use strict;
+ use CGI;
+ use CGI::Carp qw(fatalsToBrowser);
+ use DateTime;
+ use XML::Feed;
+
+ my $cgi = CGI->new;
+ my @args = ( $cgi->param('format') || "Atom" );
+ push @args, ( version => $cgi->param('version') ) if $cgi->param('version');
+
+ my $feed = XML::Feed->new(@args);
+ $feed->id("http://".time.rand()."/");
+ $feed->title('Test Feed');
+ $feed->link($cgi->url);
+ $feed->self_link($cgi->url( -query => 1, -full => 1, -rewrite => 1) );
+ $feed->modified(DateTime->now);
+
+ my $entry = XML::Feed::Entry->new();
+ $entry->id("http://".time.rand()."/");
+ $entry->link("http://example.com");
+ $entry->title("Test entry");
+ $entry->summary("Test summary");
+ $entry->content("Foo");
+ $entry->modified(DateTime->now);
+ $entry->author('test at example.com (Testy McTesterson)');
+ $feed->add_entry($entry);
+
+ my $mime = ("Atom" eq $feed->format) ? "application/atom+xml" : "application/rss+xml";
+ print $cgi->header($mime);
+ print $feed->as_xml;
+
+
=head1 LICENSE
I<XML::Feed> is free software; you may redistribute it and/or modify it
Modified: trunk/libxml-feed-perl/lib/XML/Feed/Content.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/lib/XML/Feed/Content.pm?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/lib/XML/Feed/Content.pm (original)
+++ trunk/libxml-feed-perl/lib/XML/Feed/Content.pm Thu Nov 6 20:08:04 2008
@@ -21,6 +21,7 @@
sub type { shift->_var('type', @_) }
sub body { shift->_var('body', @_) }
+sub base { shift->_var('base', @_) }
1;
__END__
@@ -44,6 +45,14 @@
=head1 USAGE
+=head2 wrap
+
+Take params and turn them into a I<XML::Feed::Content> object.
+
+=head2 new
+
+A synonym for I<wrap>.
+
=head2 $content->body
The actual data.
@@ -56,6 +65,10 @@
the type of content included in an entry. In RSS feeds, generally the MIME
type defaults to I<text/html>.
+=head2 $content->base
+
+The url base of the content.
+
=head1 AUTHOR & COPYRIGHT
Please see the I<XML::Feed> manpage for author, copyright, and license
Modified: trunk/libxml-feed-perl/lib/XML/Feed/Entry.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/lib/XML/Feed/Entry.pm?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/lib/XML/Feed/Entry.pm (original)
+++ trunk/libxml-feed-perl/lib/XML/Feed/Entry.pm Thu Nov 6 20:08:04 2008
@@ -20,10 +20,10 @@
my $class = shift;
my($format) = @_;
$format ||= 'Atom';
- my $format_class = 'XML::Feed::' . $format;
+ my $format_class = 'XML::Feed::Format::' . $format;
eval "use $format_class";
Carp::croak("Unsupported format $format: $@") if $@;
- my $entry = bless {}, join('::', __PACKAGE__, $format);
+ my $entry = bless {}, join('::', __PACKAGE__, "Format", $format);
$entry->init_empty or return $class->error($entry->errstr);
$entry;
}
@@ -34,7 +34,7 @@
my $entry = shift;
my($format) = @_;
my $new = __PACKAGE__->new($format);
- for my $field (qw( title link content summary category author id issued modified )) {
+ for my $field (qw( title link content summary category 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;
@@ -52,6 +52,8 @@
sub id;
sub issued;
sub modified;
+sub lat;
+sub long;
1;
__END__
@@ -87,6 +89,10 @@
=head2 $entry->title([ $title ])
The title of the entry.
+
+=head2 $entry->base([ $base ])
+
+The url base of the entry.
=head2 $entry->link([ $uri ])
@@ -141,6 +147,14 @@
If present, I<$modified> should be a I<DateTime> object.
+=head2 $entry->wrap
+
+Take an entry in its native format and turn it into an I<XML::Feed::Entry> object.
+
+=head2 $entry->unwrap
+
+Take an I<XML::Feed::Entry> object and turn it into its native format.
+
=head1 AUTHOR & COPYRIGHT
Please see the I<XML::Feed> manpage for author, copyright, and license
Modified: trunk/libxml-feed-perl/t/00-compile.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/t/00-compile.t?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/t/00-compile.t (original)
+++ trunk/libxml-feed-perl/t/00-compile.t Thu Nov 6 20:08:04 2008
@@ -5,5 +5,5 @@
use_ok('XML::Feed');
use_ok('XML::Feed::Entry');
-use_ok('XML::Feed::RSS');
-use_ok('XML::Feed::Atom');
+use_ok('XML::Feed::Format::RSS');
+use_ok('XML::Feed::Format::Atom');
Modified: trunk/libxml-feed-perl/t/01-parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/t/01-parse.t?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/t/01-parse.t (original)
+++ trunk/libxml-feed-perl/t/01-parse.t Thu Nov 6 20:08:04 2008
@@ -15,26 +15,26 @@
my $feed;
my $file = 't/samples/atom.xml';
$feed = XML::Feed->parse($file);
-isa_ok($feed, 'XML::Feed::Atom');
+isa_ok($feed, 'XML::Feed::Format::Atom');
is($feed->title, 'First Weblog');
open my $fh, $file or die "Can't open $file: $!";
$feed = XML::Feed->parse($fh);
-isa_ok($feed, 'XML::Feed::Atom');
+isa_ok($feed, 'XML::Feed::Format::Atom');
is($feed->title, 'First Weblog');
seek $fh, 0, 0;
my $xml = do { local $/; <$fh> };
$feed = XML::Feed->parse(\$xml);
-isa_ok($feed, 'XML::Feed::Atom');
+isa_ok($feed, 'XML::Feed::Format::Atom');
is($feed->title, 'First Weblog');
$feed = XML::Feed->parse(URI->new("file:$file"));
-isa_ok($feed, 'XML::Feed::Atom');
+isa_ok($feed, 'XML::Feed::Format::Atom');
is($feed->title, 'First Weblog');
## Then try calling all of the unified API methods.
for my $file (sort keys %Feeds) {
my $feed = XML::Feed->parse($file) or die XML::Feed->errstr;
my($subclass) = $Feeds{$file} =~ /^(\w+)/;
- isa_ok($feed, 'XML::Feed::' . $subclass);
+ isa_ok($feed, 'XML::Feed::Format::' . $subclass);
is($feed->format, $Feeds{$file});
is($feed->language, 'en-us');
is($feed->title, 'First Weblog');
Modified: trunk/libxml-feed-perl/t/02-create.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-feed-perl/t/02-create.t?rev=26682&op=diff
==============================================================================
--- trunk/libxml-feed-perl/t/02-create.t (original)
+++ trunk/libxml-feed-perl/t/02-create.t Thu Nov 6 20:08:04 2008
@@ -1,7 +1,7 @@
# $Id$
use strict;
-use Test::More tests => 69;
+use Test::More tests => 72;
use XML::Feed;
use XML::Feed::Entry;
use XML::Feed::Content;
@@ -9,7 +9,7 @@
for my $format (qw( Atom RSS )) {
my $feed = XML::Feed->new($format);
- isa_ok($feed, 'XML::Feed::' . $format);
+ isa_ok($feed, 'XML::Feed::Format::' . $format);
like($feed->format, qr/^$format/, 'Format is correct');
$feed->title('My Feed');
is($feed->title, 'My Feed', 'feed title is correct');
@@ -35,7 +35,7 @@
ok($feed->as_xml, 'as_xml returns something');
my $entry = XML::Feed::Entry->new($format);
- isa_ok($entry, 'XML::Feed::Entry::' . $format);
+ isa_ok($entry, 'XML::Feed::Entry::Format::' . $format);
$entry->title('Foo Bar');
is($entry->title, 'Foo Bar', 'entry title is correct');
$entry->link('http://www.example.com/foo/bar.html');
@@ -76,4 +76,21 @@
if ($format eq 'Atom') {
like $feed->as_xml, qr/This is the content/;
}
+ if ($format eq 'RSS') {
+ like $feed->as_xml, qr{xmlns:dcterms="http://purl.org/dc/terms/"};
+ }
+
+ $feed->self_link("http://tor.tld/my-feed.rss");
+
+ if ($format eq "RSS")
+ {
+ like ($feed->as_xml(), qr{\Q<atom:link href="http://tor.tld/my-feed.rss" rel="self" type="application/rss+xml"/>\E},
+ "Feed contains the atom:link");
+ }
+ elsif ($format eq "Atom")
+ {
+ like ($feed->as_xml(), qr{\Q<link rel="self" href="http://tor.tld/my-feed.rss" type="application/atom+xml"/>\E},
+ "Feed contains the atom:link");
+ }
+
}
More information about the Pkg-perl-cvs-commits
mailing list