Data-Dumper-Compact

 view release on metacpan or  search on metacpan

lib/Data/Dumper/Compact.pm  view on Meta::CPAN

                },
              },
            ],
          },
        },
      },
    ],
    set => {
      path => {
        -ident => [
          'tree',
          'path',
        ],
      },
    },
  }

=head2 Summary

Hopefully it's clear what the goal is, and what we've done to achieve it.

While the system is already somewhat configurable, further options are almost
certainly implementable, although if you really want such an option then we
expect you to turn up with documentation and test cases for it so we just
have to write the code.

=head1 OPTIONS

=head2 max_width

Represents the width that DDC will attempt to keep as the maximum (if
something overflows it in spite of our best efforts, DDC will fall back to
a more vertically sprawling format to at least overflow as little as
feasible).

Default: C<78>

=head2 indent_by

The string to indent by. To set e.g. 4 space indent, pass C<' 'x4>.

Default: C<'  '> (two spaces).

=head2 indent_width

How many characters one indent should be considered to be. Generally you
only need to manually set this if your L</indent_by> is C<"\t">.

Default: C<< length($self->indent_by) >>

=head2 transforms

Set of transforms to apply on every L</dump> operation. See L</transform>
for more information.

Default: C<[]>

=head2 dumper

The dumper function to be used for dumping things DDC doesn't understand,
such as coderefs, regexprefs, etc.

Defaults to the same options as L<Data::Dumper::Concise> (which is, itself,
only a L<Data::Dumper> configuration albeit it comes with L<Devel::Dwarn>
which is rather more interesting) - although on top of that we add a little
bit of extra cleverness to make L<B::Deparse> use the correct indentation,
since for some reason L<Data::Dumper> doesn't (at the time of writing) do
that.

If you supply it yourself, it needs to be a single argument coderef - you
could for example use C<\&Data::Dumper::Dumper> though that would almost
certainly be pointless.

=head1 EXPORTS

=head2 ddc

  use Data::Dumper::Compact 'ddc';
  use Data::Dumper::Compact 'ddc' => \%options;

If the first argument to C<use>/C<import()> is 'ddc', a subroutine C<ddc()>
is installed in the calling package which behaves like calling L</dump>.

If the second argument is a hashref, it becomes the options passed to L</new>.

This feature is effectively sugar over L</dump_cb>, in that:

  Data::Dumper::Compact->import(ddc => \%options)

is equivalent to:

  *ddc = Data::Dumper::Compact->new(\%options)->dump_cb;

=head1 METHODS

=head2 new

  my $ddc = Data::Dumper::Compact->new;
  my $ddc = Data::Dumper::Compact->new(%options);
  my $ddc = Data::Dumper::Compact->new(\%options);

Constructor. Takes a hash or hashref of L</OPTIONS>

=head2 dump

  my $formatted = Data::Dumper::Compact->dump($data, \%options?);
  
  my $formatted = $ddc->dump($data, \%merge_options?);

This is the method you're going to want to call most of the time, and ties
together the rest of the functionality into a single data-structure-to-string
bundle. With just a data argument, it's equivalent to:

  $ddc->format( $ddc->transform( $ddc->transforms, $ddc->expand($data) );

In class method form, options provided are passed to L</new>; in instance
method form, options if provided are merged into C<$ddc> just for this
invocation.

=head2 dump_cb



( run in 1.410 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )