[libcode-tidyall-perl] 68/374: more docs

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:25:50 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 4108d8eb35d954444ad0ef83a3926e7551a3bf89
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Tue Jul 3 13:23:42 2012 -0700

    more docs
---
 lib/Code/TidyAll.pm        |   48 +++++++++++++++++++++++++++++++++++---------
 lib/Code/TidyAll/Result.pm |   40 ++++++++++++++++++++++++++++++++----
 2 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/lib/Code/TidyAll.pm b/lib/Code/TidyAll.pm
index 577bb0c..7ee842d 100644
--- a/lib/Code/TidyAll.pm
+++ b/lib/Code/TidyAll.pm
@@ -115,13 +115,13 @@ sub new {
 
     $self->{base_sig} = $self->_sig( [ $Code::TidyAll::VERSION || 0 ] );
     $self->{plugin_objects} =
-      [ map { $self->load_plugin( $_, $self->plugins->{$_} ) } sort keys( %{ $self->plugins } ) ];
+      [ map { $self->_load_plugin( $_, $self->plugins->{$_} ) } sort keys( %{ $self->plugins } ) ];
     $self->{matched_files} = $self->_find_matched_files;
 
     return $self;
 }
 
-sub load_plugin {
+sub _load_plugin {
     my ( $self, $plugin_name, $plugin_conf ) = @_;
     my $class_name = (
         $plugin_name =~ /^\+/
@@ -165,7 +165,7 @@ sub process_file {
     my $small_path = $self->_small_path($file);
     if ( !@plugins ) {
         $self->msg( "[no plugins apply] %s", $small_path ) unless $self->quiet;
-        return Code::TidyAll::Result->new( state => 'no_match' );
+        return Code::TidyAll::Result->new( file => $file, state => 'no_match' );
     }
 
     my $cache     = $self->cache;
@@ -177,7 +177,7 @@ sub process_file {
             $cache->remove($cache_key);
         }
         else {
-            return Code::TidyAll::Result->new( state => 'cached' )
+            return Code::TidyAll::Result->new( file => $file, state => 'cached' )
               if $sig eq $self->_file_sig( $file, $orig_contents );
         }
     }
@@ -213,11 +213,12 @@ sub process_file {
 
     if ($error) {
         $self->msg( "%s", $error );
-        return Code::TidyAll::Result->new( state => 'error', msg => $error );
+        return Code::TidyAll::Result->new( file => $file, state => 'error', msg => $error );
     }
     else {
         $cache->set( $cache_key, $self->_file_sig( $file, $contents ) ) if $cache;
-        return Code::TidyAll::Result->new( state => ( $was_tidied ? 'tidied' : 'checked' ) );
+        my $state = $was_tidied ? 'tidied' : 'checked';
+        return Code::TidyAll::Result->new( file => $file, state => $state );
     }
 }
 
@@ -429,6 +430,8 @@ content.
 
 =item backup_ttl
 
+=item check_only
+
 =item conf_file
 
 =item data_dir
@@ -439,8 +442,6 @@ content.
 
 =item no_cache
 
-=item plugins
-
 =item root_dir
 
 =item quiet
@@ -463,7 +464,36 @@ Process all files; this implements the C<tidyall -a> option.
 
 =item process_files (file, ...)
 
-Process the specified files.
+Calls L</process_file> on each file. Return a list of
+L<Code::TidyAll::Result|Code::TidyAll::Result> objects, one for each file.
+
+=item process_file (file)
+
+Process the file, meaning
+
+=over
+
+=item *
+
+Check the cache and return immediately if file has not changed
+
+=item *
+
+Apply prefilters, appropriate matching plugins, and postfilters
+
+=item *
+
+Print success or failure result to STDOUT, depending on quiet/verbose settings
+
+=item *
+
+Write the cache if enabled
+
+=item *
+
+Return a L<Code::TidyAll::Result|Code::TidyAll::Result> object
+
+=back
 
 =item find_conf_file (start_dir)
 
diff --git a/lib/Code/TidyAll/Result.pm b/lib/Code/TidyAll/Result.pm
index 477bdd4..44781c5 100644
--- a/lib/Code/TidyAll/Result.pm
+++ b/lib/Code/TidyAll/Result.pm
@@ -15,18 +15,50 @@ __END__
 
 =head1 NAME
 
-Code::TidyAll::Result - Result returned from Code::TidyAll methods
+Code::TidyAll::Result - Result returned from Code::TidyAll::process_file
+
+=head1 SYNOPSIS
+
+    my $ct = Code::TidyAll->new(...);
+    my $result = $ct->process_file($file);
+    if ($result->error) {
+       ...
+    }
+
+=head1 DESCRIPTION
+
+Represents the result of
+L<Code::TidyAll::process_file|Code::TidyAll/process_file>. A list of these is
+returned from L<Code::TidyAll::process_files|Code::TidyAll/process_files>.
 
 =head1 METHODS
 
 =over
 
-=item error_count
+=item state
+
+A string, one of
+
+=over
+
+=item C<no_match> - No plugins matched this file
+
+=item C<cached> - Cache hit (file had not changed since last processed)
+
+=item C<error> - An error occurred while applying one of the plugins
+
+=item C<checked> - File was successfully checked and did not change
+
+=item C<tidied> - File was successfully checked and changed
+
+=back
+
+=item error
 
-The number of errors that occurred.
+Returns true iff state is 'error'
 
 =item ok
 
-Returns true iff there were no errors.
+Returns true iff state is not 'error'
 
 =back

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