Skip to content

Commit

Permalink
Allow accessors to make sure things validate
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwistow committed Aug 22, 2008
1 parent 4b70ec2 commit e8fcbc5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -12,6 +12,9 @@ Revision history for XML::Feed
- Force working version XML::Atom
http://rt.cpan.org/Public/Bug/Display.html?id=22548
http://rt.cpan.org/Public/Bug/Display.html?id=19920
- Allow extra Atom accessors
http://rt.cpan.org/Public/Bug/Display.html?id=33881
(Paul Mison PMISON)

0.12 2006.08.13
- Generate Atom 1.0 feeds by default. Thanks to Tatsuhiko Miyagawa for
Expand Down
8 changes: 7 additions & 1 deletion lib/XML/Feed/Atom.pm
Expand Up @@ -44,6 +44,9 @@ sub description { shift->{atom}->tagline(@_) }
sub copyright { shift->{atom}->copyright(@_) }
sub language { shift->{atom}->language(@_) }
sub generator { shift->{atom}->generator(@_) }
sub id { shift->{atom}->id(@_) }
sub updated { shift->{atom}->updated(@_) }
sub add_link { shift->{atom}->add_link(@_) }

sub author {
my $feed = shift;
Expand Down Expand Up @@ -98,6 +101,9 @@ sub init_empty {
}

sub title { shift->{entry}->title(@_) }
sub source { shift->{entry}->source(@_) }
sub updated { shift->{entry}->updated(@_) }

sub link {
my $entry = shift;
if (@_) {
Expand Down Expand Up @@ -152,7 +158,7 @@ sub category {
$entry->{entry}->add_category({ term => $_[0] });
} else {
my $category = $entry->{entry}->category;
$category ? ($category->label || $category->term) : $entry->{entry}->get($ns, 'subject');
$category ? ($category->label || $category->term) : $entry->{entry}->getlist($ns, 'subject');
}
}

Expand Down
13 changes: 12 additions & 1 deletion t/07-atom10-create.t
@@ -1,20 +1,27 @@
use strict;
use Test::More;

plan 'no_plan';
plan tests => 17;

use XML::Feed;
use DateTime;

my $now = DateTime->now();

my $feed = XML::Feed->new('Atom');
$feed->title("foo");
$feed->description("Atom 1.0 feed");
$feed->link("http://example.org/");
$feed->id("tag:cpan.org;xml-feed-atom");
$feed->updated($now);

my $entry = XML::Feed::Entry->new('Atom');
$entry->title("1st Entry");
$entry->link("http://example.org/");
$entry->category("blah");
$entry->content("<p>Hello world.</p>");
$entry->id("tag:cpan.org;xml-feed-atom-entry");
$entry->updated($now);

$feed->add_entry($entry);

Expand All @@ -29,6 +36,8 @@ is $feed->format, 'Atom';
is $feed->title, "foo";
is $feed->description, "Atom 1.0 feed";
is $feed->link, "http://example.org/";
is $feed->id, "tag:cpan.org;xml-feed-atom";
is $feed->updated, $now;

my @entries = $feed->entries;
is @entries, 1;
Expand All @@ -40,5 +49,7 @@ is $entry->category, 'blah';
is $entry->content->type, 'text/html';
like $entry->content->body, qr!\s*<p>Hello world.</p>\s*!s;

is $entry->id, "tag:cpan.org;xml-feed-atom-entry";
is $entry->updated, $now;


0 comments on commit e8fcbc5

Please sign in to comment.