Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package perl-Data-Printer for
openSUSE:Factory checked in at 2023-01-04 17:54:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Data-Printer (Old)
and /work/SRC/openSUSE:Factory/.perl-Data-Printer.new.1563 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Data-Printer"
Wed Jan 4 17:54:24 2023 rev:7 rq:1055917 version:1.001000
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Data-Printer/perl-Data-Printer.changes
2021-04-12 17:10:27.562571280 +0200
+++
/work/SRC/openSUSE:Factory/.perl-Data-Printer.new.1563/perl-Data-Printer.changes
2023-01-04 17:55:02.375043396 +0100
@@ -1,0 +2,28 @@
+Fri Dec 23 03:07:02 UTC 2022 - Tina Müller <[email protected]>
+
+- updated to 1.001000
+ see /usr/share/doc/packages/perl-Data-Printer/Changes
+
+ 1.1.0 2022-12-22
+ NEW FEATURES:
+ - new option 'coderef_stub' letting you customize what to show on
+ non-deparsed coderefs (default: 'sub { ... }')
+ - new option 'coderef_undefined' that checks if a given coderef
points
+ to an existing reference at the time of inspection. Defaults to
+ '<undefined coderef>'. Set to 0 to disable this check.
+ - basic Object::Pad support.
+ - new option class.show_wrapped to expose methods modified with
before,
+ after, around (Moose only for now)
+ - new option 'quiet' to avoid traversal and silence all output
+ from p() and np().
+ - new option 'live_update' to reload .dataprinter whenever
+ you make changes to it, applying them without needing to
+ restart your code.
+ BUG FIXES:
+ - properly shows inherited Moo(se) attributes.
+ - fix $@ clobbering when checking available modules.
+ - class.sort_methods also sorts attributes and roles.
+ - improved color reset.
+ - $DDP::VERSION is now hardcoded to avoid issues with PAUSE.
+
+-------------------------------------------------------------------
Old:
----
Data-Printer-1.000004.tar.gz
New:
----
Data-Printer-1.001000.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Data-Printer.spec ++++++
--- /var/tmp/diff_new_pack.SA5ydb/_old 2023-01-04 17:55:02.743045565 +0100
+++ /var/tmp/diff_new_pack.SA5ydb/_new 2023-01-04 17:55:02.751045612 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-Data-Printer
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,10 +18,10 @@
%define cpan_name Data-Printer
Name: perl-Data-Printer
-Version: 1.000004
+Version: 1.001000
Release: 0
-Summary: Colored & full-featured pretty print of Perl data structures
and objects
License: Artistic-1.0 OR GPL-1.0-or-later
+Summary: Colored & full-featured pretty print of Perl data structures
and objects
URL: https://metacpan.org/release/%{cpan_name}
Source0:
https://cpan.metacpan.org/authors/id/G/GA/GARU/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
++++++ Data-Printer-1.000004.tar.gz -> Data-Printer-1.001000.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/Changes
new/Data-Printer-1.001000/Changes
--- old/Data-Printer-1.000004/Changes 2021-03-03 23:27:02.000000000 +0100
+++ new/Data-Printer-1.001000/Changes 2022-12-22 05:11:53.559523306 +0100
@@ -1,5 +1,28 @@
Revision history for Data-Printer
+1.1.0 2022-12-22
+ NEW FEATURES:
+ - new option 'coderef_stub' letting you customize what to show on
+ non-deparsed coderefs (default: 'sub { ... }')
+ - new option 'coderef_undefined' that checks if a given coderef points
+ to an existing reference at the time of inspection. Defaults to
+ '<undefined coderef>'. Set to 0 to disable this check.
+ - basic Object::Pad support.
+ - new option class.show_wrapped to expose methods modified with before,
+ after, around (Moose only for now)
+ - new option 'quiet' to avoid traversal and silence all output
+ from p() and np().
+ - new option 'live_update' to reload .dataprinter whenever
+ you make changes to it, applying them without needing to
+ restart your code.
+ BUG FIXES:
+ - properly shows inherited Moo(se) attributes.
+ - fix $@ clobbering when checking available modules.
+ - class.sort_methods also sorts attributes and roles.
+ - improved color reset.
+ - $DDP::VERSION is now hardcoded to avoid issues with PAUSE.
+
+
1.0.4 2021-03-03
BUG FIXES:
- fix DBIx::Class print when literal SQL is present (Veesh Goldman)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/MANIFEST
new/Data-Printer-1.001000/MANIFEST
--- old/Data-Printer-1.000004/MANIFEST 2021-03-03 23:28:28.000000000 +0100
+++ new/Data-Printer-1.001000/MANIFEST 2022-12-22 05:15:36.000000000 +0100
@@ -51,6 +51,7 @@
t/011-class.t
t/011.1-attributes.t
t/011.2-roles.t
+t/011.3-object_pad.t
t/012-code.t
t/013-refcount.t
t/014-memsize.t
@@ -65,6 +66,7 @@
t/023-filters.t
t/024-tied.t
t/025-profiles.t
+t/026-caller_message.t
t/100-filter_datetime.t
t/101-filter_db.t
t/102-filter_digest.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/META.json
new/Data-Printer-1.001000/META.json
--- old/Data-Printer-1.000004/META.json 2021-03-03 23:28:28.000000000 +0100
+++ new/Data-Printer-1.001000/META.json 2022-12-22 05:15:36.000000000 +0100
@@ -4,7 +4,7 @@
"Breno G. de Oliveira <[email protected]>"
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter
version 2.150010",
+ "generated_by" : "ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter
version 2.150010",
"license" : [
"perl_5"
],
@@ -53,6 +53,6 @@
"url" : "https://github.com/garu/Data-Printer"
}
},
- "version" : "1.000004",
- "x_serialization_backend" : "JSON::PP version 4.06"
+ "version" : "1.001000",
+ "x_serialization_backend" : "JSON::PP version 4.07"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/META.yml
new/Data-Printer-1.001000/META.yml
--- old/Data-Printer-1.000004/META.yml 2021-03-03 23:28:27.000000000 +0100
+++ new/Data-Printer-1.001000/META.yml 2022-12-22 05:15:36.000000000 +0100
@@ -7,7 +7,7 @@
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version
2.150010'
+generated_by: 'ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version
2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -28,5 +28,5 @@
bugtracker: https://github.com/garu/Data-Printer/issues/
license: http://dev.perl.org/licenses/
repository: https://github.com/garu/Data-Printer
-version: '1.000004'
+version: '1.001000'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/lib/DDP.pm
new/Data-Printer-1.001000/lib/DDP.pm
--- old/Data-Printer-1.000004/lib/DDP.pm 2020-05-02 22:16:46.000000000
+0200
+++ new/Data-Printer-1.001000/lib/DDP.pm 2022-12-22 05:11:14.000000000
+0100
@@ -5,7 +5,8 @@
BEGIN {
push our @ISA, 'Data::Printer';
- our $VERSION = $Data::Printer::VERSION;
+ our $VERSION = '1.001000';
+ $VERSION = eval $VERSION;
}
1;
__END__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/lib/Data/Printer/Common.pm
new/Data-Printer-1.001000/lib/Data/Printer/Common.pm
--- old/Data-Printer-1.000004/lib/Data/Printer/Common.pm 2021-02-06
03:26:08.000000000 +0100
+++ new/Data-Printer-1.001000/lib/Data/Printer/Common.pm 2022-11-21
04:24:09.000000000 +0100
@@ -176,8 +176,8 @@
sub _initialize_nsort {
return 'Sort::Key::Natural' if $INC{'Sort/Key/Natural.pm'};
return 'Sort::Naturally' if $INC{'Sort/Naturally.pm'};
- return 'Sort::Key::Natural' if eval { require Sort::Key::Natural; 1; };
- return 'Sort::Naturally' if eval { require Sort::Naturally; 1; };
+ return 'Sort::Key::Natural' if !_tryme('use Sort::Key::Natural; 1;');
+ return 'Sort::Naturally' if !_tryme('use Sort::Naturally; 1;');
return 'core';
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Data-Printer-1.000004/lib/Data/Printer/Filter/CODE.pm
new/Data-Printer-1.001000/lib/Data/Printer/Filter/CODE.pm
--- old/Data-Printer-1.000004/lib/Data/Printer/Filter/CODE.pm 2021-01-30
04:03:25.000000000 +0100
+++ new/Data-Printer-1.001000/lib/Data/Printer/Filter/CODE.pm 2022-11-25
06:02:18.000000000 +0100
@@ -11,8 +11,23 @@
sub parse {
my ($subref, $ddp) = @_;
- my $string = $ddp->deparse ? _deparse($subref, $ddp) : 'sub { ... }';
- return $ddp->maybe_colorize($string, 'code');
+ my $string;
+ my $color = 'code';
+ if ($ddp->deparse) {
+ $string = _deparse($subref, $ddp);
+ if ($ddp->coderef_undefined && $string =~ /\A\s*sub\s*;\s*\z/) {
+ $string = $ddp->coderef_undefined;
+ $color = 'undef';
+ }
+ }
+ elsif ($ddp->coderef_undefined && !_subref_is_reachable($subref)) {
+ $string = $ddp->coderef_undefined;
+ $color = 'undef';
+ }
+ else {
+ $string = $ddp->coderef_stub;
+ }
+ return $ddp->maybe_colorize($string, $color);
};
#######################################
@@ -34,4 +49,11 @@
return $sub;
}
+sub _subref_is_reachable {
+ my ($subref) = @_;
+ require B;
+ my $cv = B::svref_2object($subref);
+ return !(B::class($cv->ROOT) eq 'NULL' && !${ $cv->const_sv });
+}
+
1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Data-Printer-1.000004/lib/Data/Printer/Filter/GenericClass.pm
new/Data-Printer-1.001000/lib/Data/Printer/Filter/GenericClass.pm
--- old/Data-Printer-1.000004/lib/Data/Printer/Filter/GenericClass.pm
2021-01-30 04:03:25.000000000 +0100
+++ new/Data-Printer-1.001000/lib/Data/Printer/Filter/GenericClass.pm
2022-12-22 05:01:43.000000000 +0100
@@ -60,8 +60,9 @@
if ($INC{'Role/Tiny.pm'} && exists
$Role::Tiny::APPLIED_TO{$class_name}) {
%roles = %{ $Role::Tiny::APPLIED_TO{$class_name} };
}
+ my $is_moose = 0;
- foreach my $parent (@superclasses) {
+ foreach my $parent (@$linear_ISA) {
if ($parent eq 'Moo::Object') {
Data::Printer::Common::_tryme(sub {
my $moo_maker = 'Moo'->_constructor_maker_for($class_name);
@@ -74,6 +75,7 @@
elsif ($parent eq 'Moose::Object') {
Data::Printer::Common::_tryme(sub {
my $class_meta = $class_name->meta;
+ $is_moose = 1;
%attributes = map {
$_->name => {
index => $_->insertion_order,
@@ -89,17 +91,33 @@
});
last;
}
+ elsif ($parent eq 'Object::Pad::UNIVERSAL') {
+ Data::Printer::Common::_tryme(sub {
+ my $meta = Object::Pad::MOP::Class->for_class( $class_name
);
+ %attributes = map {
+ $_->name . $_->value($class_name) => {
+ }
+ } $meta->fields;
+ %roles = map { $_->name => 1 } $meta->direct_roles;
+ });
+ }
}
- if (keys %roles) {
- $string .= $ddp->newline . 'roles (' . scalar(keys %roles) . '): '
- . join(', ' => map $ddp->maybe_colorize($_, 'class'), keys
%roles)
- ;
- }
+ if ($ddp->class->show_methods ne 'none') {
+ if (my @role_list = keys %roles) {
+ @role_list = Data::Printer::Common::_nsort(@role_list)
+ if @role_list && $ddp->class->sort_methods;
+ $string .= $ddp->newline . 'roles (' . scalar(@role_list) .
'): '
+ . join(', ' => map $ddp->maybe_colorize($_, 'class'),
@role_list)
+ ;
+ }
- if (keys %attributes) {
- $string .= $ddp->newline . 'attributes (' . scalar(keys
%attributes) . '): '
- . join(', ' => map $ddp->maybe_colorize($_, 'method'),
keys %attributes)
- ;
+ if (my @attr_list = keys %attributes) {
+ @attr_list = Data::Printer::Common::_nsort(@attr_list)
+ if @attr_list && $ddp->class->sort_methods;
+ $string .= $ddp->newline . 'attributes (' . scalar(@attr_list)
. '): '
+ . join(', ' => map $ddp->maybe_colorize($_, 'method'),
@attr_list)
+ ;
+ }
}
my $show_linear_isa = $ddp->class->linear_isa && (
@@ -113,8 +131,30 @@
;
}
- if ($ddp->class->show_methods && $ddp->class->show_methods ne 'none') {
+ if ($ddp->class->show_methods ne 'none') {
$string .= _show_methods($class_name, $linear_ISA, \%attributes,
$ddp);
+ if ($is_moose && $ddp->class->show_wrapped) {
+ my $modified = '';
+ my $modified_count = 0;
+ $ddp->indent;
+ for my $method ($class_name->meta->get_all_methods) {
+ if (ref $method eq 'Class::MOP::Method::Wrapped') {
+ foreach my $kind (qw(before around after)) {
+ my $getter_method = $kind . '_modifiers';
+ if (my @modlist = $method->$getter_method) {
+ $modified .= $ddp->newline . $kind . ' ' .
$method->name . ': '
+ . (@modlist > 1 ?
$ddp->parse(\@modlist) : $ddp->parse($modlist[0]));
+ $modified_count++;
+ }
+ }
+ }
+ }
+ $ddp->outdent;
+ if ($modified_count) {
+ $string .= $ddp->newline . 'method modifiers (' .
$modified_count . '):'
+ . $modified;
+ }
+ }
}
if ($ddp->class->show_overloads) {
@@ -139,6 +179,7 @@
if ($ddp->show_tied and my $tie = ref tied $object) {
$string .= " (tied to $tie)";
}
+
return $string;
};
@@ -226,7 +267,7 @@
if ($ddp->class->format_inheritance eq 'string') {
my @method_list = keys %{$methods{$type}};
@method_list = Data::Printer::Common::_nsort(@method_list)
- if $ddp->class->sort_methods && @method_list;
+ if @method_list && $ddp->class->sort_methods;
$string .= $ddp->newline . "$type methods (" .
scalar(@method_list) . ')';
if (@method_list) {
@@ -258,7 +299,7 @@
# then we print them, starting with our own methods:
@base_methods = Data::Printer::Common::_nsort(@base_methods)
- if $ddp->class->sort_methods && @base_methods;
+ if @base_methods && $ddp->class->sort_methods;
$string .= $ddp->newline . "$type methods ($total_methods)"
. ($total_methods ? ':' : '')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/lib/Data/Printer/Object.pm
new/Data-Printer-1.001000/lib/Data/Printer/Object.pm
--- old/Data-Printer-1.000004/lib/Data/Printer/Object.pm 2021-03-02
13:27:08.000000000 +0100
+++ new/Data-Printer-1.001000/lib/Data/Printer/Object.pm 2022-12-22
04:24:33.000000000 +0100
@@ -13,6 +13,7 @@
sub show_overloads { $_[0]->{'show_overloads'} }
sub show_methods { $_[0]->{'show_methods'} }
sub sort_methods { $_[0]->{'sort_methods'} }
+ sub show_wrapped { $_[0]->{'show_wrapped'} }
sub inherited { $_[0]->{'inherited'} }
sub format_inheritance { $_[0]->{'format_inheritance'} }
sub parent_filters { $_[0]->{'parent_filters'} }
@@ -37,6 +38,7 @@
'parent_filters' =>
Data::Printer::Common::_fetch_scalar_or_default($params, 'parent_filters', 1),
'universal' =>
Data::Printer::Common::_fetch_scalar_or_default($params, 'universal', 0),
'sort_methods' =>
Data::Printer::Common::_fetch_scalar_or_default($params, 'sort_methods', 1),
+ 'show_wrapped' =>
Data::Printer::Common::_fetch_scalar_or_default($params, 'show_wrapped', 1),
'internals' =>
Data::Printer::Common::_fetch_scalar_or_default($params, 'internals', 1),
'parents' =>
Data::Printer::Common::_fetch_scalar_or_default($params, 'parents', 1),
};
@@ -68,7 +70,7 @@
hash_preserve unicode_charnames colored theme show_weak
max_depth index separator end_separator class_method class hash_separator
align_hash sort_keys quote_keys deparse return_value show_dualvar show_tied
- warnings arrows
+ warnings arrows coderef_stub coderef_undefined
);
foreach my $method_name (@method_names) {
no strict 'refs';
@@ -206,6 +208,8 @@
$self->{'sort_keys'} =
Data::Printer::Common::_fetch_scalar_or_default($props, 'sort_keys', 1);
$self->{'quote_keys'} =
Data::Printer::Common::_fetch_scalar_or_default($props, 'quote_keys', 'auto');
$self->{'deparse'} =
Data::Printer::Common::_fetch_scalar_or_default($props, 'deparse', 0);
+ $self->{'coderef_stub'} =
Data::Printer::Common::_fetch_scalar_or_default($props, 'coderef_stub', 'sub {
... }');
+ $self->{'coderef_undefined'} =
Data::Printer::Common::_fetch_scalar_or_default($props, 'coderef_undefined',
'<undefined coderef>');
$self->{'return_value'} = Data::Printer::Common::_fetch_anyof(
$props,
'return_value',
@@ -572,7 +576,7 @@
# this funcionallity separated, but refcounts increase as we find
# them again and because of that we were seeing weird refcounting.
# So now instead we store the refcount of the variable when we
-# first saw it.
+# first see it.
# Finally, if we have already seen the data, we return its stringified
# position, like "var", "var{foo}[7]", etc. UNLESS $options{seen_override}
# is set. Why seen_override? Sometimes we want to print the same data
@@ -679,10 +683,13 @@
}
}
+ # FIXME: because of prototypes, p(@data) becomes a ref (that we don't care
about)
+ # to the data (that we do care about). So we should not show refcounts,
memsize
+ # or readonly status for something guaranteed to be ephemeral.
$parsed_string .= $self->_check_readonly($data);
$parsed_string .= $str_weak if ref($data) ne 'REF';
-
$parsed_string .= $self->_check_memsize($data);
+
if ($self->show_refcount && ref($data) ne 'SCALAR' && $seen->{refcount} >
1 ) {
$parsed_string .= ' (refcount: ' . $seen->{refcount} .')';
}
@@ -1041,9 +1048,23 @@
=head3 deparse
-If the data structure contains a subroutine reference, this options can be
-set to deparse it and print the underlying code, which hopefully resembles
-the original source code. (default: 0)
+If the data structure contains a subroutine reference (coderef), this option
+can be set to deparse it and print the underlying code, which hopefully
+resembles the original source code. (default: 0)
+
+=head3 coderef_stub
+
+If the data structure contains a subroutine reference (coderef) and the
+'L<deparse|/deparse>' option above is set to false, Data::Printer will print
this
+instead. (default: 'C<< sub { ... } >>')
+
+=head3 coderef_undefined
+
+If the data structure contains a subroutine reference (coderef) that has
+not actually been defined at the time of inspection, Data::Printer will
+print this instead. Set it to '0' to disable this check, in which case
+Data::Printer will use whatever value you set on
+L<coderef_stub|/coderef_stub> above. (default: '<undefined coderef>').
=head3 end_separator
@@ -1251,12 +1272,14 @@
=head4 show_methods
Controls which of the object's direct methods to show. Can be set to 'none',
-'all', 'private' or 'public'. (default: 'all')
+'all', 'private' or 'public'. When applicable (Moo, Moose) it will also
+show attributes and roles. (default: 'all')
=head4 sort_methods
-When listing methods, this option will order them alphabetically, rather than
-on whatever order the list of methods returned. (default: 1)
+When listing methods, attributes and roles, this option will order them
+alphabetically, rather than on whatever order the list of methods returned.
+(default: 1)
=head4 inherited
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/lib/Data/Printer/Theme.pm
new/Data-Printer-1.001000/lib/Data/Printer/Theme.pm
--- old/Data-Printer-1.000004/lib/Data/Printer/Theme.pm 2021-02-24
04:34:52.000000000 +0100
+++ new/Data-Printer-1.001000/lib/Data/Printer/Theme.pm 2022-11-22
04:24:48.000000000 +0100
@@ -29,7 +29,7 @@
}
# prints the SGR (terminal) color reset modifier
-sub color_reset { return "\e[0m" }
+sub color_reset { return "\e[m" }
sub new {
my ($class, %params) = @_;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/lib/Data/Printer.pm
new/Data-Printer-1.001000/lib/Data/Printer.pm
--- old/Data-Printer-1.000004/lib/Data/Printer.pm 2021-03-03
23:27:47.000000000 +0100
+++ new/Data-Printer-1.001000/lib/Data/Printer.pm 2022-12-22
05:11:31.000000000 +0100
@@ -5,7 +5,7 @@
use Data::Printer::Common;
use Data::Printer::Config;
-our $VERSION = '1.000004';
+our $VERSION = '1.001000';
$VERSION = eval $VERSION;
my $rc_arguments;
@@ -45,7 +45,34 @@
sub _initialize {
# potential race but worst case is we read it twice :)
{ no warnings 'redefine'; *_initialize = sub {} }
- $rc_arguments = Data::Printer::Config::load_rc_file();
+
+ my $rc_filename = Data::Printer::Config::_get_first_rc_file_available();
+ $rc_arguments = Data::Printer::Config::load_rc_file($rc_filename);
+
+ if (
+ exists $rc_arguments->{'_'}{live_update}
+ && defined $rc_arguments->{'_'}{live_update}
+ && $rc_arguments->{'_'}{live_update} =~ /\A\d+\z/
+ && $rc_arguments->{'_'}{live_update} > 0) {
+ my $now = time;
+ my $last_mod = (stat $rc_filename)[9];
+ {
+ no warnings 'redefine';
+ *_initialize = sub {
+ if (time - $now > $rc_arguments->{'_'}{live_update}) {
+ my $new_last_mod = (stat $rc_filename)[9];
+ if (defined $new_last_mod && $new_last_mod > $last_mod) {
+ $now = time;
+ $last_mod = $new_last_mod;
+ $rc_arguments =
Data::Printer::Config::load_rc_file($rc_filename);
+ if (!exists $rc_arguments->{'_'}{live_update} ||
!$rc_arguments->{'_'}{live_update}) {
+ *_initialize = sub {};
+ }
+ }
+ }
+ };
+ }
+ }
}
sub np (\[@$%&];%) {
@@ -55,6 +82,7 @@
my $caller = caller;
my $args_to_use = _fetch_args_with($caller, \%properties);
+ return '' if $args_to_use->{quiet};
my $printer = Data::Printer::Object->new($args_to_use);
# force color level 0 on 'auto' colors:
@@ -84,6 +112,7 @@
my $caller = caller;
my $args_to_use = _fetch_args_with($caller, \%properties);
+ return if $args_to_use->{quiet};
my $printer = Data::Printer::Object->new($args_to_use);
my $want_value = defined wantarray;
if ($printer->colored eq 'auto' && $printer->return_value eq 'dump' &&
$want_value) {
@@ -122,6 +151,7 @@
my $caller = caller;
my $args_to_use = _fetch_args_with($caller, \%properties);
+ return if $args_to_use->{quiet};
my $printer = Data::Printer::Object->new($args_to_use);
my $want_value = defined wantarray;
@@ -255,17 +285,16 @@
p @array;
p %hash;
- # for anonymous array/hash references, use postderef (on perl 5.24 or
later):
- p [ $one, $two, $three ]->@*;
- p { foo => $foo, bar => $bar }->%*;
-
- # or deref the anonymous ref:
- p @{[ $one, $two, $three ]};
- p %{{ foo => $foo, bar => $bar }};
-
- # or put '&' in front of the call:
- &p( [ $one, $two, $three ] );
- &p( { foo => $foo, bar => $bar } );
+ # printing anonymous array references:
+ p [ $one, $two, $three ]->@*; # perl 5.24 or later!
+ p @{[ $one, $two, $three ]}; # same, older perls
+ &p( [ $one, $two, $three ] ); # same, older perls
+
+ # printing anonymous hash references:
+ p { foo => $foo, bar => $bar }->%*; # perl 5.24 or later!
+ p %{{ foo => $foo, bar => $bar }}; # same, older perls
+ &p( { foo => $foo, bar => $bar } ); # same, older perls
+
The snippets above will print the contents of the chosen variables to STDERR
on your terminal, with colors and a few extra features to help you debug
@@ -284,7 +313,7 @@
That's pretty much it :)
-=for html <img alt="Data::Printer in action"
src="https://raw.githubusercontent.com/garu/Data-Printer/master/examples/ddp.gif"
/>
+=for html <img alt="samples of Data::Printer output for several kinds of data
and objects"
src="https://raw.githubusercontent.com/garu/Data-Printer/master/examples/ddp.gif"
/>
Data::Printer is L<fully customizable|/Properties Quick Reference>, even
on a per-module basis! Once you figure out your own preferences, create a
@@ -508,11 +537,25 @@
multiline = 0
output = /var/log/myapp/debug.data
+ # use 'quiet' to silence all output from p() and np()
+ # called from the specified package.
+ [MyApp::Yet::Another]
+ quiet = 1
+
Note that if you set custom properties as arguments to C<p()> or C<np()>, you
should group suboptions as a hashref. So while the C<.dataprinter> file has
"C<< class.expand = 0 >>" and "C<< class.inherited = none >>", the equivalent
code is "C<< class => { expand => 0, inherited => 'none' } >>".
+=head3 live updating your .dataprinter without restarts
+
+Data::Printer 1.1 introduces a new 'live_update' flag that can be set to a
+positive integer to enable live updates. When this mode is on, Data::Printer
+will check if the C<.dataprinter> file has been updated and, if so, it will
+reload it. This way you can toggle features on and off and control output
+verbosity directly from your C<.dataprinter> file without needing to change
+or restart running code.
+
=head2 Properties Quick Reference
Below are (almost) all available properties and their (hopefully sane)
@@ -610,6 +653,11 @@
values. Use this to generate complete (full) dumps of all your content,
which is trimmed by default.
+=item * B<quiet> - when set to 1, disables all data parsing and returns as
+quickly as possible. Use this to disable all output from C<p()> and C<np()>
+inside a particular package, either from the 'use' call or from .dataprinter.
+(introduced in version 1.1)
+
=back
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/t/001-object.t
new/Data-Printer-1.001000/t/001-object.t
--- old/Data-Printer-1.000004/t/001-object.t 2021-02-16 19:58:24.000000000
+0100
+++ new/Data-Printer-1.001000/t/001-object.t 2022-11-30 03:39:23.000000000
+0100
@@ -162,7 +162,7 @@
is $ddp->maybe_colorize('x'), 'x', 'no color unless tag is provided';
is $ddp->maybe_colorize('x', 'invalid tag'), 'x', 'no color unless valid
tag';
my $colored = $ddp->maybe_colorize('x', 'invalid tag', "\e[0;38;2m");
- if ($colored eq "\e[0;38;2mx\e[0m") {
+ if ($colored eq "\e[0;38;2mx\e[m") {
pass 'fallback to default color';
}
else {
@@ -171,7 +171,7 @@
my $parsed = $ddp->theme->_parse_color("\e[0;38;2m");
$parsed =~ s{\e}{\\e}gsm if defined $parsed;
fail 'fallback to default color:'
- . ' got "' . $colored . '" expected "\e[0;38;2mx\e[0m"'
+ . ' got "' . $colored . '" expected "\e[0;38;2mx\e[m"'
. ' theme name: ' . $ddp->theme->name
. ' color level: ' . $ddp->{_output_color_level}
. ' sgr_color_for "invalid tag": '
@@ -195,7 +195,7 @@
my $parsed = $ddp->theme->_parse_color("\e[0;38;2m");
$parsed =~ s{\e}{\\e}gsm if defined $parsed;
fail 'fallback to default color:'
- . ' got "' . $colored . '" expected "\e[0;38;2mx\e[0m"'
+ . ' got "' . $colored . '" expected "\e[0;38;2mx\e[m"'
. ' theme name: ' . $ddp->theme->name
. ' color level: ' . $ddp->{_output_color_level}
. ' sgr_color_for "invalid tag": '
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/t/011.3-object_pad.t
new/Data-Printer-1.001000/t/011.3-object_pad.t
--- old/Data-Printer-1.000004/t/011.3-object_pad.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Data-Printer-1.001000/t/011.3-object_pad.t 2022-12-22
05:07:26.000000000 +0100
@@ -0,0 +1,38 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+use Data::Printer::Common;
+use Data::Printer::Object;
+
+test_object_pad();
+exit;
+
+sub test_object_pad {
+ SKIP: {
+ my $error = Data::Printer::Common::_tryme(
+ 'use Object::Pad 0.60; class TestClass { has $x :param = 42;
method one($dX) { } method two { } }'
+ );
+ skip 'Object::Pad 0.60+ not found', 1 if $error;
+
+ my $ddp = Data::Printer::Object->new( colored => 0, class => {
show_reftype => 1 } );
+ my $obj = TestClass->new( x => 666 );
+ my $parsed = $ddp->parse($obj);
+ is(
+ $parsed,
+ 'TestClass (ARRAY) {
+ parents: Object::Pad::UNIVERSAL
+ public methods (6):
+ DOES, META, new, one, two
+ Object::Pad::UNIVERSAL:
+ BUILDARGS
+ private methods (0)
+ internals: [
+ [0] 666
+ ]
+}',
+ 'parsed Object::Pad class'
+ );
+ };
+}
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/t/026-caller_message.t
new/Data-Printer-1.001000/t/026-caller_message.t
--- old/Data-Printer-1.000004/t/026-caller_message.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Data-Printer-1.001000/t/026-caller_message.t 2021-03-09
02:38:08.000000000 +0100
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+BEGIN {
+ use Data::Printer::Config;
+ no warnings 'redefine';
+ *Data::Printer::Config::load_rc_file = sub { {} };
+};
+
+use Data::Printer
+ colored => 0,
+ caller_info => 1,
+ return_value => 'dump',
+ caller_message_newline => 0,
+ caller_message_position => 'before';
+
+my $x;
+my $got = p $x;
+is(
+ $got,
+ 'Printing in line 19 of t/026-caller_message.t: undef',
+ 'caller_info shows the proper caller message (after)'
+);
+
+$got = p $x, caller_message_position => 'after';
+is(
+ $got,
+ 'undef Printing in line 26 of t/026-caller_message.t:',
+ 'caller_info shows the proper caller message (before)'
+);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Data-Printer-1.000004/t/998-color.t
new/Data-Printer-1.001000/t/998-color.t
--- old/Data-Printer-1.000004/t/998-color.t 2021-03-03 03:07:21.000000000
+0100
+++ new/Data-Printer-1.001000/t/998-color.t 2022-11-22 18:32:43.000000000
+0100
@@ -46,30 +46,30 @@
push @{$data->{arrayref}}, $data->{arrayref}[0];
my $got = $ddp->parse(\$data);
-my $expected = qq|\e[0;38;2;102;217;239m{\e[0m
- \e[0;38;2;121;134;203marrayref\e[0m\e[0;38;2;102;217;239m
\e[0m\e[0;38;2;102;217;239m[\e[0m
- \e[0;38;2;161;187;197m[0] \e[0m\e[0;38;2;102;217;239m[\e[0m
- \e[0;38;2;161;187;197m[0] \e[0m\e[0;38;2;247;140;106m10\e[0m
- \e[0;38;2;102;217;239m]\e[0m (refcount:
2)\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;161;187;197m[1]
\e[0m\e[0;38;2;199;146;234mDDPTestObject\e[0m
\e[0;38;2;102;217;239m(\e[0m\e[0;38;2;199;146;234mHASH\e[0m\e[0;38;2;102;217;239m)\e[0m
\e[0;38;2;102;217;239m{\e[0m
- public methods (1): \e[0;38;2;130;170;255mnew\e[0m
+my $expected = qq|\e[0;38;2;102;217;239m{\e[m
+ \e[0;38;2;121;134;203marrayref\e[m\e[0;38;2;102;217;239m
\e[m\e[0;38;2;102;217;239m[\e[m
+ \e[0;38;2;161;187;197m[0] \e[m\e[0;38;2;102;217;239m[\e[m
+ \e[0;38;2;161;187;197m[0] \e[m\e[0;38;2;247;140;106m10\e[m
+ \e[0;38;2;102;217;239m]\e[m (refcount:
2)\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;161;187;197m[1] \e[m\e[0;38;2;199;146;234mDDPTestObject\e[m
\e[0;38;2;102;217;239m(\e[m\e[0;38;2;199;146;234mHASH\e[m\e[0;38;2;102;217;239m)\e[m
\e[0;38;2;102;217;239m{\e[m
+ public methods (1): \e[0;38;2;130;170;255mnew\e[m
private methods (0)
- internals: \e[0;38;2;102;217;239m{}\e[0m
- \e[0;38;2;102;217;239m}\e[0m\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;161;187;197m[2]
\e[0m\e[0;38;2;240;113;120mvar{arrayref}[0]\e[0m
- \e[0;38;2;102;217;239m]\e[0m\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203mhashref\e[0m \e[0;38;2;102;217;239m
\e[0m\e[0;38;2;102;217;239m{\e[0m
- \e[0;38;2;121;134;203mlvalue\e[0m
\e[0;38;2;102;217;239m
\e[0m\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;144;181;90mc\e[0m\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;247;140;106m
(LVALUE)\e[0m| . (q{ (refcount: 2)}x!!($] < 5.014000)) .
qq|\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203mnumber\e[0m
\e[0;38;2;102;217;239m
\e[0m\e[0;38;2;247;140;106m3.14\e[0m\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203mref\e[0m
\e[0;38;2;102;217;239m \e[0m\\ \e[0;38;2;247;140;106m42\e[0m
(read-only)\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203mregex\e[0m
\e[0;38;2;102;217;239m \e[0m\e[0;38;2;255;203;107m(?:\\s+)\$\e[0m
(modifiers: ix)| . (q{ (refcount: 2)}x!!($] =~ /5.01100[12]/)) .
qq|\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203mspecial\e[0m
\e[0;38;2;102;217;239m
\e[0m\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;144;181;90mone\e[0;38;2;0;150;136m\\t\e[0;38;2;144;181;90m\e[0;38;2;0;150;136m\\x{2603}\e[0;38;2;144;181;90mtwo\e[0;38;2;0;150;136m\\0\e[0;38;2;144;181;90m\e[0;38;2;0;150;136m\\n\e[0;38;2;144;181;90m\e[0;38;2;0;150;136m\\e\e[0;38;2;144;181;90m[0m\e[0;38;2;0;150;136m\\x{2603}\e[0;38;2;144;181;90mBBBBBBBBBBBBBBB\e[0;38;2;79;90;97m(...skipping
85
chars...)\e[0;38;2;144;181;90m\e[0m\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203mstring\e[0m
\e[0;38;2;102;217;239m
\e[0m\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;144;181;90mthis is a
string\e[0m\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203msub\e[0m
\e[0;38;2;102;217;239m \e[0m\e[0;38;2;79;90;97msub { ... }\e[0m (refcount:
2)\e[0;38;2;102;217;239m,\e[0m
- \e[0;38;2;121;134;203mundef\e[0m
\e[0;38;2;102;217;239m
\e[0m\e[0;38;2;255;83;112mundef\e[0m\e[0;38;2;102;217;239m,\e[0m
-
\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;121;134;203mwe\e[0;38;2;0;150;136m\\e\e[0;38;2;121;134;203m[0mird\e[0;38;2;0;150;136m\\0\e[0;38;2;121;134;203mkey\e[0;38;2;0;150;136m\\x{2603}\e[0;38;2;121;134;203m!\e[0m\e[0;38;2;102;217;239m"\e[0m\e[0;38;2;102;217;239m
\e[0m\e[0;38;2;247;140;106m1\e[0m
- \e[0;38;2;102;217;239m}\e[0m
-\e[0;38;2;102;217;239m}\e[0m|;
+ internals: \e[0;38;2;102;217;239m{}\e[m
+ \e[0;38;2;102;217;239m}\e[m\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;161;187;197m[2]
\e[m\e[0;38;2;240;113;120mvar{arrayref}[0]\e[m
+ \e[0;38;2;102;217;239m]\e[m\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203mhashref\e[m \e[0;38;2;102;217;239m
\e[m\e[0;38;2;102;217;239m{\e[m
+ \e[0;38;2;121;134;203mlvalue\e[m
\e[0;38;2;102;217;239m
\e[m\e[0;38;2;102;217;239m"\e[m\e[0;38;2;144;181;90mc\e[m\e[0;38;2;102;217;239m"\e[m\e[0;38;2;247;140;106m
(LVALUE)\e[m| . (q{ (refcount: 2)}x!!($] < 5.014000)) .
qq|\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203mnumber\e[m
\e[0;38;2;102;217;239m
\e[m\e[0;38;2;247;140;106m3.14\e[m\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203mref\e[m
\e[0;38;2;102;217;239m \e[m\\ \e[0;38;2;247;140;106m42\e[m
(read-only)\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203mregex\e[m
\e[0;38;2;102;217;239m \e[m\e[0;38;2;255;203;107m(?:\\s+)\$\e[m (modifiers:
ix)| . (q{ (refcount: 2)}x!!($] =~ /5.01100[12]/)) .
qq|\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203mspecial\e[m
\e[0;38;2;102;217;239m
\e[m\e[0;38;2;102;217;239m"\e[m\e[0;38;2;144;181;90mone\e[0;38;2;0;150;136m\\t\e[0;38;2;144;181;90m\e[0;38;2;0;150;136m\\x{2603}\e[0;38;2;144;181;90mtwo\e[0;38;2;0;150;136m\\0\e[0;38;2;144;181;90m\e[0;38;2;0;150;136m\\n\e[0;38;2;144;181;90m\e[0;38;2;0;150;136m\\e\e[0;38;2;144;181;90m[0m\e[0;38;2;0;150;136m\\x{2603}\e[0;38;2;144;181;90mBBBBBBBBBBBBBBB\e[0;38;2;79;90;97m(...skipping
85
chars...)\e[0;38;2;144;181;90m\e[m\e[0;38;2;102;217;239m"\e[m\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203mstring\e[m
\e[0;38;2;102;217;239m
\e[m\e[0;38;2;102;217;239m"\e[m\e[0;38;2;144;181;90mthis is a
string\e[m\e[0;38;2;102;217;239m"\e[m\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203msub\e[m
\e[0;38;2;102;217;239m \e[m\e[0;38;2;79;90;97msub { ... }\e[m (refcount:
2)\e[0;38;2;102;217;239m,\e[m
+ \e[0;38;2;121;134;203mundef\e[m
\e[0;38;2;102;217;239m
\e[m\e[0;38;2;255;83;112mundef\e[m\e[0;38;2;102;217;239m,\e[m
+
\e[0;38;2;102;217;239m"\e[m\e[0;38;2;121;134;203mwe\e[0;38;2;0;150;136m\\e\e[0;38;2;121;134;203m[0mird\e[0;38;2;0;150;136m\\0\e[0;38;2;121;134;203mkey\e[0;38;2;0;150;136m\\x{2603}\e[0;38;2;121;134;203m!\e[m\e[0;38;2;102;217;239m"\e[m\e[0;38;2;102;217;239m
\e[m\e[0;38;2;247;140;106m1\e[m
+ \e[0;38;2;102;217;239m}\e[m
+\e[0;38;2;102;217;239m}\e[m|;
is($got, $expected, 'colored output');
if ($got ne $expected) {