aboutsummaryrefslogtreecommitdiffstats
path: root/Perl/Webwml
diff options
context:
space:
mode:
authorBas Zoetekouw <bas>2008-09-21 16:34:46 +0000
committerBas Zoetekouw <bas>2008-09-21 16:34:46 +0000
commit73b2052c3f19e1f2c17f8177b1e1fcfb8a239ab8 (patch)
tree8712a665e86c9a3e4866f0195dcb03968da61cf8 /Perl/Webwml
parent259e6a26d632f13b6d5d48e38771c2dbdb2c3827 (diff)
Fix Webwml::TransIgnore to use VCS_CVS.pm instead of Cvsinfo.pm.
Also clean up the script, and reindent. CVS version numbers Perl/Webwml/TransIgnore.pm: 1.1 -> 1.2
Diffstat (limited to 'Perl/Webwml')
-rw-r--r--Perl/Webwml/TransIgnore.pm176
1 files changed, 99 insertions, 77 deletions
diff --git a/Perl/Webwml/TransIgnore.pm b/Perl/Webwml/TransIgnore.pm
index fd3f8e907b2..4974976b5db 100644
--- a/Perl/Webwml/TransIgnore.pm
+++ b/Perl/Webwml/TransIgnore.pm
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
## Copyright (C) 2001 Denis Barbier <barbier@debian.org>
##
@@ -30,70 +30,83 @@ directory, it contains files which must be ignored in all languages.
=cut
package Webwml::TransIgnore;
+
use Carp;
+use File::Spec::Functions;
+use Local::VCS_CVS qw{ vcs_get_topdir };
+
use strict;
-use Local::Cvsinfo;
+use warnings;
=item new
-This is the constructor. If called with an argument, it tells where to
-find top-level webwml directory. Otherwise it is automatically
-determined by parsing F<CVS/Repository>.
+This is the constructor. The argument specifies where to find the
+top-level webwml directory. If the method is called without arguments, to
+top-level directory is automatically determined.
my $ti = Webwml::TransIgnore->new("foo/bar");
=cut
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $dir = shift
- or croak "Missing argument in Webwml::TransIgnore->new";
- my $self = {
- GLOBAL => [],
- LOCAL => [],
- FOUND => 0,
- };
- bless ($self, $class);
- my $root;
- if (@_) {
- $root = shift;
- } else {
- my $cvs = Local::Cvsinfo->new();
- $cvs->readinfo('.');
- $root = $cvs->topdir()
- or croak "Unable to determine top-level directory";
- }
- # Read global .transignore file
- $self->_read($root);
- for (0 .. $#{$self->{LOCAL}}) {
- ${$self->{LOCAL}}[$_] =~ s{^$root/}{};
- }
- $self->{GLOBAL} = $self->{LOCAL};
- # reinitialize $self->{LOCAL}
- $self->{LOCAL} = [];
- # and read $dir/.transignore
- $self->{FOUND} = $self->_read($dir);
- return $self;
+sub new
+{
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $dir = shift;
+
+ # init the object
+ my $self =
+ {
+ GLOBAL => [],
+ LOCAL => [],
+ FOUND => 0,
+ };
+ bless ($self, $class);
+
+ # determine the root dir
+ my $root = shift || vcs_get_topdir('.');
+
+ # Read global .transignore file
+ $self->_read($root);
+
+ # remove the root path from the front of the files
+ for (0 .. $#{$self->{LOCAL}})
+ {
+ ${$self->{LOCAL}}[$_] =~ s{^$root/}{};
+ }
+ $self->{GLOBAL} = $self->{LOCAL};
+
+ # reinitialize $self->{LOCAL}
+ $self->{LOCAL} = [];
+ # and read $dir/.transignore
+ $self->{FOUND} = $self->_read($dir);
+
+ return $self;
}
-sub _read {
- my $self = shift;
- my $dir = shift;
- $dir .= "/";
- my $status = 0;
- my $file = $dir . ".transignore";
- my $line;
- splice (@{$self->{LOCAL}}, 0);
- open(FILE, "< $file") or return 0;
- while (<FILE>) {
- next if m/^#/;
- next if m/^\s*$/;
- chomp;
- push (@{$self->{LOCAL}}, $dir.$_);
- }
- close(FILE);
- return 1;
+sub _read
+{
+ my $self = shift;
+ my $dir = shift;
+
+ my $status = 0;
+ my $file = catfile( $dir, '.transignore' );
+
+ my $line;
+ splice( @{$self->{LOCAL}}, 0 );
+
+ open( my $fd, '<', $file) or return 0;
+ while ( my $line = <$fd> )
+ {
+ next if $line =~ m/^#/;
+ next if $line =~ m/^\s*$/;
+ chomp $line;
+
+ push( @{$self->{LOCAL}}, catfile($dir, $line) );
+ }
+ close($fd);
+
+ return 1;
}
=item found
@@ -102,9 +115,10 @@ Return 1 if .transignore file was found, 0 otherwise.
=cut
-sub found {
- my $self = shift;
- return $self->{FOUND};
+sub found
+{
+ my $self = shift;
+ return $self->{FOUND};
}
=item local
@@ -115,9 +129,10 @@ Return the list of files found in F<.transignore> file.
=cut
-sub local {
- my $self = shift;
- return $self->{LOCAL};
+sub local
+{
+ my $self = shift;
+ return $self->{LOCAL};
}
=item global
@@ -128,9 +143,10 @@ Return the list of files defined
=cut
-sub global {
- my $self = shift;
- return $self->{GLOBAL};
+sub global
+{
+ my $self = shift;
+ return $self->{GLOBAL};
}
=item is_local
@@ -141,13 +157,17 @@ Return 1 if argument is listed in .transignore, 0 otherwise
=cut
-sub is_local {
- my $self = shift;
- my $entry = shift;
- foreach (@{$self->{LOCAL}}) {
- return 1 if $_ eq $entry;
- }
- return 0;
+sub is_local
+{
+ my $self = shift;
+ my $entry = shift;
+
+ foreach my $file ( @{$self->{LOCAL}} )
+ {
+ return 1 if $file eq $entry;
+ }
+
+ return 0;
}
=item is_global
@@ -158,13 +178,16 @@ Return 1 if argument has been defined, 0 otherwise.
=cut
-sub is_global {
- my $self = shift;
- my $entry = shift;
- foreach (@{$self->{GLOBAL}}) {
- return 1 if $_ eq $entry;
- }
- return 0;
+sub is_global
+{
+ my $self = shift;
+ my $entry = shift;
+
+ foreach my $file ( @{$self->{GLOBAL}} )
+ {
+ return 1 if $file eq $entry;
+ }
+ return 0;
}
=back
@@ -181,4 +204,3 @@ the Free Software Foundation; either version 2 of the License, or
=cut
1;
-

© 2014-2024 Faster IT GmbH | imprint | privacy policy