XML::Feed::Deduper - remove duplicated entries from feed


XML-Feed-Deduper documentation Contained in the XML-Feed-Deduper distribution.

Index


Code Index:

NAME

Top

XML::Feed::Deduper - remove duplicated entries from feed

SYNOPSIS

Top

    use XML::Feed;
    use XML::Feed::Deduper;
    my $feed = XML::Feed->parse($content);
    my $deduper = XML::Feed::Deduper->new(
        path => '/tmp/foo.db',
    );
    for my $entry ($deduper->dedup($feed->entries)) {
        # only new entries come here!
    }

DESCRIPTION

Top

XML::Feed::Deduper is deduper for XML::Feed.

You can write the aggregator more easily :)

The concept is stolen from Plagger::Rule::Deduper.

Enjoy!

CAUTION

Top

This module is still in its beta quality.

your base are belongs to us!

AUTHOR

Top

Tokuhiro Matsuno <tokuhirom slkjfd gmail.com>

SEE ALSO

Top

Plagger::Rule::Deduper

LICENSE

Top

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


XML-Feed-Deduper documentation Contained in the XML-Feed-Deduper distribution.

package XML::Feed::Deduper;
use Any::Moose;
use XML::Feed;
our $VERSION = '0.03';
use 5.008;

sub BUILD {
    my ($self, $args) = @_;
    my $engine = delete $args->{engine} || 'DB_File';
    $engine = $engine =~ s/^\+// ? $engine : "@{[ __PACKAGE__ ]}::${engine}";
    Any::Moose::load_class($engine);
    my $instance = $engine->new($args) or die 'wtf?';
    $self->{engine} = $instance;
}

sub dedup {
    my ($self, @entries) = @_;
    my $engine = $self->{engine} or die 'wtf?';

    my @res;
    for my $entry (@entries) {
        next unless $engine->is_new($entry);
        push @res, $entry;
        $engine->add($entry);
    }
    return @res;
}

no Any::Moose;
__PACKAGE__->meta->make_immutable;
__END__