autobox-dump-20090426.1746/0000755000175000017500000000000011175117571014372 5ustar cowenscowensautobox-dump-20090426.1746/Changes0000444000175000017500000000064311175117571015666 0ustar cowenscowensRevision history for autobox-dump 20090425.1630 2009-04-25/1630 Schwern rearanged the code and added some options to Data::Dumper I renamed the pragma to autobox-dump at Schwern's request. I removed the pod tests. I added Useqq option to Data::Dumper to allow unprintable characters to be seen (part of the human readable part. 20090425 2009-04-25/0255 First version, released on an unsuspecting world. autobox-dump-20090426.1746/MANIFEST.SKIP0000444000175000017500000000115111175117571016264 0ustar cowenscowens #!start included /usr/local/perl/5.10.0/lib/5.10.0/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ # Avoid Devel::Cover files. \bcover_db\b #!end included /usr/local/perl/5.10.0/lib/5.10.0/ExtUtils/MANIFEST.SKIP autobox-dump-20090426.1746/Build.PL0000444000175000017500000000075111175117571015667 0ustar cowenscowensuse strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'autobox::dump', license => 'perl', dist_author => 'Chas. J Owens IV ', dist_version_from => 'lib/autobox/dump.pm', build_requires => { 'Test::More' => 0, 'autobox' => 0, }, add_to_cleanup => [ 'autobox-dump-*' ], create_makefile_pl => 'traditional', ); $builder->create_build_script(); autobox-dump-20090426.1746/MANIFEST0000444000175000017500000000026411175117571015523 0ustar cowenscowensBuild.PL Changes lib/autobox/dump.pm MANIFEST This list of files MANIFEST.SKIP README t/00-load.t t/01-scalars.t t/02-arrays.t t/03-hashes.t t/boilerplate.t Makefile.PL META.yml autobox-dump-20090426.1746/t/0000755000175000017500000000000011175117571014635 5ustar cowenscowensautobox-dump-20090426.1746/t/02-arrays.t0000444000175000017500000000122711175117571016542 0ustar cowenscowens#!/usr/bin/perl use strict; use warnings; use Test::More tests => 8; use autobox::dump; my @a = qw/a b c d 0/; my $ref = \@a; my @lol = map { [ 1 .. 5 ] } 1 .. 5; is_deeply eval @a->perl, [@a]; is_deeply eval [@a]->perl, [@a]; is_deeply eval $ref->perl, $ref; is_deeply eval @lol->perl, \@lol; #test passing of options is @a->perl([Indent => 0], [Varname => 'a'], qw/Useqq/), qq(\$a1 = ["a","b","c","d",0];); #no options still works normally is [0]->perl, "[\n 0\n]\n"; #test setting defaults can_ok "autobox::dump", qw/options/; autobox::dump->options([Indent => 0], [Varname => 'a'], qw/Useqq/); is @a->perl, qq(\$a1 = ["a","b","c","d",0];); autobox-dump-20090426.1746/t/boilerplate.t0000444000175000017500000000232711175117571017326 0ustar cowenscowens#!perl -T use strict; use warnings; use Test::More tests => 3; sub not_in_file_ok { my ($filename, %regex) = @_; open( my $fh, '<', $filename ) or die "couldn't open $filename for reading: $!"; my %violated; while (my $line = <$fh>) { while (my ($desc, $regex) = each %regex) { if ($line =~ $regex) { push @{$violated{$desc}||=[]}, $.; } } } if (%violated) { fail("$filename contains boilerplate text"); diag "$_ appears on lines @{$violated{$_}}" for keys %violated; } else { pass("$filename contains no boilerplate text"); } } sub module_boilerplate_ok { my ($module) = @_; not_in_file_ok($module => 'the great new $MODULENAME' => qr/ - The great new /, 'boilerplate description' => qr/Quick summary of what the module/, 'stub function definition' => qr/function[12]/, ); } not_in_file_ok(README => "The README is used..." => qr/The README is used/, "'version information here'" => qr/to provide version information/, ); not_in_file_ok(Changes => "placeholder date/time" => qr(Date/time) ); module_boilerplate_ok('lib/autobox/dump.pm'); autobox-dump-20090426.1746/t/00-load.t0000444000175000017500000000022511175117571016153 0ustar cowenscowens#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'autobox::dump' ); } diag( "Testing autobox::dump $autobox::dump::VERSION, Perl $], $^X" ); autobox-dump-20090426.1746/t/03-hashes.t0000444000175000017500000000045311175117571016515 0ustar cowenscowens#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; use autobox::dump; sub func { return { a => 1, b => 2 }; } my %h = ( one => 1, two => 2, three => [1, 1, 1] ); my $ref = \%h; is_deeply eval %h->perl, \%h; is_deeply eval $ref->perl, $ref; is_deeply eval func->perl, func; autobox-dump-20090426.1746/t/01-scalars.t0000444000175000017500000000114211175117571016664 0ustar cowenscowens#!/usr/bin/perl use strict; use warnings; use Test::More tests => 11; use autobox::dump; is eval 5->perl, 5; is eval "foo"->perl, "foo"; is eval( +(5*6)->perl ), 30; my $str = "bar"; is eval $str->perl, $str; my $num = 100.34; is eval $num->perl, $num; my $ref = \$num; is ${eval $ref->perl}, $$ref; #make sure non-printable charactrs can be seen is "\x{0A}"->perl, qq("\\n"\n); is "\x{00}"->perl, qq("\\0"\n); is "\x{7F}"->perl, qq("\\177"\n); #test passing of options is "\x{7F}"->perl([Useqq => 0]), "\$VAR1 = '\x{7F}';\n"; is "foo"->perl([Varname => "foo"], qw/Useqq/), qq(\$foo1 = "foo";\n); autobox-dump-20090426.1746/Makefile.PL0000444000175000017500000000070211175117571016341 0ustar cowenscowens# Note: this file was auto-generated by Module::Build::Compat version 0.30 use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'autobox::dump', 'VERSION_FROM' => 'lib/autobox/dump.pm', 'PREREQ_PM' => { 'Test::More' => 0, 'autobox' => 0 }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {} ) ; autobox-dump-20090426.1746/lib/0000755000175000017500000000000011175117571015140 5ustar cowenscowensautobox-dump-20090426.1746/lib/autobox/0000755000175000017500000000000011175117571016621 5ustar cowenscowensautobox-dump-20090426.1746/lib/autobox/dump.pm0000444000175000017500000000732311175117571020127 0ustar cowenscowenspackage autobox::dump; # vi: ht=4 sw=4 ts=4 et : use warnings; use strict; use base "autobox"; our $VERSION = '20090426.1746'; our @options = qw/Indent Terse Useqq Sortkeys Deparse/; sub options { #let them call it autobox::dump::options or autobox::dump->options shift @_ if $_[0] eq 'autobox::dump'; @options = @_; } sub import { my $class = shift; my $dumper = "autobox::dump::inner"; $class->SUPER::import( SCALAR => $dumper, ARRAY => $dumper, HASH => $dumper, CODE => $dumper, ); } { package autobox::dump::inner; sub perl { require Data::Dumper; #use Test::More; my $self = shift; my @options = @_ ? @_ : @autobox::dump::options; my $dumper = Data::Dumper->new([$self]); for my $option (@options) { my ($opt, @opt_args) = ref $option ? @$option : ($option, 1); $dumper->$opt(@opt_args) if $dumper->can($opt); } return $dumper->Dump; } } =head1 NAME autobox::dump - human/perl readable strings from the results of an EXPR =head1 VERSION Version 20090426.1746 =head1 SYNOPSIS The autobox::dump pragma adds, via the autobox pragma, a method to normal expression (such as scalars, arrays, hashes, math, literals, etc.) that produces a human/perl readable representation of the value of that expression. use autobox::dump; my $foo = "foo"; print $foo->perl; # "foo"; print +(5*6)->perl; # 30; my @a = (1..3); print @a->perl; # [ # 1, # 2, # 3 # ]; print {a=>1, b=>2}->perl; # { # "a" => 1, # "b" => 2 # }; sub func { my ($x, $y) = @_; return $x + $y; } my $func = \&func; print $func->perl; #sub { # BEGIN { # $^H{'autobox_scope'} = q(154456408); # $^H{'autobox'} = q(HASH(0x93a3e00)); # $^H{'autobox_leave'} = q(Scope::Guard=ARRAY(0x9435078)); # } # my($x, $y) = @_; # return $x + $y; #} You can set Data::Dumper options by passing either arrayrefs of option and value pairs or just keys (in which case the option will be set to 1). The default options are C. print ["a", 0, 1]->perl([Indent => 3], [Varname => "a"], qw/Useqq/); #$a1 = [ # #0 # "a", # #1 # 0, # #2 # 1 # ]; You can also call the class method ->options to set a different default. #set Indent to 0, but leave the rest of the options autobox::dump->options([Indent => 0], qw/Terse Useqq Sortkeys Deparse/); print ["a", 0, 1]->perl; #["a",0,1] =head1 AUTHOR Chas. J Owens IV, C<< >> =head1 BUGS Has all the issues L has. Has all the issues L has. This pragma errs on the side of human readable to the detriment of Perl readable. In particular it uses the terse and deparse options of Data::Dumper by default. These options may create code that cannot be eval'ed. For best eval results, set options to C. Note, this turns off coderef dumping. Please report any bugs or feature requests to http://github.com/cowens/autobox-dump/issues =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc autobox::dump =head1 ACKNOWLEDGEMENTS Michael Schwern for starting the perl5i pragma which prompted me to add a feature I wanted to autobox. =head1 COPYRIGHT & LICENSE Copyright 2009 Chas. J Owens IV, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of autobox::dump autobox-dump-20090426.1746/README0000444000175000017500000000201411175117571015245 0ustar cowenscowensautobox-dump autobox::dump pragma adds, via the autobox pragma, a method to normal expression (such as scalars, arrays, hashes, math, literals, etc.) that produces a human/perl readable representation of the value of that expression. use autobox::dump; my $foo = "foo"; print $foo->perl; #"foo"; print +(5*6)->perl; #30; my @a = (1..3); print @a->perl; #[ # 1, # 2, # 3 #]; print {a=>1, b=>2}->perl; #{ # "a" => 1, # "b" => 2 #}; INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install SUPPORT AND DOCUMENTATION Please report any bugs or feature requests to http://github.com/cowens/autobox-dump/issues After installing, you can find documentation for this module with the perldoc command. perldoc autobox::dump COPYRIGHT AND LICENCE Copyright (C) 2009 Chas. J Owens IV This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. autobox-dump-20090426.1746/META.yml0000444000175000017500000000104011175117571015634 0ustar cowenscowens--- name: autobox-dump version: 20090426.1746 author: - 'Chas. J Owens IV ' abstract: human/perl readable strings from the results of an EXPR license: perl resources: license: http://dev.perl.org/licenses/ build_requires: Test::More: 0 autobox: 0 provides: autobox::dump: file: lib/autobox/dump.pm version: 20090426.1746 autobox::dump::inner: file: lib/autobox/dump.pm generated_by: Module::Build version 0.3 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.2.html version: 1.2