[Bast-commits] r8094 - in ironman/Perlanet-IronMan: lib/Perlanet t
aCiD2 at dev.catalyst.perl.org
aCiD2 at dev.catalyst.perl.org
Sat Dec 12 21:29:19 GMT 2009
Author: aCiD2
Date: 2009-12-12 21:29:19 +0000 (Sat, 12 Dec 2009)
New Revision: 8094
Modified:
ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm
ironman/Perlanet-IronMan/t/01_basic.t
Log:
Override build_feeds to load feeds from the database
Modified: ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm
===================================================================
--- ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm 2009-12-12 21:20:53 UTC (rev 8093)
+++ ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm 2009-12-12 21:29:19 UTC (rev 8094)
@@ -2,6 +2,7 @@
use Moose;
use IronMan::Schema;
+use Perlanet::Feed;
extends 'Perlanet';
@@ -19,11 +20,28 @@
);
}
+override '_build_feeds' => sub {
+ my $self = shift;
+ return [ map {
+ Perlanet::Feed->new(
+ url => $_->url,
+ website => $_->link,
+ title => $_->title,
+ author => $_->owner
+ );
+ } $self->schema->resultset('Feed')->all ];
+};
+
around 'select_entries' => sub {
my $orig = shift;
my ($self, @feeds) = @_;
- my @all = $self->$orig();
- return $self->schema->resultset('Feed')->filter_unseen(@all);
+ my @entries;
+ for my $feed (@feeds) {
+ push @entries, $self->schema->resultset('Feed')->filter_unseen($feed->url,
+ $feed->entries);
+ }
+
+ return @entries;
};
override 'render' => sub {
@@ -31,7 +49,6 @@
$self->schema->resultset('Post')->populate(
map {
+{
- feed_id => ?,
url => $_->link,
title => $_->title,
posted_on => $_->issued,
@@ -40,7 +57,7 @@
body => $_->content->body,
body_filtered => $self->clean($_->content->body),
}
- } $feed->entries
+ } @{ $feed->entries }
);
};
Modified: ironman/Perlanet-IronMan/t/01_basic.t
===================================================================
--- ironman/Perlanet-IronMan/t/01_basic.t 2009-12-12 21:20:53 UTC (rev 8093)
+++ ironman/Perlanet-IronMan/t/01_basic.t 2009-12-12 21:29:19 UTC (rev 8094)
@@ -16,7 +16,7 @@
owner => '',
title => "Dave's Blog",
});
-$schema->resultset('Post')->create({ url => 'http://blog.dave.org.uk/2009/10/updates-from-jesusistan.html'
+$schema->resultset('Post')->create({ url => 'http://blog.dave.org.uk/2009/10/updates-from-jesusistan.html',
feed_id => 'dave',
title => 'Entry 1',
posted_on => DateTime->now,
More information about the Bast-commits
mailing list