[Bps-public-commit] Text-Quoted branch, master, updated. 2.07-6-ge966122

Thomas Sibley trs at bestpractical.com
Tue May 21 14:42:25 EDT 2013


The branch, master has been updated
       via  e966122ca7eec88b933263478fccda48c81cad28 (commit)
       via  8e630276d73ab2a7d7949c26fef2a80d9ae9568f (commit)
       via  d18455697224c9c902ebd2e011e23f31121582dc (commit)
       via  3e866057c290c696227649cd62398691e29f8705 (commit)
       via  eeb7b6ce9052abb01d6d8316fe760a5191b6da97 (commit)
       via  53d7c2f5db3b0c0532584f73476d6a03209c9f88 (commit)
      from  d6899eaebcba031f514e02ab40b3f46fa0fce782 (commit)

Summary of changes:
 Changes           |  5 +++++
 META.yml          |  2 +-
 Quoted.pm         | 41 +++++++++++++++++++++++++++--------------
 t/life_sample.1.t |  8 +++++++-
 t/life_sample.2.t |  8 +++++++-
 t/life_sample.3.t |  8 +++++++-
 6 files changed, 54 insertions(+), 18 deletions(-)

- Log -----------------------------------------------------------------
commit 53d7c2f5db3b0c0532584f73476d6a03209c9f88
Author: Ricardo Signes <rjbs at cpan.org>
Date:   Tue May 21 14:00:10 2013 -0400

    underscorify implicitly private methods

diff --git a/Quoted.pm b/Quoted.pm
index 7bf51de..a435471 100644
--- a/Quoted.pm
+++ b/Quoted.pm
@@ -70,10 +70,10 @@ Exported by default.
 =cut
 
 sub extract {
-    return organize( "", classify( @_ ) );
+    return _organize( "", _classify( @_ ) );
 }
 
-sub organize {
+sub _organize {
     my $top_level = shift;
     my @todo      = @_;
     $top_level = '' unless defined $top_level;
@@ -94,17 +94,17 @@ sub organize {
         elsif ( $q =~ /^\Q$top_level\E./ ) {
 
             # Find all the lines at a quoting level "below" me.
-            my $newquoter = find_below( $top_level, $line, @todo );
+            my $newquoter = _find_below( $top_level, $line, @todo );
             my @next = $line;
             push @next, shift @todo while defined $todo[0]->{quoter}
               and $todo[0]->{quoter} =~ /^\Q$newquoter/;
 
             # Find the 
-            # And pass them on to organize()!
+            # And pass them on to _organize()!
             #print "Trying to organise the following lines over $newquoter:\n";
             #print $_->{raw}."\n" for @next;
             #print "!-!-!-\n";
-            push @ret, organize( $newquoter, @next );
+            push @ret, _organize( $newquoter, @next );
         } #  else { die "bugger! I had $top_level, but now I have $line->{raw}\n"; }
     }
     return \@ret;
@@ -121,7 +121,7 @@ sub organize {
 # is incorrect - "> >" is actually a "sub-quote" of ">". This routine
 # works out which is the next level below us.
 
-sub find_below {
+sub _find_below {
     my ( $top_level, @stuff ) = @_;
 
     # Find the prefices, shortest first.
@@ -170,14 +170,14 @@ sub set_quote_characters {
 
 sub defn($) { return $_[0] if (defined $_[0]); return "" }
 
-sub classify {
+sub _classify {
     my $text = shift;
     return { raw => undef, text => undef, quoter => undef }
         unless defined $text && length $text;
     # If the user passes in a null string, we really want to end up with _something_
 
     # DETABIFY
-    my @lines = expand_tabs( split /\n/, $text );
+    my @lines = _expand_tabs( split /\n/, $text );
 
     # PARSE EACH LINE
     foreach (splice @lines) {
@@ -244,7 +244,7 @@ sub classify {
 # This bug unlikely to be fixed in 5.8.x, however we use workaround.
 # As soon as Text::Tabs will be fixed we can return back to it
 my $tabstop = 8;
-sub expand_tabs {
+sub _expand_tabs {
     my $pad;
     for ( @_ ) {
         my $offs = 0;

commit eeb7b6ce9052abb01d6d8316fe760a5191b6da97
Author: Ricardo Signes <rjbs at cpan.org>
Date:   Tue May 21 14:01:40 2013 -0400

    remove a never-called routine

diff --git a/Quoted.pm b/Quoted.pm
index a435471..f511766 100644
--- a/Quoted.pm
+++ b/Quoted.pm
@@ -168,8 +168,6 @@ sub set_quote_characters {
     $quoter     = qr/$quotechunk(?:[ \t]*$quotechunk)*/;
 }
 
-sub defn($) { return $_[0] if (defined $_[0]); return "" }
-
 sub _classify {
     my $text = shift;
     return { raw => undef, text => undef, quoter => undef }

commit 3e866057c290c696227649cd62398691e29f8705
Author: Ricardo Signes <rjbs at cpan.org>
Date:   Tue May 21 14:07:38 2013 -0400

    remove a patently false line
    
    maybe it should be moved lower, instead...
    
    ...but I can see no reason to keep it

diff --git a/Quoted.pm b/Quoted.pm
index f511766..29a8f65 100644
--- a/Quoted.pm
+++ b/Quoted.pm
@@ -135,8 +135,6 @@ sub _find_below {
     )[0];
 }
 
-# Everything below this point is essentially Text::Autoformat.
-
 # BITS OF A TEXT LINE
 
 =head2 set_quote_characters

commit d18455697224c9c902ebd2e011e23f31121582dc
Author: Ricardo Signes <rjbs at cpan.org>
Date:   Tue May 21 14:23:06 2013 -0400

    implement combine_hunks

diff --git a/Changes b/Changes
index aab0061..fc1965b 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Text::Quoted.
 
+2.08
+    - add a combine_hunks function to recombine hunks
+
 2.07    Thu May 16 18:18:01 PDT 2013
     - Add set_quote_characters() function to control what additional characters
       are treated as quoting chars (above and beyond ">")
diff --git a/Quoted.pm b/Quoted.pm
index 29a8f65..e1b476e 100644
--- a/Quoted.pm
+++ b/Quoted.pm
@@ -8,7 +8,7 @@ require Exporter;
 
 our @ISA    = qw(Exporter);
 our @EXPORT = qw(extract);
-our @EXPORT_OK = qw(set_quote_characters);
+our @EXPORT_OK = qw(set_quote_characters combine_hunks);
 
 use Text::Autoformat();    # Provides the Hang package, heh, heh.
 
@@ -166,6 +166,23 @@ sub set_quote_characters {
     $quoter     = qr/$quotechunk(?:[ \t]*$quotechunk)*/;
 }
 
+=head2 combine_hunks
+
+  my $text = combine_hunks( $arrayref_of_hunks );
+
+Takes the output of C<extract> and turns it back into text.
+
+Not exported by default, but exportable.
+
+=cut
+
+sub combine_hunks {
+    my ($hunks) = @_;
+
+    join "",
+      map {; ref $_ eq 'HASH' ? "$_->{raw}\n" : combine_hunks($_) } @$hunks;
+}
+
 sub _classify {
     my $text = shift;
     return { raw => undef, text => undef, quoter => undef }
diff --git a/t/life_sample.1.t b/t/life_sample.1.t
index 509faf4..d822631 100644
--- a/t/life_sample.1.t
+++ b/t/life_sample.1.t
@@ -5,7 +5,7 @@
 
 # change 'tests => 1' to 'tests => last_test_to_print';
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 use Text::Quoted;
 
 #########################
@@ -145,3 +145,9 @@ http://www.template-toolkit.org/mailman/listinfo/templates',
 
 is_deeply(extract($a), $expected, 
           "Supercite doesn't screw me up as badly as before");
+
+is(
+    Text::Quoted::combine_hunks( extract($a) ),
+    $a,
+    "round-trips okay",
+);
diff --git a/t/life_sample.2.t b/t/life_sample.2.t
index 8b17252..301d76a 100644
--- a/t/life_sample.2.t
+++ b/t/life_sample.2.t
@@ -5,7 +5,7 @@
 
 # change 'tests => 1' to 'tests => last_test_to_print';
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 use Text::Quoted;
 
 #########################
@@ -89,3 +89,9 @@ realted to picking them up and dropping them off at various times, as',
 
 is_deeply(extract($a), $expected, 
           "Supercite doesn't screw me up as badly as before");
+
+is(
+    Text::Quoted::combine_hunks( extract($a) ),
+    $a,
+    "round-trips okay",
+);
diff --git a/t/life_sample.3.t b/t/life_sample.3.t
index 4774575..4a66a6b 100644
--- a/t/life_sample.3.t
+++ b/t/life_sample.3.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # change 'tests => 1' to 'tests => last_test_to_print';
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 use Text::Quoted;
 
 # I don't really care what the results are, so long as we don't
@@ -16,3 +16,9 @@ my $ntk = <<'NTK';
 NTK
 
 ok(extract($ntk), "It's not pretty, but at least it works");
+
+is(
+    Text::Quoted::combine_hunks( extract($ntk) ),
+    $ntk,
+    "round-trips okay",
+);

commit 8e630276d73ab2a7d7949c26fef2a80d9ae9568f
Merge: d6899ea d184556
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Tue May 21 11:38:12 2013 -0700

    Merge branch 'pr/1'


commit e966122ca7eec88b933263478fccda48c81cad28
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Tue May 21 11:40:38 2013 -0700

    Releng for 2.08

diff --git a/Changes b/Changes
index fc1965b..66582e7 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,9 @@
 Revision history for Perl extension Text::Quoted.
 
-2.08
-    - add a combine_hunks function to recombine hunks
+2.08    Tue May 21 11:40:04 PDT 2013
+    - add a combine_hunks function to recombine hunks (RJBS)
+    - implicitly private methods are now underscore private: organize,
+      find_below, classify, expand_tabs (RJBS)
 
 2.07    Thu May 16 18:18:01 PDT 2013
     - Add set_quote_characters() function to control what additional characters
diff --git a/META.yml b/META.yml
index ab85289..41891d1 100644
--- a/META.yml
+++ b/META.yml
@@ -23,4 +23,4 @@ requires:
   perl: 5.6.0
 resources:
   license: http://dev.perl.org/licenses/
-version: 2.07
+version: 2.08
diff --git a/Quoted.pm b/Quoted.pm
index e1b476e..9a6967b 100644
--- a/Quoted.pm
+++ b/Quoted.pm
@@ -1,5 +1,5 @@
 package Text::Quoted;
-our $VERSION = "2.07";
+our $VERSION = "2.08";
 use 5.006;
 use strict;
 use warnings;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list