[libcode-tidyall-perl] 20/374: add --root-dir, --conf-file

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:25:41 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libcode-tidyall-perl.

commit 761c69b287fc53f93a963abe8a920df33fc5bf14
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Fri Jun 15 19:16:31 2012 -0500

    add --root-dir, --conf-file
---
 bin/tidyall              |   11 +++++++----
 lib/Code/TidyAll.pm      |   10 +++++-----
 lib/Code/TidyAll/Util.pm |    2 +-
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/bin/tidyall b/bin/tidyall
index a4ede36..c2c03fc 100755
--- a/bin/tidyall
+++ b/bin/tidyall
@@ -1,4 +1,5 @@
 #!/usr/bin/perl
+use Cwd qw(realpath);
 use Getopt::Long;
 use Pod::Usage;
 use Code::TidyAll::Util qw(can_load dirname);
@@ -19,9 +20,11 @@ my $class = 'Code::TidyAll';
 GetOptions(
     'backup-ttl=i' => \$params{backup_ttl},
     'class=s'      => \$class,
+    'conf-file=s'  => \$params{conf_file},
     'data-dir=s'   => \$params{data_dir},
     'no-backups'   => \$params{no_backups},
     'no-cache'     => \$params{no_cache},
+    'root-dir=s'   => \$params{root_dir},
     'a|all'        => \$all,
     'h|help'       => \$help,
     'v|verbose'    => \$params{verbose},
@@ -33,16 +36,16 @@ die "cannot load '$class'" unless can_load($class);
 
 %params = slice_def( \%params );
 
+$params{conf_file} ||= "$params{root_dir}/tidyall.ini" if ( $params{root_dir} );
+
 if ($all) {
-    my $start_dir = shift(@ARGV) || cwd();
-    $params{conf_file} = $class->find_conf_file( $start_dir, "tidyall.ini" );
+    $params{conf_file} ||= $class->find_conf_file( realpath(), "tidyall.ini" );
     my $ct = $class->new(%params);
     $ct->process_all();
 }
 else {
     my @files = @ARGV or die "file(s) or -a required";
-    my $start_dir = dirname( $files[0] );
-    $params{conf_file} = $class->find_conf_file( $start_dir, "tidyall.ini" );
+    $params{conf_file} ||= $class->find_conf_file( dirname( $files[0] ), "tidyall.ini" );
     my $ct = $class->new(%params);
     $ct->process_files(@files);
 }
diff --git a/lib/Code/TidyAll.pm b/lib/Code/TidyAll.pm
index a125a9f..17872c1 100644
--- a/lib/Code/TidyAll.pm
+++ b/lib/Code/TidyAll.pm
@@ -91,7 +91,7 @@ sub new {
 
     my $plugins = $self->plugins;
 
-    $self->{base_sig} = $self->_sig( [ $Code::TidyAll::VERSION || 0, $plugins ] );
+    $self->{base_sig} = $self->_sig( [ $Code::TidyAll::VERSION || 0 ] );
     $self->{plugin_objects} =
       [ map { $self->load_plugin( $_, $plugins->{$_} ) } sort keys( %{ $self->plugins } ) ];
     $self->{matched_files} = $self->_find_matched_files;
@@ -134,7 +134,7 @@ sub process_files {
 sub _process_file {
     my ( $self, $file ) = @_;
 
-    my @plugins    = @{ $self->matched_files->{$file} || [] };
+    my @plugins = @{ $self->matched_files->{$file} || [] };
     my $small_path = $self->_small_path($file);
     if ( !@plugins ) {
         $self->msg( "[no plugins apply] %s", $small_path );
@@ -176,7 +176,7 @@ sub _process_file {
 sub _read_conf_file {
     my ( $class, $conf_file ) = @_;
     my $conf_string = read_file($conf_file);
-    my $root_dir    = basename($conf_file);
+    my $root_dir    = dirname($conf_file);
     $conf_string =~ s/\$ROOT/$root_dir/g;
     my $conf_hash = Config::INI::Reader->read_string($conf_string);
     die "'$conf_file' did not evaluate to a hash"
@@ -331,8 +331,8 @@ Code::TidyAll - Engine for tidyall, your all-in-one code tidier and validator
 
 =head1 DESCRIPTION
 
-This is the engine used by L<tidyall|tidyall>, which you can use from your
-own program instead of calling C<tidyall>.
+This is the engine used by L<tidyall|tidyall>, which you can use from your own
+program instead of calling C<tidyall>.
 
 =head1 CONSTRUCTOR OPTIONS
 
diff --git a/lib/Code/TidyAll/Util.pm b/lib/Code/TidyAll/Util.pm
index 1f9ecac..6745f6e 100644
--- a/lib/Code/TidyAll/Util.pm
+++ b/lib/Code/TidyAll/Util.pm
@@ -23,7 +23,7 @@ sub can_load {
 
     my $result;
     try {
-        eval "require $class_name";
+        eval "require $class_name";    ## no critic
         die $@ if $@;
         $result = 1;
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git



More information about the Pkg-perl-cvs-commits mailing list