Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make all filter objects blessed hashes

*Why* did I think doing otherwise would be smart?
  • Loading branch information...
commit 5744e36cf8de88dfe304fec82f8e089e932ed4f7 1 parent 56d899b
@hoelzro hoelzro authored
View
9 Extension.pm
@@ -10,13 +10,16 @@ sub new {
my $exts = join('|', map { "\Q$_\E"} @extensions);
my $re = qr/[.](?:$exts)$/i;
- return bless \$re, $class;
+ return bless {
+ extensions => \@extensions,
+ regex => $re,
+ }, $class;
};
sub filter {
my ( $self, $resource ) = @_;
- my $re = ${$self};
+ my $re = $self->{'regex'};
return $resource->name =~ /$re/;
}
@@ -24,7 +27,7 @@ sub filter {
sub inspect {
my ( $self ) = @_;
- my $re = ${$self};
+ my $re = $self->{'regex'};
return ref($self) . " - $re";
}
View
9 FirstLineMatch.pm
@@ -6,10 +6,13 @@ use base 'App::Ack::Filter';
sub new {
my ( $class, $re ) = @_;
+
$re =~ s{^/|/$}{}g; # XXX validate?
$re = qr{$re}i;
- return bless \$re, $class;
+ return bless {
+ regex => $re,
+ }, $class;
}
# XXX This test checks the first "line" of the file, but we need
@@ -20,7 +23,7 @@ sub new {
sub filter {
my ( $self, $resource ) = @_;
- my $re = ${$self};
+ my $re = $self->{'regex'};
local $_;
return unless $resource->next_text;
@@ -31,7 +34,7 @@ sub filter {
sub inspect {
my ( $self ) = @_;
- my $re = ${$self};
+ my $re = $self->{'regex'};
return ref($self) . " - $re";
}
View
10 Inverse.pm
@@ -7,20 +7,22 @@ use base 'App::Ack::Filter';
sub new {
my ( $class, $filter ) = @_;
- return bless \$filter, $class;
+ return bless {
+ filter => $filter,
+ }, $class;
}
sub filter {
my ( $self, $resource ) = @_;
- my $filter = ${$self};
+ my $filter = $self->{'filter'};
return !$filter->filter( $resource );
}
sub invert {
my $self = shift;
- return ${$self};
+ return $self->{'filter'};
}
sub is_inverted {
@@ -30,7 +32,7 @@ sub is_inverted {
sub inspect {
my ( $self ) = @_;
- my $filter = ${$self};
+ my $filter = $self->{'filter'};
return "!$filter";
}
View
8 Is.pm
@@ -9,13 +9,15 @@ use File::Spec ();
sub new {
my ( $class, $filename ) = @_;
- return bless \$filename, $class;
+ return bless {
+ filename => $filename,
+ }, $class;
}
sub filter {
my ( $self, $resource ) = @_;
- my $filename = ${$self};
+ my $filename = $self->{'filename'};
my $base = (File::Spec->splitpath($resource->name))[2];
return $base eq $filename;
@@ -24,7 +26,7 @@ sub filter {
sub inspect {
my ( $self ) = @_;
- my $filename = ${$self};
+ my $filename = $self->{'filename'};
return ref($self) . " - $filename";
}
View
8 Match.pm
@@ -12,13 +12,15 @@ sub new {
$re =~ s{^/|/$}{}g; # XXX validate?
$re = qr/$re/i;
- return bless \$re, $class;
+ return bless {
+ regex => $re,
+ }, $class;
}
sub filter {
my ( $self, $resource ) = @_;
- my $re = ${$self};
+ my $re = $self->{'regex'};
my $base = (File::Spec->splitpath($resource->name))[2];
return $base =~ /$re/;
@@ -27,7 +29,7 @@ sub filter {
sub inspect {
my ( $self ) = @_;
- my $re = ${$self};
+ my $re = $self->{'regex'};
print ref($self) . " - $re";
}

0 comments on commit 5744e36

Please sign in to comment.
Something went wrong with that request. Please try again.