[Bast-commits] r9991 - in ironman/Perlanet-IronMan/trunk: bin lib/Perlanet

idn at dev.catalyst.perl.org idn at dev.catalyst.perl.org
Sun Oct 21 15:18:47 GMT 2012


Author: idn
Date: 2012-10-21 15:18:47 +0000 (Sun, 21 Oct 2012)
New Revision: 9991

Modified:
   ironman/Perlanet-IronMan/trunk/bin/ironman-collector.pl
   ironman/Perlanet-IronMan/trunk/lib/Perlanet/IronMan.pm
Log:
Merging changes back from ironboy into trunk

Modified: ironman/Perlanet-IronMan/trunk/bin/ironman-collector.pl
===================================================================
--- ironman/Perlanet-IronMan/trunk/bin/ironman-collector.pl	2012-10-21 13:32:25 UTC (rev 9990)
+++ ironman/Perlanet-IronMan/trunk/bin/ironman-collector.pl	2012-10-21 15:18:47 UTC (rev 9991)
@@ -18,35 +18,45 @@
     'v'           => \$DEBUG,
 ) or die pod2usage;
 
-# Perlanet configuration settings
-my $cfg = {};
-$cfg->{title}           = "all.things.per.ly";
-$cfg->{description}     = "all.things.per.ly IronMan agregation";
-$cfg->{url}             = "http://ironboy.enlightenedperl.org/";
-$cfg->{self_link}       = "http://ironboy.enlightenedperl.org/";
-$cfg->{agent}           = "Perlanet";
-$cfg->{author}->{name}  = "Perlanet";
-$cfg->{feed}->{format}  = "Atom";
-$cfg->{entries}         = 10;
+my $dsn = "dbi:SQLite:/var/www/ironboy.enlightenedperl.org/ironman/subscriptions.db";
 
-$cfg->{filter}->{keywords} = ["cpan", "ironman", "perl"];
-
 # Database DSN
 if(defined($cli_dsn)) {
-    $cfg->{db}{dsn} = $cli_dsn;
+    $dsn = $cli_dsn;
 }
 
-else {
-    $cfg->{db}{dsn} = "dbi:SQLite:/var/www/ironboy.enlightenedperl.org/ironman/subscriptions.db";
-}
+# Schema for our database
+my $schema = IronMan::Schema->connect($dsn);
 
-# Get me a Perlanet::IronMan thingy using our config from above
-my $p = Perlanet::IronMan->new( cfg => $cfg );
+# Perlanet configuration settings
+#my $cfg = {};
+#$cfg->{title}           = "all.things.per.ly";
+#$cfg->{description}     = "all.things.per.ly IronMan agregation";
+#$cfg->{url}             = "http://ironboy.enlightenedperl.org/";
+#$cfg->{self_link}       = "http://ironboy.enlightenedperl.org/";
+#$cfg->{agent}           = "Perlanet";
+#$cfg->{author}->{name}  = "Perlanet";
+#$cfg->{feed}->{format}  = "Atom";
+#$cfg->{entries}         = 10;
+#
+#$cfg->{filter}->{keywords} = ["cpan", "ironman", "perl"];
 
-# Should be calling run here
-#$p->run;
-#exit;
+# Get me a Perlanet::IronMan thingy using our schema
+my $p = Perlanet::IronMan->new({
+    author      => { name   => "Perlanet" },
+    title       => "ironman.enlightenedperl.org",
+    description => "ironman.enlightenedperl.org IronMan Blog Aggregation",
+    url         => "http://ironman.enlightenedperl.org/",
+    self_link   => "http://ironman.enlightenedperl.org/",
+    agent       => "Perlanet::IronMan",
+    author      => { name   => "Perlanet::IronMan" },
+    feed        => { format => "Atom" },
 
+    # Ironman specifics
+    filter      => { keywords => ["cpan", "ironman", "perl"] },
+    schema      => $schema,
+});
+
 # Get the list of feeds from the database
 print("Fetching the Perlanet::Feed objects array\n");
 my $feeds_obj = $p->feeds;
@@ -78,7 +88,7 @@
     if($DEBUG) { print("Fetching posts from feed '" . $feed_obj->url . "'\n"); }
     my @feed_posts = $p->fetch_feeds( $feed_obj );
 
-    #if($DEBUG) { print(Dumper(@feed_posts)); }
+    if($DEBUG) { print(Dumper(@feed_posts)); }
     if($DEBUG) { print("Filtering posts to remove duplicates\n"); }
 
     # Filter feed_posts for previously seen posts

Modified: ironman/Perlanet-IronMan/trunk/lib/Perlanet/IronMan.pm
===================================================================
--- ironman/Perlanet-IronMan/trunk/lib/Perlanet/IronMan.pm	2012-10-21 13:32:25 UTC (rev 9990)
+++ ironman/Perlanet-IronMan/trunk/lib/Perlanet/IronMan.pm	2012-10-21 15:18:47 UTC (rev 9991)
@@ -5,6 +5,7 @@
 use warnings;
 
 use Moose;
+use Data::Dumper;
 use IronMan::Schema;
 use HTML::Truncate;
 use Try::Tiny;
@@ -104,6 +105,12 @@
     } $self->schema->resultset('Feed')->all ];
 };
 
+has 'filter' => (
+  isa     => 'HashRef',
+  is      => 'ro',
+);
+
+
 =head2 render
 
 Given a Perlanet::Entry object, store the entry as a post in the
@@ -150,9 +157,9 @@
                 title            => $post->_entry->title,
                 posted_on        => $post->_entry->issued || DateTime->now,
                 summary          => $summary,
-                summary_filtered => $self->clean($summary),
+                summary_filtered => $self->clean_html($summary),
                 body             => $post->_entry->content->body,
-                body_filtered    => $self->clean($post->_entry->content->body),
+                body_filtered    => $self->clean_html($post->_entry->content->body),
             } );
         }
 
@@ -312,12 +319,12 @@
     # print("Called to keyword filter url '" . $xml_entry->link . "'\n");
 
     # If no filter is defined, then we pass.
-    unless(defined($self->{cfg}->{filter}->{keywords})) {
+    unless(defined($self->filter->{keywords})) {
         print("No filter defined so skipping this check.\n");
         return 1;
     }
 
-    my $filters = $self->{cfg}->{filter}->{keywords};
+    my $filters = $self->filter->{keywords};
 
     # Iterate through the defined filters checking them
     foreach my $filter (@ { $filters } ) {




More information about the Bast-commits mailing list