r68575 - in /branches/upstream/libdata-dumper-concise-perl/current: Changes META.yml lib/Data/Dumper/Concise.pm lib/Data/Dumper/Concise/Sugar.pm lib/Devel/Dwarn.pm t/concise.t t/sugar.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon Feb 14 01:54:40 UTC 2011


Author: jawnsy-guest
Date: Mon Feb 14 01:54:23 2011
New Revision: 68575

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=68575
Log:
[svn-upgrade] new version libdata-dumper-concise-perl (2.020)

Modified:
    branches/upstream/libdata-dumper-concise-perl/current/Changes
    branches/upstream/libdata-dumper-concise-perl/current/META.yml
    branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise.pm
    branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise/Sugar.pm
    branches/upstream/libdata-dumper-concise-perl/current/lib/Devel/Dwarn.pm
    branches/upstream/libdata-dumper-concise-perl/current/t/concise.t
    branches/upstream/libdata-dumper-concise-perl/current/t/sugar.t

Modified: branches/upstream/libdata-dumper-concise-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-dumper-concise-perl/current/Changes?rev=68575&op=diff
==============================================================================
--- branches/upstream/libdata-dumper-concise-perl/current/Changes (original)
+++ branches/upstream/libdata-dumper-concise-perl/current/Changes Mon Feb 14 01:54:23 2011
@@ -1,3 +1,8 @@
+2.020 Jan 20 2011
+  - Add DumperObject for getting at the underlying obj
+  - create DwarnF for formatting Dumper'd output
+  - Create Ddie for die'ing output
+
 2.012 Aug 31 2010
   - Make DwarnN test still work if Devel::ArgNames isn't installed
 

Modified: branches/upstream/libdata-dumper-concise-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-dumper-concise-perl/current/META.yml?rev=68575&op=diff
==============================================================================
--- branches/upstream/libdata-dumper-concise-perl/current/META.yml (original)
+++ branches/upstream/libdata-dumper-concise-perl/current/META.yml Mon Feb 14 01:54:23 2011
@@ -22,4 +22,4 @@
   perl: 5.6.0
 resources:
   license: http://dev.perl.org/licenses/
-version: 2.012
+version: 2.020

Modified: branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise.pm?rev=68575&op=diff
==============================================================================
--- branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise.pm (original)
+++ branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise.pm Mon Feb 14 01:54:23 2011
@@ -2,19 +2,25 @@
 
 use 5.006;
 
-$VERSION = '2.012';
+$VERSION = '2.020';
 
 require Exporter;
 require Data::Dumper;
 
 BEGIN { @ISA = qw(Exporter) }
 
- at EXPORT = qw(Dumper);
+ at EXPORT = qw(Dumper DumperF DumperObject);
 
-sub Dumper {
+sub DumperObject {
   my $dd = Data::Dumper->new([]);
   $dd->Terse(1)->Indent(1)->Useqq(1)->Deparse(1)->Quotekeys(0)->Sortkeys(1);
-  return $dd->Values([ @_ ])->Dump;
+}
+
+sub Dumper { DumperObject->Values([ @_ ])->Dump }
+
+sub DumperF (&@) {
+  my $code = shift;
+  return $code->(map Dumper($_), @_);
 }
 
 =head1 NAME
@@ -64,6 +70,19 @@
   };
 
 (note the tab indentation, oh joy ...)
+
+If you need to get the underlying L<Dumper> object just call C<DumperObject>.
+
+Also try out C<DumperF> which takes a C<CodeRef> as the first argument to
+format the output.  For example:
+
+  use Data::Dumper::Concise;
+
+  warn DumperF { "result: $_[0] result2: $_[1]" } $foo, $bar;
+
+Which is the same as:
+
+  warn 'result: ' . Dumper($foo) . ' result2: ' . Dumper($bar);
 
 =head1 DESCRIPTION
 

Modified: branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise/Sugar.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise/Sugar.pm?rev=68575&op=diff
==============================================================================
--- branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise/Sugar.pm (original)
+++ branches/upstream/libdata-dumper-concise-perl/current/lib/Data/Dumper/Concise/Sugar.pm Mon Feb 14 01:54:23 2011
@@ -7,7 +7,10 @@
 
 BEGIN { @ISA = qw(Exporter) }
 
- at EXPORT = qw($Dwarn $DwarnN Dwarn DwarnS DwarnL DwarnN);
+ at EXPORT = qw(
+   $Dwarn $DwarnN Dwarn DwarnS DwarnL DwarnN DwarnF
+   $Ddie $DdieN Ddie DdieS DdieL DdieN DdieD
+);
 
 sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) }
 
@@ -22,6 +25,23 @@
    require Devel::ArgNames;
    my $x = Devel::ArgNames::arg_names();
    warn(($x?$x:'(anon)') . ' => ' . Data::Dumper::Concise::Dumper $_[0]); $_[0]
+}
+
+sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ }
+
+sub Ddie { DdieL(@_) if wantarray; DdieS($_[0]) }
+
+our $Ddie = \&Ddie;
+our $DdieN = \&DdieN;
+
+sub DdieL { die Data::Dumper::Concise::Dumper @_ }
+
+sub DdieS ($) { die Data::Dumper::Concise::Dumper $_[0] }
+
+sub DdieN ($) {
+   require Devel::ArgNames;
+   my $x = Devel::ArgNames::arg_names();
+   die(($x?$x:'(anon)') . ' => ' . Data::Dumper::Concise::Dumper $_[0]);
 }
 
 =head1 NAME
@@ -100,6 +120,22 @@
   warn Dumper($return);
   return $return;
 
+If you want to format the output of your data structures, try DwarnF
+
+ my ($a, $c) = DwarnF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy;
+
+is equivalent to:
+
+  my @return = ($awesome, $cheesy);
+  warn DumperF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy;
+  return @return;
+
+If you want to immediately die after outputting the data structure, every
+Dwarn subroutine has a paired Ddie version, so just replace the warn with die.
+For example:
+
+ DdieL 'foo', { bar => 'baz' };
+
 =head1 DESCRIPTION
 
   use Data::Dumper::Concise::Sugar;
@@ -132,6 +168,10 @@
   sub DwarnN { warn '$argname => ' . Data::Dumper::Concise::Dumper $_[0]; $_[0] }
 
 B<Note>: this requires L<Devel::ArgNames> to be installed.
+
+=head2 DwarnF
+
+  sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ }
 
 =head1 TIPS AND TRICKS
 

Modified: branches/upstream/libdata-dumper-concise-perl/current/lib/Devel/Dwarn.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-dumper-concise-perl/current/lib/Devel/Dwarn.pm?rev=68575&op=diff
==============================================================================
--- branches/upstream/libdata-dumper-concise-perl/current/lib/Devel/Dwarn.pm (original)
+++ branches/upstream/libdata-dumper-concise-perl/current/lib/Devel/Dwarn.pm Mon Feb 14 01:54:23 2011
@@ -82,6 +82,12 @@
   warn Dumper($return);
   return $return;
 
+If you want to immediately die after outputting the data structure, every
+Dwarn subroutine has a paired Ddie version, so just replace the warn with die.
+For example:
+
+ DdieL 'foo', { bar => 'baz' };
+
 =head1 TIPS AND TRICKS
 
 =head2 global usage

Modified: branches/upstream/libdata-dumper-concise-perl/current/t/concise.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-dumper-concise-perl/current/t/concise.t?rev=68575&op=diff
==============================================================================
--- branches/upstream/libdata-dumper-concise-perl/current/t/concise.t (original)
+++ branches/upstream/libdata-dumper-concise-perl/current/t/concise.t Mon Feb 14 01:54:23 2011
@@ -33,3 +33,7 @@
 
   is($example, Dumper(@$to_dump), 'Subroutine call usage equivalent');
 }
+
+my $out = DumperF { "arr: $_[0] str: $_[1]" } [qw(wut HALP)], "gnarl";
+
+is($out, qq{arr: [\n  "wut",\n  "HALP"\n]\n str: "gnarl"\n}, 'DumperF works!');

Modified: branches/upstream/libdata-dumper-concise-perl/current/t/sugar.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdata-dumper-concise-perl/current/t/sugar.t?rev=68575&op=diff
==============================================================================
--- branches/upstream/libdata-dumper-concise-perl/current/t/sugar.t (original)
+++ branches/upstream/libdata-dumper-concise-perl/current/t/sugar.t Mon Feb 14 01:54:23 2011
@@ -45,6 +45,13 @@
    ok eq_array($foo, ['warn','friend']), 'Dwarn passes lists through correctly';
 }
 
+DWARNF: {
+   my @foo = DwarnF { "arr: $_[0] str: $_[1]" } [qw(wut HALP)], "gnarl";
+
+   is($warned_string, qq{arr: [\n  "wut",\n  "HALP"\n]\n str: "gnarl"\n}, 'DumperF works!');
+   ok eq_array($foo[0], ['wut','HALP']) && $foo[1] eq 'gnarl', 'DwarnF passes lists through correctly';
+}
+
 DWARNN: {
    my $loaded = eval { require Devel::ArgNames; 1 };
    if ($loaded) {
@@ -59,3 +66,10 @@
    }
 }
 
+DDIE: {
+   eval {
+      DdieS [ 'k', 'bar' ];
+   };
+   is $@, qq{[\n  "k",\n  "bar"\n]\n}, 'DwarnD dies output correctly';
+}
+




More information about the Pkg-perl-cvs-commits mailing list