r22481 - in /branches/upstream/libpoe-component-rssaggregator-perl: ./ current/ current/examples/ current/lib/ current/lib/POE/ current/lib/POE/Component/ current/t/

azatoth-guest at users.alioth.debian.org azatoth-guest at users.alioth.debian.org
Sun Jun 29 17:47:01 UTC 2008


Author: azatoth-guest
Date: Sun Jun 29 17:47:00 2008
New Revision: 22481

URL: http://svn.debian.org/wsvn/?sc=1&rev=22481
Log:
[svn-inject] Installing original source of libpoe-component-rssaggregator-perl

Added:
    branches/upstream/libpoe-component-rssaggregator-perl/
    branches/upstream/libpoe-component-rssaggregator-perl/current/
    branches/upstream/libpoe-component-rssaggregator-perl/current/Changes
    branches/upstream/libpoe-component-rssaggregator-perl/current/MANIFEST
    branches/upstream/libpoe-component-rssaggregator-perl/current/META.yml
    branches/upstream/libpoe-component-rssaggregator-perl/current/Makefile.PL
    branches/upstream/libpoe-component-rssaggregator-perl/current/README
    branches/upstream/libpoe-component-rssaggregator-perl/current/examples/
    branches/upstream/libpoe-component-rssaggregator-perl/current/examples/example-1.pl
    branches/upstream/libpoe-component-rssaggregator-perl/current/lib/
    branches/upstream/libpoe-component-rssaggregator-perl/current/lib/POE/
    branches/upstream/libpoe-component-rssaggregator-perl/current/lib/POE/Component/
    branches/upstream/libpoe-component-rssaggregator-perl/current/lib/POE/Component/RSSAggregator.pm
    branches/upstream/libpoe-component-rssaggregator-perl/current/t/
    branches/upstream/libpoe-component-rssaggregator-perl/current/t/00-load.t
    branches/upstream/libpoe-component-rssaggregator-perl/current/t/01-basic.t
    branches/upstream/libpoe-component-rssaggregator-perl/current/t/boilerplate.t
    branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod-coverage.t
    branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod.t

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/Changes?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/Changes (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/Changes Sun Jun 29 17:47:00 2008
@@ -1,0 +1,81 @@
+Revision history for POE-Component-RSSAggregator
+
+1.022   11/06/2006
+        - No need to update, cpants META.yml fix, needed to update to
+          ExtUtils::MakeMaker 6.31 for META.yml update (part deux)
+
+1.021   11/05/2006
+        - No need to update, cpants META.yml fix, needed to update to
+          ExtUtils::MakeMaker 6.31 for META.yml update
+
+1.02    11/01/2006
+        - Fixed cpants META.yaml issue
+
+1.01    - Missed renaming a fetch to _fetch when the delay was set
+          Thanks to Kester Edmonds for reporting it.
+
+1.0     - Wrote decent pod for the module (finally)
+        - Updated pod template to perl best practices template
+        - renamed methods that should have only be internal
+            - renamed fetch to internal _fetch
+            - renamed response to internal _response
+
+0.3     - Added POE::Component::Client::DNS as a dependency
+
+0.29
+	- New shutdown event to clean things up
+	- New feed_list method to get the current feeds
+	- Updated some of the debug messages
+	- Fix to to pause_feed in case there isn't a feed to pause
+	- The begins of a PoCo::Server::HTTP test suite so I can actually 
+	  write tests for it
+	- Defaulted POE::Component::Client::HTTP to FollowRedirects => 2, 
+	  and allow to set the number of redirects via 
+
+	      POE::Component::RSSAggregator->new(
+	        ...
+		follow_redirects => 4,
+	      );
+
+	- Need to write MUCH, MUCH, better documentation... its next!
+
+0.28    - Squelched uninitialized -d test on tmpdir when its not
+	  defined.
+
+0.27    - Updated pod (removed reference to XML::RSS::Feed::Factory)
+	- removed calls to failed_to_fetch and failed_to_parse
+
+0.26    - fixed 'remove_feed' so that it when it yielded 'pause_feed'
+	  that it would actually work.
+	- updated pod to show 'alias' as a new() param
+
+0.25    - ATTENTION! new() param 'feeds' has been deprecated, use 
+	  add_feed instead
+
+	      $heap->{rssagg} = POE::Component::RSSAggregator->new(
+		  debug    => 1,
+		  callback => $session->postback("handle_feed"),
+		  tmpdir   => '/tmp', # optional caching
+	      );
+
+	    $kernel->post('rssagg','add_feed',$_) for @feeds;
+	
+	- fixed the pod not to use XML::RSS::Feed::Factory in the example
+
+0.20    - ATTENTION! You no longer need to use XML::RSS::Feed::Factory
+	  to defined 'feeds', just pass an array ref of hash refs 
+	  for each feed you'd like to watch.
+	- Fixed POD example so it actually works :D
+	- added 'tmpdir' param to pass to XML::RSS::Feed objects to 
+	  cache XML on DESTROY and to attempt to load and parse old
+	  headlines when the object is initialized.
+	- added 'feed' accessor method to fetch XML::RSS::Feed objects
+
+0.10    - Now use XML::RSS::Headline instead of XML::RSS::Feed::Headline
+	- added an accessor 'feeds' for to the hash of rss feeds
+	- use delay_set instead of delay_add.  This is for the future
+	  support of adding, reloading, removing feeds.
+	- use POE postback instead of sub reference for callback
+	- updated the pod with a POE session example
+
+0.01    - First version, released on an unsuspecting world.

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/MANIFEST?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/MANIFEST (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/MANIFEST Sun Jun 29 17:47:00 2008
@@ -1,0 +1,12 @@
+Changes
+lib/POE/Component/RSSAggregator.pm
+Makefile.PL
+MANIFEST
+META.yml			# Will be created by "make dist"
+README
+examples/example-1.pl
+t/00-load.t
+t/01-basic.t
+t/boilerplate.t
+t/pod-coverage.t
+t/pod.t

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/META.yml?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/META.yml (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/META.yml Sun Jun 29 17:47:00 2008
@@ -1,0 +1,19 @@
+--- #YAML:1.0
+name:                POE-Component-RSSAggregator
+version:             1.022
+abstract:            Watch Muliple RSS Feeds for New Headlines
+license:             perl
+generated_by:        ExtUtils::MakeMaker version 6.31
+distribution_type:   module
+requires:     
+    Carp:                          0
+    HTTP::Request:                 1.3
+    POE::Component::Client::DNS:   0.98
+    POE::Component::Client::HTTP:  0.51
+    Test::More:                    0
+    XML::RSS::Feed:                0.01
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.2.html
+    version: 1.2
+author:
+    - Jeff Bisbee <jbisbee at cpan.org>

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/Makefile.PL?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/Makefile.PL (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/Makefile.PL Sun Jun 29 17:47:00 2008
@@ -1,0 +1,22 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME          => 'POE::Component::RSSAggregator',
+    AUTHOR        => 'Jeff Bisbee <jbisbee at cpan.org>',
+    VERSION_FROM  => 'lib/POE/Component/RSSAggregator.pm',
+    ABSTRACT_FROM => 'lib/POE/Component/RSSAggregator.pm',
+    PL_FILES      => {},
+    PREREQ_PM     => {
+        'POE::Component::Client::HTTP' => 0.51,
+        'POE::Component::Client::DNS'  => 0.98,
+        'XML::RSS::Feed'               => 0.01,
+        'HTTP::Request'                => 1.30,
+        'Test::More'                   => 0,
+        'Carp'                         => 0,
+    },
+    dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean   => { FILES => 'POE-Component-RSSAggregator-*' },
+    LICENSE => 'perl',
+);

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/README?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/README (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/README Sun Jun 29 17:47:00 2008
@@ -1,0 +1,151 @@
+NAME
+    POE::Component::RSSAggregator - Watch Muliple RSS Feeds for New
+    Headlines
+
+VERSION
+    Version 1.022
+
+SYNOPSIS
+        #!/usr/bin/perl
+        use strict;
+        use warnings;
+        use POE;
+        use POE::Component::RSSAggregator;
+
+        my @feeds = (
+            {   url   => "http://www.jbisbee.com/rdf/",
+                name  => "jbisbee",
+                delay => 10,
+            },
+            {   url   => "http://lwn.net/headlines/rss",
+                name  => "lwn",
+                delay => 300,
+            },
+        );
+
+        POE::Session->create(
+            inline_states => {
+                _start      => \&init_session,
+                handle_feed => \&handle_feed,
+            },
+        );
+
+        $poe_kernel->run();
+
+        sub init_session {
+            my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSION ];
+            $heap->{rssagg} = POE::Component::RSSAggregator->new(
+                alias    => 'rssagg',
+                debug    => 1,
+                callback => $session->postback("handle_feed"),
+                tmpdir   => '/tmp',        # optional caching 
+            );
+            $kernel->post( 'rssagg', 'add_feed', $_ ) for @feeds;
+        }
+
+        sub handle_feed {
+            my ( $kernel, $feed ) = ( $_[KERNEL], $_[ARG1]->[0] );
+            for my $headline ( $feed->late_breaking_news ) {
+
+                # do stuff with the XML::RSS::Headline object
+                print $headline->headline . "\n";
+            }
+        }
+
+CONSTRUCTORS
+  POE::Component::RSSAggregator->new( %hash );
+    Create a new instace of PoCo::RSSAggregator.
+
+    * alias
+        POE alias to use for your instance of PoCo::RSSAggregator.
+
+    * debug
+        Boolean value to turn on verbose output. (debug is also passed to
+        XML::RSS::Feed instances to turn on verbose output as well)
+
+    * tmpdir
+        The tmpdir argument is passed on to XML::RSS::Feed as the directory
+        to cache RSS between fetches (and instances).
+
+    * http_alias
+        Optional. Alias of an existing PoCoCl::HTTP.
+
+    * follow_redirects
+        Optional. Only if you don't have an exiting PoCoCl::HTTP. Argument
+        is passed to PoCoCl::HTTP to tell it the follow redirect level.
+        (Defaults to 2)
+
+METHODS
+  $rssagg->feed_list
+    Returns the current feeds as an array or array_ref.
+
+  $rssagg->feeds
+    Returns a hash ref of feeds with the key being the feeds name.
+
+  $rssagg->feed( $feed_name )
+    Accessor to access a the XML::RSS::Feed object via a feed's name.
+
+  $rssagg->add_feed( $hash_ref )
+    The hash reference you pass in to add_feed is passed to
+    XML::RSS::Feed->new($hash_ref). ( see XML::RSS::Feed )
+
+  $rssagg->remove_feed( $feed_name )
+    Pass in the name of the feed you want to remove.
+
+  $rssagg->pause_feed( $feed_name )
+    Pass in the name of the feed you want to pause.
+
+  $rssagg->resume_feed( $feed_name )
+    Pass in the name of the feed you want to resume (that you previously
+    paused).
+
+  $rssagg->shutdown
+    Shutdown the instance of PoCo::RSSAggregator.
+
+AUTHOR
+    Jeff Bisbee, "<jbisbee at cpan.org>"
+
+BUGS
+    Please report any bugs or feature requests to
+    "bug-poe-component-rssaggregator at rt.cpan.org", or through the web
+    interface at
+    <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Component-RSSAggrega
+    tor>. I will be notified, and then you'll automatically be notified of
+    progress on your bug as I make changes.
+
+SUPPORT
+    You can find documentation for this module with the perldoc command.
+
+        perldoc POE::Component::RSSAggregator
+
+    You can also look for information at:
+
+    * AnnoCPAN: Annotated CPAN documentation
+        <http://annocpan.org/dist/POE-Component-RSSAggregator>
+
+    * CPAN Ratings
+        <http://cpanratings.perl.org/d/POE-Component-RSSAggregator>
+
+    * RT: CPAN's request tracker
+        <http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-RSSAggregato
+        r>
+
+    * Search CPAN
+        <http://search.cpan.org/dist/POE-Component-RSSAggregator>
+
+ACKNOWLEDGEMENTS
+    Special thanks to Rocco Caputo, Martijn van Beers, Sean Burke, Prakash
+    Kailasa and Randal Schwartz for their help, guidance, patience, and bug
+    reports. Guys thanks for actually taking time to use the code and give
+    good, honest feedback.
+
+COPYRIGHT & LICENSE
+    Copyright 2006 Jeff Bisbee, all rights reserved.
+
+    This program is free software; you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+
+SEE ALSO
+    XML::RSS::Feed, XML::RSS::Headline, XML::RSS::Headline::PerlJobs,
+    XML::RSS::Headline::Fark
+

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/examples/example-1.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/examples/example-1.pl?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/examples/example-1.pl (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/examples/example-1.pl Sun Jun 29 17:47:00 2008
@@ -1,0 +1,45 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use POE;
+use POE::Component::RSSAggregator;
+
+my @feeds = (
+    {   url   => "http://www.jbisbee.com/rdf/",
+        name  => "jbisbee",
+        delay => 10,
+    },
+    {   url   => "http://lwn.net/headlines/rss",
+        name  => "lwn",
+        delay => 300,
+    },
+);
+
+POE::Session->create(
+    inline_states => {
+        _start      => \&init_session,
+        handle_feed => \&handle_feed,
+    },
+);
+
+$poe_kernel->run();
+
+sub init_session {
+    my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSION ];
+    $heap->{rssagg} = POE::Component::RSSAggregator->new(
+        alias    => 'rssagg',
+        debug    => 1,
+        callback => $session->postback("handle_feed"),
+        tmpdir   => '/tmp',        # optional caching 
+    );
+    $kernel->post( 'rssagg', 'add_feed', $_ ) for @feeds;
+}
+
+sub handle_feed {
+    my ( $kernel, $feed ) = ( $_[KERNEL], $_[ARG1]->[0] );
+    for my $headline ( $feed->late_breaking_news ) {
+
+        # do stuff with the XML::RSS::Headline object
+        print $headline->headline . "\n";
+    }
+}

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/lib/POE/Component/RSSAggregator.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/lib/POE/Component/RSSAggregator.pm?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/lib/POE/Component/RSSAggregator.pm (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/lib/POE/Component/RSSAggregator.pm Sun Jun 29 17:47:00 2008
@@ -1,0 +1,417 @@
+package POE::Component::RSSAggregator;
+
+use warnings;
+use strict;
+
+use POE;
+use POE::Component::Client::HTTP;
+use HTTP::Request;
+use XML::RSS::Feed;
+use Carp qw(croak);
+
+=head1 NAME
+
+POE::Component::RSSAggregator - Watch Muliple RSS Feeds for New Headlines
+
+=head1 VERSION
+
+Version 1.022
+
+=cut
+
+our $VERSION = 1.022;
+
+=head1 SYNOPSIS
+
+    #!/usr/bin/perl
+    use strict;
+    use warnings;
+    use POE;
+    use POE::Component::RSSAggregator;
+
+    my @feeds = (
+        {   url   => "http://www.jbisbee.com/rdf/",
+            name  => "jbisbee",
+            delay => 10,
+        },
+        {   url   => "http://lwn.net/headlines/rss",
+            name  => "lwn",
+            delay => 300,
+        },
+    );
+
+    POE::Session->create(
+        inline_states => {
+            _start      => \&init_session,
+            handle_feed => \&handle_feed,
+        },
+    );
+
+    $poe_kernel->run();
+
+    sub init_session {
+        my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSION ];
+        $heap->{rssagg} = POE::Component::RSSAggregator->new(
+            alias    => 'rssagg',
+            debug    => 1,
+            callback => $session->postback("handle_feed"),
+            tmpdir   => '/tmp',        # optional caching 
+        );
+        $kernel->post( 'rssagg', 'add_feed', $_ ) for @feeds;
+    }
+
+    sub handle_feed {
+        my ( $kernel, $feed ) = ( $_[KERNEL], $_[ARG1]->[0] );
+        for my $headline ( $feed->late_breaking_news ) {
+
+            # do stuff with the XML::RSS::Headline object
+            print $headline->headline . "\n";
+        }
+    }
+
+=head1 CONSTRUCTORS
+
+=head2 POE::Component::RSSAggregator->new( %hash );
+
+Create a new instace of PoCo::RSSAggregator.
+
+=over 4
+
+=item * alias
+
+POE alias to use for your instance of PoCo::RSSAggregator.
+
+=item * debug
+
+Boolean value to turn on verbose output.  (debug is also passed to
+XML::RSS::Feed instances to turn on verbose output as well)
+
+=item * tmpdir
+
+The tmpdir argument is passed on to XML::RSS::Feed as the directory to 
+cache RSS between fetches (and instances).
+
+=item * http_alias
+
+Optional.  Alias of an existing PoCoCl::HTTP.
+
+=item * follow_redirects
+
+Optional.  Only if you don't have an exiting PoCoCl::HTTP.  Argument 
+is passed to PoCoCl::HTTP to tell it the follow redirect level.  
+(Defaults to 2)
+
+=back
+
+=cut
+
+sub new {
+    my $class = shift;
+    croak __PACKAGE__ . "->new() params must be a hash" if @_ % 2;
+    my %params = @_;
+
+    croak __PACKAGE__
+        . "->new() feeds param has been deprecated, use add_feed"
+        if $params{feeds};
+
+    my $self = bless \%params, $class;
+    $self->_init();
+
+    return $self;
+}
+
+sub _start {
+    my ( $self, $kernel ) = @_[ OBJECT, KERNEL ];
+    $self->{alias} = 'rssagg' unless $self->{alias};
+    $kernel->alias_set( $self->{alias} );
+}
+
+sub _stop {}
+
+sub _init {
+    my ($self) = @_;
+
+    unless ($self->{http_alias}) {
+	$self->{http_alias} = 'ua';
+	$self->{follow_redirects} ||= 2;
+        POE::Component::Client::HTTP->spawn(
+            Alias           => $self->{http_alias},
+            Timeout         => 60,
+            FollowRedirects => $self->{follow_redirects},
+            Agent           => 'Mozilla/5.0 (X11; U; Linux i686; en-US; '
+                . 'rv:1.1) Gecko/20020913 Debian/1.1-1',
+        );
+    }
+
+    POE::Session->create(
+	object_states => [
+	    $self => [qw(
+		_start
+		add_feed remove_feed pause_feed resume_feed 
+		_fetch _response
+		shutdown
+		_stop
+	    )],
+	],
+    );
+}
+
+sub _create_feed_object {
+    my ( $self, $feed_hash ) = @_;
+
+    warn "[$feed_hash->{name}] Creating XML::RSS::Feed object\n"
+        if $self->{debug};
+
+    $feed_hash->{tmpdir} = $self->{tmpdir}
+        if exists $self->{tmpdir} && -d $self->{tmpdir};
+
+    $feed_hash->{debug} = $self->{debug} 
+        if $self->{debug};
+
+    if ( my $rssfeed = XML::RSS::Feed->new(%$feed_hash) ) {
+        $self->{feed_objs}{ $rssfeed->name } = $rssfeed;
+    }
+    else {
+        warn "[$feed_hash->{name}] !! Error attempting to " 
+            . "create XML::RSS::Feed object\n";
+    }
+}
+
+=head1 METHODS
+
+=head2 $rssagg->feed_list
+
+Returns the current feeds as an array or array_ref.
+
+=cut
+
+sub feed_list {
+    my ($self) = @_;
+    my @feeds = map { $self->{feed_objs}{$_} } keys %{ $self->{feed_objs} };
+    return wantarray ? @feeds : \@feeds;
+}
+
+=head2 $rssagg->feeds
+
+Returns a hash ref of feeds with the key being the feeds name.
+
+=cut
+
+sub feeds {
+    my ($self) = @_;
+    return $self->{feed_objs};
+}
+
+=head2 $rssagg->feed( $feed_name )
+
+Accessor to access a the XML::RSS::Feed object via a feed's name.
+
+=cut
+
+sub feed {
+    my ( $self, $name ) = @_;
+    return exists $self->{feed_objs}{$name}
+        ? $self->{feed_objs}{$name}
+        : undef;
+}
+
+=head2 $rssagg->add_feed( $hash_ref )
+
+The hash reference you pass in to add_feed is passed to
+XML::RSS::Feed->new($hash_ref). ( see L<XML::RSS::Feed> )
+
+=cut
+
+sub add_feed {
+    my ( $self, $kernel, $feed_hash ) = @_[ OBJECT, KERNEL, ARG0 ];
+    if ( exists $self->{feed_objs}{ $feed_hash->{name} } ) {
+        warn "[$feed_hash->{name}] !! Add Failed: Feed name already exists\n";
+        return;
+    }
+    warn "[$feed_hash->{name}] Added\n" if $self->{debug};
+    $self->_create_feed_object($feed_hash);
+
+    # Test to remove it after 10 seconds
+    $kernel->yield( '_fetch', $feed_hash->{name} );
+}
+
+=head2 $rssagg->remove_feed( $feed_name )
+
+Pass in the name of the feed you want to remove.
+
+=cut
+
+sub remove_feed {
+    my ( $self, $kernel, $name ) = @_[ OBJECT, KERNEL, ARG0 ];
+    unless ( exists $self->{feed_objs}{$name} ) {
+        warn "[$name] remove_feed: Remove Failed: Unknown feed\n";
+        return;
+    }
+    $kernel->call( $self->{alias}, 'pause_feed', $name );
+    delete $self->{feed_objs}{$name};
+    warn "[$name] remove_feed: Removed RSS Feed\n" if $self->{debug};
+}
+
+=head2 $rssagg->pause_feed( $feed_name )
+
+Pass in the name of the feed you want to pause.
+
+=cut
+
+sub pause_feed {
+    my ( $self, $kernel, $name ) = @_[ OBJECT, KERNEL, ARG0 ];
+    unless ( exists $self->{feed_objs}{$name} ) {
+        warn "[$name] pause_feed: Pause Failed: Unknown feed\n";
+        return;
+    }
+    unless ( exists $self->{alarm_ids}{$name} ) {
+        warn "[$name] pause_feed: Pause Failed: Feed currently on pause\n";
+        return;
+    }
+    if ( $kernel->alarm_remove( $self->{alarm_ids}{$name} ) ) {
+        delete $self->{alarm_ids}{$name};
+        warn "[$name] pause_feed: Paused RSS Feed\n" if $self->{debug};
+    }
+    else {
+        warn "[$name] pause_feed: Failed to Pause RSS Feed\n"
+            if $self->{debug};
+    }
+}
+
+=head2 $rssagg->resume_feed( $feed_name )
+
+Pass in the name of the feed you want to resume (that you previously paused).
+
+=cut
+
+sub resume_feed {
+    my ( $self, $kernel, $name ) = @_[ OBJECT, KERNEL, ARG0 ];
+    unless ( exists $self->{feed_objs}{$name} ) {
+        warn "[$name] resume_feed: Resume Failed: Unknown feed\n";
+        return;
+    }
+    if ( exists $self->{alarm_ids}{$name} ) {
+        warn "[$name] resume_feed: Resume Failed: Feed currently active\n";
+        return;
+    }
+    warn "[$name] resume_feed: Resumed RSS Feed\n" if $self->{debug};
+    $kernel->yield( '_fetch', $name );
+}
+
+=head2 $rssagg->shutdown
+
+Shutdown the instance of PoCo::RSSAggregator.
+
+=cut
+
+sub shutdown {
+    my ( $self, $kernel, $session ) = @_[ OBJECT, KERNEL, SESSION ];
+    for my $feed ( $self->feed_list ) {
+        $kernel->call( $session, 'remove_feed', $feed->name );
+    }
+    delete $self->{callback};
+    $kernel->alias_remove( $self->{alias} );
+    warn "shutdown: shutting down rssaggregator\n" if $self->{debug};
+}
+
+sub _fetch {
+    my ( $self, $kernel, $feed_name ) = @_[ OBJECT, KERNEL, ARG0 ];
+    unless ( exists $self->{feed_objs}{$feed_name} ) {
+        warn "[$feed_name] Unknown Feed\n";
+        return;
+    }
+
+    my $rssfeed = $self->{feed_objs}{$feed_name};
+    my $req = HTTP::Request->new( GET => $rssfeed->url );
+    warn "[" . $rssfeed->name . "] Attempting to fetch\n" if $self->{debug};
+    $kernel->post( $self->{http_alias}, 'request', '_response', $req,
+        $rssfeed->name );
+    $self->{alarm_ids}{ $rssfeed->name }
+        = $kernel->delay_set( '_fetch', $rssfeed->delay, $rssfeed->name );
+}
+
+sub _response {
+    my ( $self, $kernel, $request_packet, $response_packet )
+        = @_[ OBJECT, KERNEL, ARG0, ARG1 ];
+
+    my ( $req, $feed_name ) = @$request_packet;
+
+    unless ( exists $self->{feed_objs}{$feed_name} ) {
+        warn "[$feed_name] Unknown Feed\n";
+        return;
+    }
+
+    my $rssfeed = $self->{feed_objs}{$feed_name};
+    my $res     = $response_packet->[0];
+    if ( $res->is_success ) {
+        warn "[" . $rssfeed->name . "] Fetched " . $rssfeed->url . "\n"
+            if $self->{debug};
+        $self->{callback}->($rssfeed) if $rssfeed->parse( $res->content );
+    }
+    else {
+        warn "[!!] Failed to fetch " . $req->uri . "\n";
+    }
+}
+
+=head1 AUTHOR
+
+Jeff Bisbee, C<< <jbisbee at cpan.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-poe-component-rssaggregator at rt.cpan.org>, or through the web 
+interface at 
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Component-RSSAggregator>.
+I will be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc POE::Component::RSSAggregator
+
+You can also look for information at:
+
+=over 4
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/POE-Component-RSSAggregator>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/POE-Component-RSSAggregator>
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-RSSAggregator>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/POE-Component-RSSAggregator>
+
+=back
+
+=head1 ACKNOWLEDGEMENTS
+
+Special thanks to Rocco Caputo, Martijn van Beers, Sean Burke, Prakash Kailasa
+and Randal Schwartz for their help, guidance, patience, and bug reports. Guys 
+thanks for actually taking time to use the code and give good, honest feedback.
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2006 Jeff Bisbee, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<XML::RSS::Feed>, L<XML::RSS::Headline>, L<XML::RSS::Headline::PerlJobs>, 
+L<XML::RSS::Headline::Fark>
+
+=cut
+
+1;

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/t/00-load.t?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/t/00-load.t (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/t/00-load.t Sun Jun 29 17:47:00 2008
@@ -1,0 +1,5 @@
+#!perl -T
+use Test::More tests => 1;
+
+BEGIN { use_ok('POE::Component::RSSAggregator'); }
+diag( "Testing POE::Component::RSSAggregator $POE::Component::RSSAggregator::VERSION, Perl $], $^X" );

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/t/01-basic.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/t/01-basic.t?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/t/01-basic.t (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/t/01-basic.t Sun Jun 29 17:47:00 2008
@@ -1,0 +1,142 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+use_ok("POE");
+POE::Kernel->run();
+
+__DATA__
+
+use Test::More tests => 5;
+use POE;
+use POE::Component::RSSAggregator;
+use HTTP::Status;
+use POE::Component::Server::HTTP;
+
+our %URLS = (
+    test1 => \&test1,
+    test2 => \&test2,
+);
+
+our @test1_xml = (
+    q|<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns="http://my.netscape.com/rdf/simple/0.9/"><channel><title>jbisbee.com</title>
+    <link>http://www.jbisbee.com/</link><description>Testing PoCo::RSSAggregator</description>
+    </channel><item><title>Friday 12th of November 2004 02:20:00 PM</title>
+    <link>http://www.jbisbee.com/xml-rss-feed/test/1100294400</link></item></rdf:RDF>|,
+
+    qq|<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns="http://my.netscape.com/rdf/simple/0.9/"><channel><title>jbisbee.com</title>
+    <link>http://www.jbisbee.com/</link><description>Testing PoCo::RSSAggregator</description>
+    </channel><item><title>Friday 12th of November 2004 02:20:30 PM</title>
+    <link>http://www.jbisbee.com/xml-rss-feed/test/1100294430</link></item></rdf:RDF>|
+);
+
+our @test2_xml = (
+    q|<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns="http://my.netscape.com/rdf/simple/0.9/"><channel><title>jbisbee.com</title>
+    <link>http://poe.perl.org/</link><description>Testing PoCo::RSSAggregator</description>
+    </channel><item><title>Friday 12th of November 2004 02:20:00 PM</title>
+    <link>http://poe.perl.org/xml-rss-feed/test/1100294400</link></item></rdf:RDF>|,
+
+    qq|<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns="http://my.netscape.com/rdf/simple/0.9/"><channel><title>jbisbee.com</title>
+    <link>http://poe.perl.org/</link><description>Testing PoCo::RSSAggregator</description>
+    </channel><item><title>Friday 12th of November 2004 02:20:30 PM</title>
+    <link>http://poe.perl.org/xml-rss-feed/test/1100294430</link></item></rdf:RDF>|
+);
+
+POE::Session->new(
+    _start      => \&start,
+    _stop       => sub { },
+    _child      => sub { },
+    handle_feed => \&handle_feed,
+    closeshop   => \&closeshop,
+    verify      => \&verify,
+);
+POE::Kernel->run();
+
+sub start {
+    my ( $heap, $session, $kernel ) = @_[ HEAP, SESSION, KERNEL ];
+    my $postback = $session->postback("handle_feed");
+    $heap->{rssagg}
+        = POE::Component::RSSAggregator->new( callback => $postback );
+    isa_ok( $heap->{rssagg}, "POE::Component::RSSAggregator" );
+    $heap->{httpd} = spawn_http_server(12345);
+    $kernel->call( $heap->{rssagg}->{alias}, 'add_feed', $_ ) for (
+        {   name  => 'test1',
+            url   => 'http://localhost:12345/test1',
+            delay => 1
+        },
+        {   name  => 'test2',
+            url   => 'http://localhost:12345/test2',
+            delay => 1
+        },
+    );
+    my @feeds = $heap->{rssagg}->feed_list();
+    is( @feeds, 2, "Verify two feeds loaded" );
+}
+
+my %done = ( test1 => 0, test2 => 0 );
+my $done = 0;
+
+sub handle_feed {
+    my ( $kernel, $session, $heap, $feed )
+        = ( @_[ KERNEL, SESSION, HEAP ], $_[ARG1]->[0] );
+    return if $done;
+    isa_ok( $feed, "XML::RSS::Feed" );
+    my $headlines = $feed->num_headlines;
+    if ( $feed->late_breaking_news ) {
+        $done{ $feed->name }++;
+        $done = 1;
+        for my $test (qw(test1 test2)) {
+            $done = $done{$test};
+        }
+        $kernel->post( $session, 'closeshop' ) unless $done;
+    }
+}
+
+sub closeshop {
+    my ( $kernel, $heap ) = ( @_[ KERNEL, HEAP ] );
+    $kernel->post( $heap->{httpd}{httpd}, "shutdown" );
+    $kernel->post( $heap->{rssagg}->{alias}, 'shutdown' );
+    $kernel->yield('verify');
+}
+
+sub verify {
+    my ( $kernel, $heap ) = ( @_[ KERNEL, HEAP ] );
+    my @feeds = $heap->{rssagg}->feed_list();
+    is( @feeds, 0, "All feeds have been removed" );
+}
+
+sub spawn_http_server {
+    my ($port) = shift;
+    return POE::Component::Server::HTTP->new(
+        Port           => $port,
+        ContentHandler => { '/' => \&http_handler },
+        Headers        => { Server => 'My Server' },
+    );
+}
+
+sub http_handler {
+    my ( $request, $response ) = @_;
+    my $path = $request->uri->path;
+    $path =~ s/^\///;
+    my $xml = &{ $URLS{$path} }();
+    $response->code( HTTP::Status::RC_OK() );
+    $response->content($xml);
+    return HTTP::Status::RC_OK();
+}
+
+sub test1 {
+    my $xml = shift @test1_xml;
+    push @test1_xml, $xml;
+    return $xml;
+}
+
+sub test2 {
+    my $xml = shift @test2_xml;
+    push @test2_xml, $xml;
+    return $xml;
+}

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/t/boilerplate.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/t/boilerplate.t?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/t/boilerplate.t (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/t/boilerplate.t Sun Jun 29 17:47:00 2008
@@ -1,0 +1,48 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+sub not_in_file_ok {
+    my ($filename, %regex) = @_;
+    open my $fh, "<", $filename
+        or die "couldn't open $filename for reading: $!";
+
+    my %violated;
+
+    while (my $line = <$fh>) {
+        while (my ($desc, $regex) = each %regex) {
+            if ($line =~ $regex) {
+                push @{$violated{$desc}||=[]}, $.;
+            }
+        }
+    }
+
+    if (%violated) {
+        fail("$filename contains boilerplate text");
+        diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
+    } else {
+        pass("$filename contains no boilerplate text");
+    }
+}
+
+not_in_file_ok(README =>
+    "The README is used..."       => qr/The README is used/,
+    "'version information here'"  => qr/to provide version information/,
+);
+
+not_in_file_ok(Changes =>
+    "placeholder date/time"       => qr(Date/time)
+);
+
+sub module_boilerplate_ok {
+    my ($module) = @_;
+    not_in_file_ok($module =>
+        'the great new $MODULENAME'   => qr/ - The great new /,
+        'boilerplate description'     => qr/Quick summary of what the module/,
+        'stub function definition'    => qr/function[12]/,
+    );
+}
+
+module_boilerplate_ok('lib/POE/Component/RSSAggregator.pm');

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod-coverage.t?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod-coverage.t Sun Jun 29 17:47:00 2008
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();

Added: branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod.t?rev=22481&op=file
==============================================================================
--- branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod.t (added)
+++ branches/upstream/libpoe-component-rssaggregator-perl/current/t/pod.t Sun Jun 29 17:47:00 2008
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();




More information about the Pkg-perl-cvs-commits mailing list