r58660 - in /branches/upstream/libtext-autoformat-perl/current: Changes MANIFEST META.yml README lib/Text/Autoformat.pm t/._01.ignore.t t/01.ignore.t
carnil-guest at users.alioth.debian.org
carnil-guest at users.alioth.debian.org
Sun May 30 19:41:52 UTC 2010
Author: carnil-guest
Date: Sun May 30 19:41:27 2010
New Revision: 58660
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=58660
Log:
[svn-upgrade] Integrating new upstream version, libtext-autoformat-perl (1.669001)
Added:
branches/upstream/libtext-autoformat-perl/current/t/._01.ignore.t (with props)
branches/upstream/libtext-autoformat-perl/current/t/01.ignore.t
Modified:
branches/upstream/libtext-autoformat-perl/current/Changes
branches/upstream/libtext-autoformat-perl/current/MANIFEST
branches/upstream/libtext-autoformat-perl/current/META.yml
branches/upstream/libtext-autoformat-perl/current/README
branches/upstream/libtext-autoformat-perl/current/lib/Text/Autoformat.pm
Modified: branches/upstream/libtext-autoformat-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-autoformat-perl/current/Changes?rev=58660&op=diff
==============================================================================
--- branches/upstream/libtext-autoformat-perl/current/Changes (original)
+++ branches/upstream/libtext-autoformat-perl/current/Changes Sun May 30 19:41:27 2010
@@ -172,3 +172,8 @@
1.668001 Sat Apr 3 15:38:55 2010
- Removed spurious debugging statement in bad Pod. (Thanks Chris)
+
+
+1.669001 Fri May 28 07:38:36 2010
+
+ - Added major improvements to the 'ignore' option (thanks Dan!)
Modified: branches/upstream/libtext-autoformat-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-autoformat-perl/current/MANIFEST?rev=58660&op=diff
==============================================================================
--- branches/upstream/libtext-autoformat-perl/current/MANIFEST (original)
+++ branches/upstream/libtext-autoformat-perl/current/MANIFEST Sun May 30 19:41:27 2010
@@ -8,3 +8,4 @@
t/00.load.t
config.emacs
config.vim
+t/01.ignore.t
Modified: branches/upstream/libtext-autoformat-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-autoformat-perl/current/META.yml?rev=58660&op=diff
==============================================================================
--- branches/upstream/libtext-autoformat-perl/current/META.yml (original)
+++ branches/upstream/libtext-autoformat-perl/current/META.yml Sun May 30 19:41:27 2010
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Text-Autoformat
-version: 1.668001
+version: 1.669001
abstract: Automatic text wrapping and reformatting
license: ~
author:
Modified: branches/upstream/libtext-autoformat-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-autoformat-perl/current/README?rev=58660&op=diff
==============================================================================
--- branches/upstream/libtext-autoformat-perl/current/README (original)
+++ branches/upstream/libtext-autoformat-perl/current/README Sun May 30 19:41:27 2010
@@ -1,4 +1,4 @@
-Text::Autoformat version 1.668001
+Text::Autoformat version 1.669001
NAME
Text::Autoformat - Automatic and manual text wrapping and reformating
Modified: branches/upstream/libtext-autoformat-perl/current/lib/Text/Autoformat.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-autoformat-perl/current/lib/Text/Autoformat.pm?rev=58660&op=diff
==============================================================================
--- branches/upstream/libtext-autoformat-perl/current/lib/Text/Autoformat.pm (original)
+++ branches/upstream/libtext-autoformat-perl/current/lib/Text/Autoformat.pm Sun May 30 19:41:27 2010
@@ -2,7 +2,7 @@
use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Carp;
use 5.005;
-our $VERSION = '1.668001';
+our $VERSION = '1.669001';
require Exporter;
@@ -139,22 +139,15 @@
# SPECIAL IGNORANCE...
if ($args{ignore}) {
$args{all} = 1;
- my $ig_type = ref $args{ignore};
- if ($ig_type eq 'Regexp') {
- my $regex = $args{ignore};
- $args{ignore} = sub { /$regex/ };
- }
- elsif ($args{ignore} =~ /^indent/i) {
- $args{ignore} = sub { ignore_headers(@_) || /$ignore_indent/ };
- }
- croak "Expected suboutine reference as value for -ignore option"
- if ref $args{ignore} ne 'CODE';
- }
- elsif ($args{mail}) {
- $args{ignore} = \&ignore_headers;
+ $args{ignore} = _build_ignore( $args{ignore} );
}
else {
$args{ignore} = sub{0};
+ }
+
+ if ( $args{mail} ) {
+ my $ignore = $args{ignore};
+ $args{ignore} = sub { $ignore->(@_) || ignore_headers(@_) };
}
# DETABIFY
@@ -475,6 +468,28 @@
return $text . $remainder;
}
+sub _build_ignore {
+ my $ignore_arg = shift;
+ my $ig_type = ref $ignore_arg;
+ my $ignore;
+ if ($ig_type eq 'Regexp') {
+ my $regex = $ignore_arg;
+ $ignore = sub { /$regex/ };
+ } elsif ($ig_type eq 'ARRAY') {
+ my @elements = map { _build_ignore($_) } @$ignore_arg;
+ $ignore = sub {
+ for my $sub (@elements) { return 1 if $sub->(@_) }
+ return 0;
+ };
+ }
+ elsif ($ignore_arg =~ /^indent/i) {
+ $ignore = sub { ignore_headers(@_) || /$ignore_indent/ };
+ }
+ croak "Expected suboutine reference as value for -ignore option"
+ if ref $ignore ne 'CODE';
+ return $ignore;
+}
+
use utf8;
my $alpha = qr/[^\W\d_]/;
@@ -842,7 +857,7 @@
=head1 VERSION
-This document describes version 1.668001 of Text::Autoformat
+This document describes version 1.669001 of Text::Autoformat
released Apr 16, 2009.
=head1 SYNOPSIS
@@ -1046,12 +1061,17 @@
C<autoformat> will ignore any paragraph in which I<every> line begins with a
whitespace.
+You may also specify multiple C<ignore> options by including them in
+an array-ref:
+
+ $tidied_mesg = autoformat($messy, {ignore=>[qr/1/,'indented']});
+
One other special case of ignorance is ignoring mail headers and signature.
This option is specified using the C<mail> argument:
$tidied_mesg = autoformat($messy_mesg, {mail=>1});
-Note that the C<mail> option automatically implies C<all>.
+Note that the C<ignore> or C<mail> options automatically imply C<all>.
=head2 Bulleting and (re-)numbering
Added: branches/upstream/libtext-autoformat-perl/current/t/._01.ignore.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-autoformat-perl/current/t/._01.ignore.t?rev=58660&op=file
==============================================================================
Binary file - no diff available.
Propchange: branches/upstream/libtext-autoformat-perl/current/t/._01.ignore.t
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: branches/upstream/libtext-autoformat-perl/current/t/01.ignore.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-autoformat-perl/current/t/01.ignore.t?rev=58660&op=file
==============================================================================
--- branches/upstream/libtext-autoformat-perl/current/t/01.ignore.t (added)
+++ branches/upstream/libtext-autoformat-perl/current/t/01.ignore.t Sun May 30 19:41:27 2010
@@ -1,0 +1,76 @@
+use Test::More 'no_plan';
+
+use Text::Autoformat;
+
+my $in =
+# 10 20 30 40
+#234567890123456789012345678901234567890123457890
+'This is a very simple test to see what will
+happen whenver we start using an ARRAY
+of ARGUMENTS to the ignore parameter inside
+Text::Autoformat.
+
+This is a very cool module that is going to save
+me from having to do a whole lot of work on my own!
+
+I sure do hope that this works. I am going to
+be very bummed if it does not.';
+
+my $expected =
+'This is a very simple test to see what will
+happen whenver we start using an ARRAY
+of ARGUMENTS to the ignore parameter inside
+Text::Autoformat.
+
+This is a very cool module that is
+going to save me from having to do a
+whole lot of work on my own!
+
+I sure do hope that this works. I am going to
+be very bummed if it does not.';
+
+my $result = autoformat( $in,
+ { right => 38,
+ ignore => [ qr/ARRAY/, qr/bummed/ ]
+ } );
+
+chomp($result);
+is ( $result, $expected, 'Test formatting with multiple ignore parameters' );
+
+$in =
+# 10 20 30 40
+#234567890123456789012345678901234567890123457890
+'From: "me" <example at example.com>
+To: "you" <example at example.com>
+Subject: Text::Autoformat rocks my world oh so much!!!
+
+Hey there,
+
+Have you tried Text::Autoformat yet? It is the coolest thing
+in this world! You really need to try it.
+
+Regards,
+Your friend with a very very very very very long name that should not wrap.';
+
+$expected =
+'From: "me" <example at example.com>
+To: "you" <example at example.com>
+Subject: Text::Autoformat rocks my world oh so much!!!
+
+Hey there,
+
+Have you tried Text::Autoformat yet?
+It is the coolest thing in this world!
+You really need to try it.
+
+Regards,
+Your friend with a very very very very very long name that should not wrap.';
+
+$result = autoformat( $in,
+ { right => 38,
+ ignore => qr/^Regards,/,
+ mail => 1
+ } );
+
+chomp($result);
+is ( $result, $expected, 'Test formatting with ignore param and mail headers' );
More information about the Pkg-perl-cvs-commits
mailing list