NAME

WWW::CPANRatings::RSS - get information from RSS feed on http://cpanratings.perl.org/

SYNOPSIS

use strict;
use warnings;

use WWW::CPANRatings::RSS;

my $rate = WWW::CPANRatings::RSS->new;

$rate->fetch
    or die $rate->error;

for ( @{ $rate->ratings } ) {
    printf "%s - %s stars - by %s\n--- %s ---\nsee %s\n\n\n",
        @$_{ qw/dist rating creator comment link/ };
}


$rate->fetch_uniqe
    or die $rate->error;
for ( @{ $rate->ratings_unique } ) {
    printf "%s - %s stars - by %s\n--- %s ---\nsee %s\n\n\n",
        @$_{ qw/dist rating creator comment link/ }
}

# ... and so on...

DESCRIPTION

The module provides access to information provided by RSS feed on http://cpanratings.perl.org/, which is basically several of most recent reviews.

CONSTRUCTOR

new

my $rate = WWW::CPANRatings::RSS->new;

my $rate = WWW::CPANRatings::RSS->new(
    ua => {
        agent   => 'Foo',
        timeout => 30,
    },
);

Returns a freshly baked WWW::CPANRatings::RSS object. Arguments are passed in a key/value fashion. So far there is only one argument ua.

ua

->new(
    ua => {
        agent   => 'Foo',
        timeout => 30,
    },
);

Optional. Takes a hashref as a value. This hashref will be directly dereferenced into LWP::UserAgent object used by this module. For possible arguments see LWP::UserAgent documentation. Defaults to: { timeout => 30 }

METHODS

fetch

my $ratings = $rate->fetch
    or die $rate->error;

Takes no arguments. Instructs the object to fetch the RSS feed on http://cpanratings.perl.org/. On success returns an arrayref of hashrefs, which are described below. On failure returns either undef or an empty list, depending on the context, in which case the error() method will return the explanation of the error. The elements (hashrefs) in the returned arrayref represent cpanratings reviews, in reverse-chronological order (i.e. newest first). The format of each hashref is as follows:

$VAR1 = {
      'link' => 'http://cpanratings.perl.org/#4446',
      'comment' => 'This module has failed on all swf\'s ive tried it on.  All attempts at transcoding has resulted in contentless flv that will not play.
',
      'creator' => 'Dave Williams',
      'dist' => 'FLV-Info',
      'rating' => '1'
};
{ 'link' => 'http://cpanratings.perl.org/#4446', }

The link key will contain a string which represents a link to the review.

comment

{ 'comment' => 'This module has failed on all swf\'s ive tried it on.  All attempts at transcoding has resulted in contentless flv that will not play. }

The comment key will contain a string representing the (often partial, starting from the beginning) content of the review.

creator

{ 'creator' => 'Dave Williams', }

The creator key will contain a string which represents the name of the person who created the review.

dist

{ 'dist' => 'FLV-Info', }

The dist key will contain a string which is the name of the distribution that was reviewed.

rating

{ 'rating' => '1' }

{ 'rating' => 'N/A' }

The rating key will contain the rating of the distribution given by the creator of the review. It will either be the number of "stars" or 'N/A' if no rating was given.

fetch_unique

my $unique_ref => $rate->fetch_unique
    or die $rate->error;

my $unique_ref => $rate->fetch_unique('some.file')
    or die $rate->error;

In case of an error will return either undef or an empty list and the error message will be available via error() method. The fetch_unique method is the same as fetch method and returns the arrayref in the same format. The difference is that fetch_unique will read/store any reviews that it were already reported and will only return the ones that haven't been reported yet. You can use this method to implement "new cpan ratings" announcements. Takes one optional argument which is a scalar containing the name of the file into which to store the already reported reviews which is the same file from which the module will attempt to read already reported reviews. The argument will defaul to 'cpan_ratings.rss.storable' if not specified.

error

my $ratings = $rate->fetch
    or die $rate->error;

In case of an error during the call to fetch() method, the error method will return a string which describes the reason for failure.

ratings

$rate->fetch
    or die $rate->error;

my $ratings = $rate->ratings;

Must be called after a successful call to fetch() method. Returns the exact same arrayref as the last call to fetch() returned;

ratings_unique

$rate->fetch_unique
    or die $rate_error;

my $ratings_unique = $rate->ratings_unique;

Must be called after a successful call to fetch_unique() method. Returns the exact same arrayref as the last call to fetch_unique() method returned.

ua

my $ua_obj = $rate->ua;

$rate->ua( LWP::UserAgent->new );

Returns an LWP::UserAgent object used internally for fetching the RSS feed. When called with an optional argument, which must be an LWP::UserAgent or a compatible object, will use the provided object in any subsequent calls to fetch() method.

PREREQUISITES

For healthy operation this module needs XML::Simple, LWP::UserAgent and Storable

EXAMPLES

The examples/ directory of this distributing contains a script that shows the usage of both fetch and fetch_unique

AUTHOR

Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com, http://haslayout.net)

BUGS

Please report any bugs or feature requests to bug-www-cpanratings-rss at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-CPANRatings-RSS. 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 WWW::CPANRatings::RSS

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2008 Zoffix Znet, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.