NAME

Feed::Data - dynamic data feeds

VERSION

Version 0.08

SYNOPSIS

use Feed::Data;

my $feed = Feed::Data->new();
$feed->parse( 'https://services.parliament.uk/calendar/lords_main_chamber.rss' );

$feed->all;
$feed->count;
$feed->delete($index);
$feed->get($index);

$feed->write( 'path/to/empty.rss', 'rss' );
my $feed_text = $feed->render('rss'); 

foreach my $object ( $feed->all ) {
	$object->render('text'); # text, html, xml..
	$object->hash('text'); # text, html, xml...
	$object->fields('title', 'description'); # returns title and description object
	$object->edit(title => 'TTI', description => 'Should have been a PWA.'); # sets
	
	$object->title->text;
	$object->link->raw;
	$object->description->text;
	$object->image->raw;
	$object->date->text;
	
	$entry->title->as_text;
}

...

use Feed::Data;

my $feed = Feed::Data->new();

$feed->parse( 'https://services.parliament.uk/calendar/commons_main_chamber.rss' );

my $string = $feed->render('styled_table');

$feed->clear;

$feed->parse($string);

DESCRIPTION

Feed::Data is a frontend for building dynamic data feeds.

Methods

parse

Populates the feed Attribute, this is an Array of Feed::Data::Object 's

You can currently build Feeds by parsing xml (RSS, ATOM), JSON, CSV, plain text using key values seperated by a colon HTML via Meta Tags (twitter, opengraph) or table markup.

URI
# any rss/atom feed or a web page that contains og or twitter markup
$feed->parse( 'http://examples.com/feed.xml' );
File
$feed->parse( 'path/to/feed.json' );
Raw
$feed->parse( 'qq{<?xml version="1.0"><feed> .... </feed>} );

all

returns all elements in the current feed

$feed->all

count

returns the count of the current data feed

$feed->count

get

accepts an index and returns an Feed::Data::Object from feed by its Array index

$feed->get($index)

pop

pop the last Feed::Data::Object from the current feed

$feed->pop;

delete

accepts an index and deletes the relevant Feed::Data::Object based on its Array index

$feed->delete($index);

insert

insert an 'Feed::Data::Object' into the feed

$feed->insert($record)

is_empty

returns true if Feed::Data is empty.

$feed->is_empty

clear

clear the current feed.

$feed->clear

title

Set the title of the rss feed the default is Feed::Data.

$feed->title('Custom Title');

Set the link of the rss feed the default is Feed::Data.

$feed->link('https://custom.link');

description

Set the description of the rss feed the default is Feed::Data.

$feed->description('Custom Description');

rss_channel

Pass additional arguments into the rss feed channel section. See XML::RSS for more information.

$feed->rss_channel({  
	dc => {
		date       => '2000-01-01T07:00+00:00',
		subject    => "LNATION",
		creator    => 'email@lnation.org',
		publisher  => 'email@lnation.org',
		rights     => 'Copyright 2000, lnation.org',
	},
	syn => {
		updatePeriod     => "hourly",
		updateFrequency  => "1",
		updateBase       => "1901-01-01T00:00+00:00",
	},
});

render

render the feed using the passed in format, defaults to text.

# raw - as taken from the feed
# text - stripped to plain text
# json 
# rss
# csv
# yaml
# table
# styled_table

$feed->render('raw');

generate

returns the feed object as a Array of hashes but with the values rendered, key being the field. You can also pass in a format.

$feed->hash('text');

write

Writes the current stream to file.

$feed->write($file_path, $type);

AUTHOR

lnation, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-feed-data at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Feed-Data. 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.

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2016 LNATION.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.