Anonymous avatar Anonymous committed 1ad3741

Add File-Find-Object-Rule-VCS.

Comments (0)

Files changed (10)

File-Find-Object-Rule-VCS/Build.PL

+# This file is under the MIT X11 License:
+# http://www.opensource.org/licenses/mit-license.php
+
+use strict;
+use warnings;
+
+use File::Spec;
+use lib File::Spec->catdir(File::Spec->curdir(), "inc");
+
+use Test::Run::Builder;
+
+my $build = Test::Run::Builder->new(
+    module_name => "File::Find::Object::Rule::VCS",
+    license     => 'perl',
+    dist_author => 'Shlomi Fish <shlomif@cpan.org>',
+    requires =>
+    {
+        'strict' => 0,
+        'warnings'           => 0,
+        'File::Find::Object::Rule' => 0,
+    },
+    test_requires    => {
+        'File::Spec' => 0.82,
+        'Test::More' => 0.47,
+    },
+    create_makefile_pl => 'traditional',
+    meta_merge =>
+    {
+        resources =>
+        {
+            repository => "http://svn.berlios.de/svnroot/repos/web-cpan/File-Find-Object/",
+            homepage => "http://www.shlomifish.org/open-source/projects/File-Find-Object/",
+        },
+        keywords =>
+        [
+            "bzr",
+            "cvs",
+            "file-find-object-rule",
+            "file-find-rule",
+            "find",
+            "git",
+            "mercurial",
+            "mmagic",
+            "object",
+            "revision control",
+            "subversion",
+            "types",
+            "vcs",
+            "version control",
+        ],
+    },
+);
+
+$build->create_build_script;
+

File-Find-Object-Rule-VCS/Changes

+Revision history for Perl extension File::Find::Rule::VCS
+
+1.07 Wed  8 Jul 2009
+	- Added git support to resolve #43558: .git missing
+
+1.06 Wed  8 Jul 2009
+	- Updated to Module::Install::DSL 0.91
+	- Added explicit dependency on Text::Glob.
+	  Some CPAN Testers machines seem to blow up without it.
+
+1.05 Mon 29 Sep 2008
+	- Updated to Module::Install 0.77
+	- Updated tests to new style
+	- Adding support for _svn (closes bug #32030)
+
+1.04 Sat 10 May 2008
+	- Support ->ignore_vcs() for ignoring all supported VCS
+	- Change all methods to check file name before checking
+	  it is a directory or file.
+	  This should provide a *massive* reduction in the number
+	  of filesystem -f or -d calls that get made.
+
+1.03 Sat 22 Mar 2008
+	- Adding support for Bazaar
+
+1.02 Fri 22 Sep 2006
+        - Making ->ignore_vcs('') a nullop, as a convenience
+
+1.01 Mon  4 Sep 2006
+	- Upgrading to Module::Install 0.64
+
+1.00 Sat  8 Apr 2006
+	- Moved from old CVS to new SVN repository
+	- Upgraded to Module::Install 0.61
+
+0.02 Sat 12 Feb 2005
+	- Decided that ignore_ was better than discard_
+	- When filtering CVS, remove those post-merge dot-hash files
+
+0.01 Fri 11 Feb 2005
+	- Created the initial version of the module

File-Find-Object-Rule-VCS/MANIFEST

+Build.PL
+Changes
+inc/Test/Run/Builder.pm
+lib/File/Find/Object/Rule/VCS.pm
+Makefile.PL
+MANIFEST			This list of files
+MANIFEST.SKIP
+META.yml
+t/01_compile.t
+t/02_main.t

File-Find-Object-Rule-VCS/MANIFEST.SKIP

+
+#!start included /usr/lib/perl5/vendor_perl/5.10.1/ExtUtils/MANIFEST.SKIP
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+\bSCCS\b
+,v$
+\B\.svn\b
+\B\.git\b
+\B\.gitignore\b
+\b_darcs\b
+\B\.cvsignore$
+
+# Avoid VMS specific MakeMaker generated files
+\bDescrip.MMS$
+\bDESCRIP.MMS$
+\bdescrip.mms$
+
+# Avoid Makemaker generated and utility files.
+\bMANIFEST\.bak
+\bMakefile$
+\bblib/
+\bMakeMaker-\d
+\bpm_to_blib\.ts$
+\bpm_to_blib$
+\bblibdirs\.ts$         # 6.18 through 6.25 generated this
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build/
+\bBuild.bat$
+\bBuild.COM$
+\bBUILD.COM$
+\bbuild.com$
+
+# Avoid temp and backup files.
+~$
+\.old$
+\#$
+\b\.#
+\.bak$
+\.tmp$
+\.#
+\.rej$
+
+# Avoid OS-specific files/dirs
+# Mac OSX metadata
+\B\.DS_Store
+# Mac OSX SMB mount metadata files
+\B\._
+
+# Avoid Devel::Cover and Devel::CoverX::Covered files.
+\bcover_db\b
+\bcovered\b
+ 
+# Avoid MYMETA files
+^MYMETA\.
+#!end included /usr/lib/perl5/vendor_perl/5.10.1/ExtUtils/MANIFEST.SKIP
+
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\bBuild.bat$
+\b_build
+\bBuild.COM$
+\bBUILD.COM$
+\bbuild.com$
+
+# Avoid archives of this distribution
+\bFile-Find-Object-Rule-VCS-[\d\.\_]+

File-Find-Object-Rule-VCS/META.yml

+---
+name: File-Find-Object-Rule-VCS
+version: 1.07
+author:
+  - 'Shlomi Fish <shlomif@cpan.org>'
+abstract: "Exclude files/directories for Version Control \r\nSystems"
+license: perl
+resources:
+  homepage: http://www.shlomifish.org/open-source/projects/File-Find-Object/
+  license: http://dev.perl.org/licenses/
+  repository: http://svn.berlios.de/svnroot/repos/web-cpan/File-Find-Object/
+requires:
+  File::Find::Object::Rule: 0
+  strict: 0
+  warnings: 0
+configure_requires:
+  Module::Build: 0.35
+provides:
+  File::Find::Object::Rule::VCS:
+    file: lib/File/Find/Object/Rule/VCS.pm
+generated_by: Module::Build version 0.35
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
+keywords:
+  - bzr
+  - cvs
+  - file-find-object-rule
+  - file-find-rule
+  - find
+  - git
+  - mercurial
+  - mmagic
+  - object
+  - revision control
+  - subversion
+  - types
+  - vcs
+  - version control

File-Find-Object-Rule-VCS/Makefile.PL

+# Note: this file was auto-generated by Module::Build::Compat version 0.35
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+          'NAME' => 'File::Find::Object::Rule::VCS',
+          'VERSION_FROM' => 'lib/File/Find/Object/Rule/VCS.pm',
+          'PREREQ_PM' => {
+                           'File::Find::Object::Rule' => 0,
+                           'strict' => 0,
+                           'warnings' => 0
+                         },
+          'INSTALLDIRS' => 'site',
+          'EXE_FILES' => [],
+          'PL_FILES' => {}
+        )
+;

File-Find-Object-Rule-VCS/inc/Test/Run/Builder.pm

+package Test::Run::Builder;
+
+use strict;
+use warnings;
+
+use Module::Build;
+
+use vars qw(@ISA);
+
+@ISA = (qw(Module::Build));
+
+sub ACTION_runtest
+{
+    my ($self) = @_;
+    my $p = $self->{properties};
+
+    $self->depends_on('code');
+
+    local @INC = @INC;
+
+    # Make sure we test the module in blib/
+    unshift @INC, (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'),
+		 File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'));
+
+    $self->do_test_run_tests;
+}
+
+sub ACTION_distruntest {
+  my ($self) = @_;
+
+  $self->depends_on('distdir');
+
+  my $start_dir = $self->cwd;
+  my $dist_dir = $self->dist_dir;
+  chdir $dist_dir or die "Cannot chdir to $dist_dir: $!";
+  # XXX could be different names for scripts
+
+  $self->run_perl_script('Build.PL') # XXX Should this be run w/ --nouse-rcfile
+      or die "Error executing 'Build.PL' in dist directory: $!";
+  $self->run_perl_script('Build')
+      or die "Error executing 'Build' in dist directory: $!";
+  $self->run_perl_script('Build', [], ['runtest'])
+      or die "Error executing 'Build test' in dist directory";
+  chdir $start_dir;
+}
+
+sub do_test_run_tests
+{
+    my $self = shift;
+
+    require Test::Run::CmdLine::Iface;
+
+    my $test_run =
+        Test::Run::CmdLine::Iface->new(
+            {
+                'test_files' => [glob("t/*.t")],
+            }   
+            # 'backend_params' => $self->_get_backend_params(),
+        );
+
+    return $test_run->run();
+}
+
+sub ACTION_tags
+{
+    return 
+        system(qw(
+            ctags -f tags --recurse --totals
+    		--exclude=blib/ --exclude=t/lib
+    		--exclude=.svn --exclude='*~'
+    		--languages=Perl --langmap=Perl:+.t
+    ));
+}
+
+1;
+

File-Find-Object-Rule-VCS/lib/File/Find/Object/Rule/VCS.pm

+package File::Find::Object::Rule::VCS;
+
+=pod
+
+=head1 NAME
+
+File::Find::Object::Rule::VCS - Exclude files/directories for Version Control 
+Systems
+
+=head1 SYNOPSIS
+
+  use File::Find::Object::Rule      ();
+  use File::Find::Object::Rule::VCS ();
+  
+  # Find all files smaller than 10k, ignoring version control files
+  my @files = File::Find::Object::Rule->ignore_vcs
+                                      ->file
+                                      ->size('<10Ki')
+                                      ->in( $dir );
+
+=head1 DESCRIPTION
+
+Many tools need to be equally useful both on ordinary files, and on code
+that has been checked out from revision control systems.
+
+B<File::Find::Object::Rule::VCS> provides quick and convenient methods to
+exclude the version control directories of several major Version
+Control Systems (currently CVS, subversion, and Bazaar).
+
+B<File::Find::Object::Rule::VCS> implements methods to ignore the following:
+
+=over 4
+
+=item B<CVS>
+
+=item B<Subversion>
+
+=item B<Bazaar>
+
+=back
+
+In addition, the following version control systems do not create
+directories in the checkout and do not require the use of any
+ignore methods
+
+=over 4
+
+=item B<SVK>
+
+=item B<Git>
+
+=back
+
+=head1 METHODS
+
+=cut
+
+use 5.00503;
+
+use strict;
+use warnings;
+
+use UNIVERSAL;
+use Carp                  ();
+use Text::Glob       0.08 ();
+use File::Find::Object::Rule ();
+
+use vars qw{$VERSION @ISA @EXPORT};
+
+use base 'File::Find::Object::Rule';
+
+my $FFOR = 'File::Find::Object::Rule';
+
+# In some Windows SVN implementations, it uses _svn instead of
+# .svn, so use both on Win32.
+my @svn = ($^O eq 'MSWin32') ? ('.svn', '_svn') : ('.svn');
+
+#####################################################################
+# File::Find::Object::Rule Method Addition
+
+=pod
+
+=head2 ignore_vcs
+
+  # Ignore all common version control systems
+  $find->ignore_vcs;
+  
+  # Ignore a specific named version control systems
+  $find->ignore_vcs($name);
+  
+  # Ignore nothing (silent pass-through)
+  $find->ignore_vcs('');
+
+The C<ignore_vcs> method excludes the files for a named Version Control
+System from your L<File::Find::Object::Rule> search.
+
+If passed, the name of the version control system is case in-sensitive.
+Names currently supported are 'cvs', 'svn', 'subversion', 'bzr', and
+'bazaar'.
+
+As a convenience for high-level APIs, if the VCS name is the defined
+null string B<''> then the call will be treated as a nullop.
+
+If no params at all are passed, this method will ignore all supported
+version control systems. If ignoring every version control system,
+please note that any legitimate directories called "CVS" or files
+starting with .# will be ignored, which is not always desirable.
+
+In widely-distributed code, you instead should try to detect the specific
+version control system used and call ignore_vcs with the specific name.
+
+Passing C<undef>, or an unsupported name, will throw an exception.
+
+=cut
+
+sub File::Find::Object::Rule::ignore_vcs {
+	my $find = $_[0]->_force_object;
+
+	# Handle special cases
+	unless ( @_ ) {
+		# Logically combine all the ignores. This will be much
+		# faster than just calling them all one after the other.
+		return $find->or(
+			$FFOR->name(@svn, '.bzr', '.git', 'CVS')->directory->prune->discard,
+			$FFOR->name(qr/^\.\#/)->file->discard,
+			$FFOR->new,
+			);
+	}
+	unless ( defined $_[1] ) {
+		Carp::croak("->ignore_vcs: No version control system name provided");
+	}
+
+        # As a convenience for higher-level APIs
+        # we treat a defined null string as a nullop
+	my $vcs = lc $_[1];
+        return $find if $vcs eq '';
+
+	# Hand off to the rules for each VCS
+	return $find->ignore_cvs if $vcs eq 'cvs';
+	return $find->ignore_svn if $vcs eq 'svn';
+	return $find->ignore_svn if $vcs eq 'subversion';
+	return $find->ignore_bzr if $vcs eq 'bzr';
+	return $find->ignore_bzr if $vcs eq 'bazaar';
+	return $find->ignore_git if $vcs eq 'git';
+	Carp::croak("->ignore_vcs: '$vcs' is not supported");
+}
+
+=pod
+
+=head2 ignore_cvs
+
+The C<ignore_cvs> method excluding all CVS directories from your
+L<File::Find::Object::Rule> search.
+
+It will also exclude all the files left around by CVS after an
+automated merge that start with C<'.#'> (dot-hash).
+
+=cut
+
+sub File::Find::Object::Rule::ignore_cvs {
+	my $find = $_[0]->_force_object;
+	return $find->or(
+		$FFOR->name('CVS')->directory->prune->discard,
+		$FFOR->name(qr/^\.\#/)->file->discard,
+		$FFOR->new,
+		);
+}
+
+=pod
+
+=head2 ignore_svn
+
+The C<ignore_svn> method excluding all Subversion (C<.svn>) directories
+from your L<File::Find::Object::Rule> search.
+
+=cut
+
+sub File::Find::Object::Rule::ignore_svn {
+	my $find = $_[0]->_force_object;
+	return $find->or(
+		$FFOR->name(@svn)->directory->prune->discard,
+		$FFOR->new,
+		);
+}
+
+=pod
+
+=head2 ignore_bzr
+
+The C<ignore_bzr> method excluding all Bazaar (C<.bzr>) directories
+from your L<File::Find::Object::Rule> search.
+
+=cut
+
+sub File::Find::Object::Rule::ignore_bzr {
+	my $find = $_[0]->_force_object;
+	return $find->or(
+		$FFOR->name('.bzr')->directory->prune->discard,
+		$FFOR->new,
+		);
+}
+
+=pod
+
+=head2 ignore_git
+
+The C<ignore_git> method excluding all Git (C<.git>) directories
+from your L<File::Find::Object::Rule> search.
+
+=cut
+
+sub File::Find::Object::Rule::ignore_git {
+	my $find = $_[0]->_force_object;
+	return $find->or(
+		$FFOR->name('.git')->directory->prune->discard,
+		$FFOR->new,
+		);
+}
+
+1;
+
+=pod
+
+=head1 TO DO
+
+- Add support for other version control systems.
+
+- Add other useful VCS-related methods
+
+=head1 SUPPORT
+
+Bugs should always be submitted via the CPAN bug tracker
+
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Find-Rule-VCS>
+
+For other issues, contact the maintainer
+
+=head1 AUTHOR
+
+=head2 ORIGINAL AUTHOR 
+
+Adam Kennedy E<lt>adamk@cpan.orgE<gt>
+
+=head2 MAINTAINER
+
+Shlomi Fish, L<http://www.shlomifish.org/>
+
+=head1 SEE ALSO
+
+L<http://ali.as/>, L<File::Find::Object::Rule>
+
+Note: this code originated from Adam Kennedy's L<File::Find::Rule::VCS>
+and was span-off/forked with his permission.
+
+=head1 COPYRIGHT
+
+Copyright 2005 - 2009 Adam Kennedy.
+
+This program is free software; you can redistribute
+it and/or modify it under the same terms as Perl itself.
+
+The full text of the license can be found in the
+LICENSE file included with this module.
+
+=head2 Modification Disclaimer
+
+Modified by Shlomi Fish, 2009. All rights disclaimed.
+
+=cut

File-Find-Object-Rule-VCS/t/01_compile.t

+#!/usr/bin/perl
+
+# Load testing for File::Find::Rule::VCS
+
+use strict;
+BEGIN {
+	$|  = 1;
+	$^W = 1;
+}
+
+use Test::More tests => 2;
+
+# Check their perl version
+ok( $] >= 5.00503, "Your perl is new enough" );
+
+# Load the modules
+use_ok( 'File::Find::Object::Rule::VCS' );

File-Find-Object-Rule-VCS/t/02_main.t

+#!/usr/bin/perl
+
+# Testing for File::Find::Rule::VCS
+
+use strict;
+BEGIN {
+        $|  = 1;
+        $^W = 1;
+}
+
+use Test::More tests => 5;
+use File::Find::Object::Rule      ();
+use File::Find::Object::Rule::VCS ();
+use constant FFOR => 'File::Find::Object::Rule';
+
+# Check the methods are added
+ok( FFOR->can('ignore_vcs'), '->ignore_vcs method exists' );
+ok( FFOR->can('ignore_cvs'), '->ignore_cvs method exists' );
+ok( FFOR->can('ignore_svn'), '->ignore_svn method exists' );
+ok( FFOR->can('ignore_bzr'), '->ignore_bzr method exists' );
+
+# Make an object containing all of them, to ensure there are no errors
+my $Rule = File::Find::Object::Rule->new
+                           ->ignore_cvs
+                           ->ignore_svn
+                           ->ignore_bzr
+                           ->ignore_vcs('')
+                           ->ignore_vcs('cvs')
+                           ->ignore_vcs('svn')
+                           ->ignore_vcs('bzr');
+isa_ok( $Rule, 'File::Find::Object::Rule' );
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.