The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Rssfilter::Feed::Storage - load and save RSS feeds as files

VERSION

version 0.07

SYNOPSIS

    use App::Rssfilter::Feed::Storage;

    my $fs = App::Rssfilter::Feed::Storage->new(
        path => 'Hi-type feeds',
        name => 'Hello',
    );

    print 'last update of feed was ', $fs->last_modified, "\n";
    print 'what we got last time: ', $fs->load_existing, "\n";

    $fs->save_feed( Mojo::DOM->new( "<hi>hello</hi>" ) );
    print 'now it is: ', $fs->load_existing, "\n";

DESCRIPTION

This module saves and loads RSS feeds to and from files, where the file name is based on a group and feed name. It is the default implementation used by App::Rssfilter::Feed for storing & retreiving feeds.

It consumes the App::Rssfilter::Logger role.

ATTRIBUTES

logger

This is a object used for logging; it defaults to a Log::Any object. It is provided by the App::Rssfilter::Logger role.

path

This is the directory path to the stored feed file. If not specified, the current working directory will be used. It is coerced into a Path::Class::Dir object, if it is a string specifying an absolute or relative directory path, or an array or arrayref of directory names (which will be joined to form a directory path).

name

This is the name of the feed, and will be used as the filename to store the feed under.

last_modified

This is the last time the stored RSS feed was saved, as a HTTP date string suitable for use in a Last-Modified header. If the feed has never been saved, returns Thu, 01 Jan 1970 00:00:00 GMT. It cannot be set from the constructor.

METHODS

path_push

    my $new_fs = $fs->path_push( @paths );

Returns a clone of this object whose path has had @paths appended to it.

set_name

    my $new_fs = $fs->set_name( $new_name );

Returns this object if its name is already $new_name, else returns a clone of this object with its name set to $name.

load_existing

    print $fs->load_existing->to_xml;

Returns a Mojo::DOM object initialised with the content of the previously-saved feed. If the feed has never been saved, returns a Mojo::DOM object initialised with an empty string.

save_feed

    $fs->save_feed( Mojo::DOM->new( '<rss> ... </rss>' ) );

Saves a Mojo::DOM object (or anything with a to_xml method), and updates last_modified().

AUTHOR

Daniel Holz <dgholz@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Daniel Holz.

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