[libcode-tidyall-perl] 246/374: Allow multiple select and ignore patterns on separate lines

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:26:28 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 05913d9cc83fbb335f7fcaccefc869f5961588d6
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Fri Sep 14 14:48:36 2012 -0400

    Allow multiple select and ignore patterns on separate lines
---
 lib/Code/TidyAll.pm        |    4 ++--
 lib/Code/TidyAll/Plugin.pm |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lib/Code/TidyAll.pm b/lib/Code/TidyAll.pm
index baba0a4..eb4bbf2 100644
--- a/lib/Code/TidyAll.pm
+++ b/lib/Code/TidyAll.pm
@@ -1,6 +1,6 @@
 package Code::TidyAll;
 use Cwd qw(realpath);
-use Config::INI::Reader;
+use Code::TidyAll::Config::INI::Reader;
 use Code::TidyAll::Cache;
 use Code::TidyAll::Util
   qw(abs2rel basename can_load dirname dump_one_line mkpath read_file rel2abs tempdir_simple uniq write_file);
@@ -277,7 +277,7 @@ sub _read_conf_file {
     my $conf_string = read_file($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);
+    my $conf_hash = Code::TidyAll::Config::INI::Reader->read_string($conf_string);
     die "'$conf_file' did not evaluate to a hash"
       unless ( ref($conf_hash) eq 'HASH' );
     return $conf_hash;
diff --git a/lib/Code/TidyAll/Plugin.pm b/lib/Code/TidyAll/Plugin.pm
index 94f3e92..52e26ec 100644
--- a/lib/Code/TidyAll/Plugin.pm
+++ b/lib/Code/TidyAll/Plugin.pm
@@ -43,6 +43,29 @@ sub _build_ignore_regex {
     return zglobs_to_regex( @{ $self->ignores } );
 }
 
+sub BUILD {
+    my ( $self, $params ) = @_;
+
+    # Strict constructor
+    #
+    $self->validate_params($params);
+}
+
+sub validate_params {
+    my ( $self, $params ) = @_;
+
+    delete( $params->{only_modes} );
+    delete( $params->{except_modes} );
+    if ( my @bad_params = grep { !$self->can($_) } keys(%$params) ) {
+        die sprintf(
+            "unknown option%s %s for plugin '%s'",
+            @bad_params > 1 ? "s" : "",
+            join( ", ", sort map { "'$_'" } @bad_params ),
+            $self->name
+        );
+    }
+}
+
 sub _parse_zglob_list {
     my ( $self, $zglob_list ) = @_;
     $zglob_list = '' if !defined($zglob_list);

-- 
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