File::Find::Rule::CVS - find files based on CVS metadata


File-Find-Rule-CVS documentation Contained in the File-Find-Rule-CVS distribution.

Index


Code Index:

NAME

Top

File::Find::Rule::CVS - find files based on CVS metadata

SYNOPSIS

Top

 use File::Find::Rule::CVS;
 my @modified = find( cvs_modified => in => 'sandbox' );

DESCRIPTION

Top

File::Find::Rule::CVS extends File::Find::Rule to add clauses based on the contents of CVS/Entries files.

RULES

Top

cvs_modified

Matches a file which the cvs sandbox thinks is modified

cvs_unknown

Matches an entry in a working directory that CVS doesn't know about

cvs_version( $test )

Matches files with versions that match $test. $test is a Number::Compare expression applied to a version object.

AUTHOR

Top

Richard Clamp <richardc@unixbeard.net>

COPYRIGHT

Top

SEE ALSO

Top

Parse::CVSEntries, File::Find::Rule


File-Find-Rule-CVS documentation Contained in the File-Find-Rule-CVS distribution.
use strict;
package File::Find::Rule::CVS;
use File::Find::Rule;
use Parse::CVSEntries;
use version;
use base 'File::Find::Rule';
use vars qw( $VERSION );
$VERSION = '0.01';

sub File::Find::Rule::_cvs_entry {
    my $self = shift;
    my ($file, $path) = @_;

    return $self->{_entries}{ $path }{ $file }
      if exists $self->{_entries}{ $path };

    my $parse = Parse::CVSEntries->new( "CVS/Entries" )
      or return;

    $self->{_entries}{ $path } = { map { $_->name => $_ } $parse->entries };
    return $self->{_entries}{ $path }{ $file };
}

sub File::Find::Rule::cvs_modified () {
    my $self = shift()->_force_object;
    my $sub = sub {
        my $entry = $self->_cvs_entry( @_ ) or return;
        return (stat $_)[9] > $entry->mtime;
    };
    $self->exec( $sub );
}


sub File::Find::Rule::cvs_unknown () {
    my $self = shift()->_force_object;
    my $sub = sub {
        return !$self->_cvs_entry( @_ );
    };
    $self->exec( $sub );
}


sub File::Find::Rule::cvs_version {
    my $self = shift()->_force_object;
    my $test = Number::Compare->new( shift );

    my $sub = sub {
        my $entry = $self->_cvs_entry( @_ )
          or return;
        my $version = version->new( $entry->version );
        return $test->( $version );
    };
    $self->exec( $sub );
}


1;
__END__