[Bast-commits] r9021 - ironman/Perlanet-IronMan/bin

idn at dev.catalyst.perl.org idn at dev.catalyst.perl.org
Wed Mar 17 22:20:03 GMT 2010


Author: idn
Date: 2010-03-17 22:20:03 +0000 (Wed, 17 Mar 2010)
New Revision: 9021

Modified:
   ironman/Perlanet-IronMan/bin/ironman-collector.pl
Log:
Added CLI options for debug and to fetch a specific feed.  Lots of optional debug added

Modified: ironman/Perlanet-IronMan/bin/ironman-collector.pl
===================================================================
--- ironman/Perlanet-IronMan/bin/ironman-collector.pl	2010-03-17 22:18:59 UTC (rev 9020)
+++ ironman/Perlanet-IronMan/bin/ironman-collector.pl	2010-03-17 22:20:03 UTC (rev 9021)
@@ -3,11 +3,21 @@
 use strict;
 use warnings;
 
+use XML::Feed;
+use Data::Dumper;
+use Getopt::Long;
+use Pod::Usage;
 use Perlanet::IronMan;
-use XML::Feed;
 use IronMan::Schema;
-use Data::Dumper;
 
+my ($cli_dsn, $cli_feed, $DEBUG);
+
+GetOptions(
+    'dsn=s'       => \$cli_dsn,
+    'feed=s'      => \$cli_feed,
+    'v'           => \$DEBUG,
+) or die pod2usage;
+
 # Perlanet configuration settings
 my $cfg = {};
 $cfg->{title} = "all.things.per.ly";
@@ -21,10 +31,16 @@
 
 $cfg->{filter}->{keywords} = ["cpan", "ironman", "perl"];
 
-# Database
-$cfg->{db}{dsn} = "dbi:SQLite:/var/www/ironboy.enlightenedperl.org/ironman/subscriptions.db";
-#$cfg->{db}{dsn} = "dbi:SQLite:/var/www/ironboy.enlightenedperl.org/ironman/testsubscriptions.db";
+# Database DSN
+if(defined($cli_dsn)) {
+    $cfg->{db}{dsn} = $cli_dsn;
+}
 
+else {
+    $cfg->{db}{dsn} = "dbi:SQLite:/var/www/ironboy.enlightenedperl.org/ironman/subscriptions.db";
+    #$cfg->{db}{dsn} = "dbi:SQLite:/var/www/ironboy.enlightenedperl.org/ironman/testsubscriptions.db";
+}
+
 # Get me a Perlanet::IronMan thingy using our config from above
 my $p = Perlanet::IronMan->new( cfg => $cfg );
 
@@ -49,34 +65,43 @@
 #               'author' => ''
 #             }, 'Perlanet::Feed' )
 
-#print(Dumper($feeds_obj));
+#if($DEBUG) { print(Dumper($feeds_obj)); }
 #exit;
 
-#print("Fetching the feed data\n");
+if($DEBUG) { print("Fetching the feed data\n"); }
 #my @feeds_data = $p->fetch_feeds( @{ $feeds_obj } );
 
 foreach my $feed_obj ( @{ $feeds_obj } ) {
-    #print("Fetching posts from feed '" . $feed_obj->url . "'\n");
+
+    if(defined($cli_feed)) {
+        unless($feed_obj->url eq $cli_feed) {
+            next;
+        }
+    }
+
+    if($DEBUG) { print("Feed object:\n"); print(Dumper($feed_obj)); }
+
+    if($DEBUG) { print("Fetching posts from feed '" . $feed_obj->url . "'\n"); }
     my @feed_posts = $p->fetch_feeds( $feed_obj );
 
-    #print(Dumper(@feed_posts));
-    #exit;
+    #if($DEBUG) { print(Dumper(@feed_posts)); }
 
-    #print("Filtering posts to remove duplicates\n");
+    if($DEBUG) { print("Filtering posts to remove duplicates\n"); }
     # Filter feed_posts for previously seen posts
     @feed_posts = $p->select_entries(@feed_posts);
 
-    #print(Dumper(@feed_posts));
-    #exit;
+    if($DEBUG) { print(Dumper(@feed_posts)); }
 
-    #print("Building a post object\n");
+    if($DEBUG) { print("Building a post object\n"); }
     my $post = $p->build_feed(@feed_posts);
+    if($DEBUG) { print(Dumper($post)); }
+
+    if($DEBUG) { print("Rendering post object\n"); }
     $p->render($post);
 
 }
 
 
-#print(Dumper(@feeds_data));
 #exit;
 
 # Get the entries from the feeds data




More information about the Bast-commits mailing list