[libcode-tidyall-perl] 58/374: remove only_plugins, add mode

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:25:49 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 4c11ef6d5326aa11401c95b36d78dab3f12569b5
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Fri Jun 29 09:43:34 2012 -0700

    remove only_plugins, add mode
---
 lib/Code/TidyAll.pm         |   19 +++++++------------
 lib/Code/TidyAll/t/Basic.pm |    9 +++++++++
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/lib/Code/TidyAll.pm b/lib/Code/TidyAll.pm
index 8115b06..505165c 100644
--- a/lib/Code/TidyAll.pm
+++ b/lib/Code/TidyAll.pm
@@ -9,6 +9,7 @@ use Date::Format;
 use Digest::SHA1 qw(sha1_hex);
 use File::Find qw(find);
 use File::Zglob;
+use List::Pairwise qw(grepp mapp);
 use Time::Duration::Parse qw(parse_duration);
 use Try::Tiny;
 use strict;
@@ -19,9 +20,9 @@ sub valid_params {
       backup_ttl
       conf_file
       data_dir
+      mode
       no_backups
       no_cache
-      only_plugins
       output_suffix
       plugins
       postfilter
@@ -57,15 +58,6 @@ sub new {
     if ( my $conf_file = delete( $params{conf_file} ) ) {
         my $conf_params = $class->_read_conf_file($conf_file);
         my $main_params = delete( $conf_params->{'_'} ) || {};
-        if ( my $only_plugins = $params{only_plugins} ) {
-            $conf_params = {
-                map {
-                    $conf_params->{$_}
-                      ? ( $_, $conf_params->{$_} )
-                      : die "no conf for plugin '$_'"
-                } @$only_plugins
-            };
-        }
         %params = (
             plugins  => $conf_params,
             root_dir => realpath( dirname($conf_file) ),
@@ -115,11 +107,14 @@ sub new {
         $self->_purge_backups_periodically();
     }
 
-    my $plugins = $self->plugins;
+    if ( my $mode = $self->mode ) {
+        $self->{plugins} =
+          { grepp { $b->{modes} && ( " " . $b->{modes} . " " =~ /$mode/ ) } %{ $self->plugins } };
+    }
 
     $self->{base_sig} = $self->_sig( [ $Code::TidyAll::VERSION || 0 ] );
     $self->{plugin_objects} =
-      [ map { $self->load_plugin( $_, $plugins->{$_} ) } sort keys( %{ $self->plugins } ) ];
+      [ map { $self->load_plugin( $_, $self->plugins->{$_} ) } sort keys( %{ $self->plugins } ) ];
     $self->{matched_files} = $self->_find_matched_files;
 
     return $self;
diff --git a/lib/Code/TidyAll/t/Basic.pm b/lib/Code/TidyAll/t/Basic.pm
index 914115f..aa347b7 100644
--- a/lib/Code/TidyAll/t/Basic.pm
+++ b/lib/Code/TidyAll/t/Basic.pm
@@ -67,6 +67,15 @@ sub test_basic : Tests {
         desc    => 'one file UpperText',
     );
     $self->tidy(
+        plugins => {
+            %UpperText, test_plugin('ReverseFoo') => { select => '**/foo*', modes => 'reversals' }
+        },
+        source  => { "foo.txt" => "abc" },
+        dest    => { "foo.txt" => "cba" },
+        desc    => 'one file reversals mode',
+        options => { mode      => 'reversals' },
+    );
+    $self->tidy(
         plugins => { %UpperText, %ReverseFoo },
         source  => {
             "foo.txt" => "abc",

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