Permalink
Browse files

Add author-v filter (think 'grep -v')

  • Loading branch information...
kappa committed Jan 2, 2010
1 parent c7707f3 commit 46db0cda4da351c3a88231572526dce92fdf2a88
Showing with 29 additions and 0 deletions.
  1. +29 −0 lib/Perlanet/Filters.pm
View
@@ -23,6 +23,9 @@ sub create_filter {
elsif ($cfg->{type} eq 'blogspot-justify') {
return bless {}, Perlanet::Filter::Blogspot_Justify;
}
+ elsif ($cfg->{type} eq 'author-v') {
+ return Perlanet::Filter::Author_V->new($cfg->{re});
+ }
die "Unknown filter type requested: $cfg->{type}\n";
}
@@ -144,4 +147,30 @@ sub filter {
return @rv;
}
+package Perlanet::Filter::Author_V;
+use List::Util qw/first/;
+
+sub new {
+ my $class = shift;
+ my $self = {};
+ $self->{re} = shift;
+
+ bless $self, $class;
+}
+
+sub filter {
+ my $self = shift;
+ my @rv;
+
+ foreach my $e (@_) {
+ if ( $e->{author}->{name} !~ /\Q$self->{re}\E/
+ && $e->{author}->{email} !~ /\Q$self->{re}\E/)
+ {
+ push @rv, $e;
+ }
+ }
+
+ return @rv;
+}
+
1;

0 comments on commit 46db0cd

Please sign in to comment.