Changeset 1025

Show
Ignore:
Timestamp:
06/30/06 09:34:27
Author:
miyagawa
Message:

Rule::Deduped: Use entry's datetime as key if there's any. Fixes #312

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Rule/Deduped/Base.pm

    r926 r1025  
    1515sub init { } 
    1616 
     17sub id_for { 
     18    my($self, $entry) = @_; 
     19 
     20    if ($entry->date) { 
     21        return join ":", $entry->permalink, $entry->date; 
     22    } else { 
     23        return $entry->permalink; 
     24    } 
     25} 
     26 
    1727sub is_new { 
    1828    my($self, $entry) = @_; 
    1929 
    20     my $exists = $self->find_entry($entry->permalink) or return 1; 
     30    my $exists = $self->find_entry( $self->id_for($entry) ) or return 1; 
    2131 
    2232    if ($self->{compare_body}) { 
     
    2939sub add { 
    3040    my($self, $entry) = @_; 
    31     $self->create_entry($entry->permalink, $entry->digest); 
     41    $self->create_entry( $self->id_for($entry), $entry->digest ); 
    3242} 
    3343 
  • trunk/plagger/t/core/deduped.t

    r1024 r1025  
    11use strict; 
    2 use Test::More tests => 3
     2use Test::More tests => 5
    33use FindBin; 
    44use File::Spec; 
     
    5050my $log; $SIG{__WARN__} = sub { $log .= "@_" }; 
    5151 
     52my $expect_count = 2; 
     53 
    5254Plagger->bootstrap(config => $config); 
    5355unlike $log, qr/Deleting/; 
     
    5557Plagger->bootstrap(config => $config); 
    5658like $log, qr/Deleting/; 
     59 
     60# Add newer entry 
     61unshift @{ $config->{plugins}->[0]->{config}->{entry} }, { 
     62    title => "foo2", 
     63    date => "2006-06-29 19:15:00", 
     64    link => "http://localhost/2/", 
     65}; 
     66 
     67undef $log; 
     68$expect_count = 1; 
     69 
     70Plagger->bootstrap(config => $config); 
     71unlike $log, qr/Deleting/; 
    5772 
    5873unlink $db if -e $db; 
     
    7287sub test { 
    7388    my($self, $context, $args) = @_; 
    74     ::is $args->{feed}->count, 2
     89    ::is $args->{feed}->count, $expect_count
    7590}