Hello community,
here is the log from the commit of package perl-Struct-Dumb for
openSUSE:Factory checked in at 2020-04-21 13:05:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Struct-Dumb (Old)
and /work/SRC/openSUSE:Factory/.perl-Struct-Dumb.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Struct-Dumb"
Tue Apr 21 13:05:27 2020 rev:5 rq:795269 version:0.11
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Struct-Dumb/perl-Struct-Dumb.changes
2016-03-17 16:47:40.000000000 +0100
+++
/work/SRC/openSUSE:Factory/.perl-Struct-Dumb.new.2738/perl-Struct-Dumb.changes
2020-04-21 13:05:29.724193384 +0200
@@ -1,0 +2,15 @@
+Fri Apr 17 03:10:41 UTC 2020 - <[email protected]>
+
+- updated to 0.11
+ see /usr/share/doc/packages/perl-Struct-Dumb/Changes
+
+ 0.11 2020-04-17
+ [BUGFIXES]
+ * Fix for detecting Data::Dump being loaded afterward Struct::Dumb
+
+ 0.10 2020-04-17
+ [CHANGES]
+ * Optional named parameter versions of constructor functions
+ * Apply hackery to Data::Dump to allow it to print structures
+
+-------------------------------------------------------------------
Old:
----
Struct-Dumb-0.09.tar.gz
New:
----
Struct-Dumb-0.11.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Struct-Dumb.spec ++++++
--- /var/tmp/diff_new_pack.PEjHMi/_old 2020-04-21 13:05:30.760195451 +0200
+++ /var/tmp/diff_new_pack.PEjHMi/_new 2020-04-21 13:05:30.764195458 +0200
@@ -1,7 +1,7 @@
#
# spec file for package perl-Struct-Dumb
#
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,24 +12,25 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: perl-Struct-Dumb
-Version: 0.09
+Version: 0.11
Release: 0
%define cpan_name Struct-Dumb
-Summary: Make Simple Lightweight Record-Like Structures
-License: Artistic-1.0 or GPL-1.0+
+Summary: Make simple lightweight record-like structures
+License: Artistic-1.0 OR GPL-1.0-or-later
Group: Development/Libraries/Perl
-Url: http://search.cpan.org/dist/Struct-Dumb/
-Source0:
http://www.cpan.org/authors/id/P/PE/PEVANS/%{cpan_name}-%{version}.tar.gz
+Url: https://metacpan.org/release/%{cpan_name}
+Source0:
https://cpan.metacpan.org/authors/id/P/PE/PEVANS/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
+BuildRequires: perl(Data::Dump)
BuildRequires: perl(Module::Build) >= 0.400400
BuildRequires: perl(Test::Fatal)
BuildRequires: perl(Test::More) >= 0.88
@@ -76,7 +77,7 @@
%setup -q -n %{cpan_name}-%{version}
%build
-%{__perl} Build.PL installdirs=vendor
+perl Build.PL installdirs=vendor
./Build build flags=%{?_smp_mflags}
%check
@@ -88,6 +89,7 @@
%files -f %{name}.files
%defattr(-,root,root,755)
-%doc Changes LICENSE README
+%doc Changes README
+%license LICENSE
%changelog
++++++ Struct-Dumb-0.09.tar.gz -> Struct-Dumb-0.11.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/Build.PL
new/Struct-Dumb-0.11/Build.PL
--- old/Struct-Dumb-0.09/Build.PL 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/Build.PL 2020-04-17 02:24:18.000000000 +0200
@@ -6,6 +6,7 @@
my $build = Module::Build->new(
module_name => 'Struct::Dumb',
test_requires => {
+ 'Data::Dump' => 0,
'Test::Fatal' => 0,
'Test::More' => '0.88', # done_testing
},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/Changes new/Struct-Dumb-0.11/Changes
--- old/Struct-Dumb-0.09/Changes 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/Changes 2020-04-17 02:24:18.000000000 +0200
@@ -1,5 +1,14 @@
Revision history for Struct-Dumb
+0.11 2020-04-17
+ [BUGFIXES]
+ * Fix for detecting Data::Dump being loaded afterward Struct::Dumb
+
+0.10 2020-04-17
+ [CHANGES]
+ * Optional named parameter versions of constructor functions
+ * Apply hackery to Data::Dump to allow it to print structures
+
0.09 2016/03/09 17:49:17
[CHANGES]
* Allow callers to allow ARRAY dereference for special circumstances
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/LICENSE new/Struct-Dumb-0.11/LICENSE
--- old/Struct-Dumb-0.09/LICENSE 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/LICENSE 2020-04-17 02:24:18.000000000 +0200
@@ -1,4 +1,4 @@
-This software is copyright (c) 2016 by Paul Evans <[email protected]>.
+This software is copyright (c) 2020 by Paul Evans <[email protected]>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -12,7 +12,7 @@
--- The GNU General Public License, Version 1, February 1989 ---
-This software is Copyright (c) 2016 by Paul Evans <[email protected]>.
+This software is Copyright (c) 2020 by Paul Evans <[email protected]>.
This is free software, licensed under:
@@ -272,7 +272,7 @@
--- The Artistic License 1.0 ---
-This software is Copyright (c) 2016 by Paul Evans <[email protected]>.
+This software is Copyright (c) 2020 by Paul Evans <[email protected]>.
This is free software, licensed under:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/MANIFEST
new/Struct-Dumb-0.11/MANIFEST
--- old/Struct-Dumb-0.09/MANIFEST 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/MANIFEST 2020-04-17 02:24:18.000000000 +0200
@@ -13,4 +13,6 @@
t/03readonly.t
t/04named.t
t/05predicate.t
+t/10data-dump.t
+t/11data-dump-late.t
t/99pod.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/META.json
new/Struct-Dumb-0.11/META.json
--- old/Struct-Dumb-0.09/META.json 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/META.json 2020-04-17 02:24:18.000000000 +0200
@@ -4,13 +4,13 @@
"Paul Evans <[email protected]>"
],
"dynamic_config" : 1,
- "generated_by" : "Module::Build version 0.4214",
+ "generated_by" : "Module::Build version 0.4224",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
- "version" : "2"
+ "version" : 2
},
"name" : "Struct-Dumb",
"prereqs" : {
@@ -21,6 +21,7 @@
},
"test" : {
"requires" : {
+ "Data::Dump" : "0",
"Test::Fatal" : "0",
"Test::More" : "0.88"
}
@@ -29,7 +30,7 @@
"provides" : {
"Struct::Dumb" : {
"file" : "lib/Struct/Dumb.pm",
- "version" : "0.09"
+ "version" : "0.11"
}
},
"release_status" : "stable",
@@ -38,6 +39,6 @@
"http://dev.perl.org/licenses/"
]
},
- "version" : "0.09",
- "x_serialization_backend" : "JSON::PP version 2.27300"
+ "version" : "0.11",
+ "x_serialization_backend" : "JSON::PP version 4.04"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/META.yml
new/Struct-Dumb-0.11/META.yml
--- old/Struct-Dumb-0.09/META.yml 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/META.yml 2020-04-17 02:24:18.000000000 +0200
@@ -3,12 +3,13 @@
author:
- 'Paul Evans <[email protected]>'
build_requires:
+ Data::Dump: '0'
Test::Fatal: '0'
Test::More: '0.88'
configure_requires:
Module::Build: '0.4004'
dynamic_config: 1
-generated_by: 'Module::Build version 0.4214, CPAN::Meta::Converter version
2.150005'
+generated_by: 'Module::Build version 0.4224, CPAN::Meta::Converter version
2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -17,8 +18,8 @@
provides:
Struct::Dumb:
file: lib/Struct/Dumb.pm
- version: '0.09'
+ version: '0.11'
resources:
license: http://dev.perl.org/licenses/
-version: '0.09'
+version: '0.11'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/Makefile.PL
new/Struct-Dumb-0.11/Makefile.PL
--- old/Struct-Dumb-0.09/Makefile.PL 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/Makefile.PL 2020-04-17 02:24:18.000000000 +0200
@@ -1,4 +1,4 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.4214
+# Note: this file was auto-generated by Module::Build::Compat version 0.4224
use ExtUtils::MakeMaker;
WriteMakefile
(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/README new/Struct-Dumb-0.11/README
--- old/Struct-Dumb-0.09/README 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/README 2020-04-17 02:24:18.000000000 +0200
@@ -5,7 +5,7 @@
SYNOPSIS
use Struct::Dumb;
-
+
struct Point => [qw( x y )];
my $point = Point(10, 20);
@@ -32,7 +32,7 @@
use Struct::Dumb qw( -named_constructors )
- struct Point3D => [qw( x y z ];
+ struct Point3D => [qw( x y z )];
my $point3d = Point3D( x => 100, z => 12, y => 50 );
@@ -88,6 +88,17 @@
basis to default true by supplying the -named_constructors option on
the use statement.
+ When using named constructors, individual fields may be declared as
+ being optional. By preceeding the field name with a ? character, the
+ constructor is instructed not to complain if a named parameter is not
+ given for that field; instead it will be set to undef.
+
+ struct Person => [qw( name age ?address )],
+ named_constructor => 1;
+
+ my $bob = Person( name => "Bob", age => 20 );
+ # This is valid because 'address' is marked as optional
+
FUNCTIONS
struct
@@ -126,6 +137,23 @@
Takes the same options as "struct".
+DATA::DUMP FILTER
+
+ Since version 0.10.
+
+ If Data::Dump is loaded, an extra filter is applied so that struct
+ instances are printed in a format matching that which would construct
+ them.
+
+ struct Colour => [qw( red green blue )];
+
+ use Data::Dump;
+
+ my %hash = ( col => Colour( 0.8, 0.5, 0.2 ) );
+ Data::Dump::dd \%hash;
+
+ # prints {col => main::Colour(0.8, 0.5, 0.2)}
+
NOTES
Allowing ARRAY dereference
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/lib/Struct/Dumb.pm
new/Struct-Dumb-0.11/lib/Struct/Dumb.pm
--- old/Struct-Dumb-0.09/lib/Struct/Dumb.pm 2016-03-09 18:51:22.000000000
+0100
+++ new/Struct-Dumb-0.11/lib/Struct/Dumb.pm 2020-04-17 02:24:18.000000000
+0200
@@ -1,14 +1,14 @@
# You may distribute under the terms of either the GNU General Public License
# or the Artistic License (the same terms as Perl itself)
#
-# (C) Paul Evans, 2012-2016 -- [email protected]
+# (C) Paul Evans, 2012-2020 -- [email protected]
package Struct::Dumb;
use strict;
use warnings;
-our $VERSION = '0.09';
+our $VERSION = '0.11';
use Carp;
@@ -25,7 +25,7 @@
=head1 SYNOPSIS
use Struct::Dumb;
-
+
struct Point => [qw( x y )];
my $point = Point(10, 20);
@@ -55,7 +55,7 @@
use Struct::Dumb qw( -named_constructors )
- struct Point3D => [qw( x y z ];
+ struct Point3D => [qw( x y z )];
my $point3d = Point3D( x => 100, z => 12, y => 50 );
@@ -109,6 +109,17 @@
default true by supplying the C<-named_constructors> option on the C<use>
statement.
+When using named constructors, individual fields may be declared as being
+optional. By preceeding the field name with a C<?> character, the constructor
+is instructed not to complain if a named parameter is not given for that
+field; instead it will be set to C<undef>.
+
+ struct Person => [qw( name age ?address )],
+ named_constructor => 1;
+
+ my $bob = Person( name => "Bob", age => 20 );
+ # This is valid because 'address' is marked as optional
+
=cut
sub import
@@ -157,44 +168,30 @@
=cut
+my %_STRUCT_PACKAGES;
+
sub _struct
{
- my ( $name, $fields, $caller, %opts ) = @_;
+ my ( $name, $_fields, $caller, %opts ) = @_;
my $lvalue = !!$opts{lvalue};
my $named = !!$opts{named_constructor};
my $pkg = "${caller}::$name";
- my %subs;
- foreach ( 0 .. $#$fields ) {
- my $idx = $_;
- my $field = $fields->[$idx];
+ my @fields = @$_fields;
- BEGIN {
- overloading->unimport if HAVE_OVERLOADING;
- }
-
- $subs{$field} = $lvalue
- ? sub :lvalue { @_ > 1 and croak "$pkg->$field invoked with
arguments";
- shift->[$idx] }
- : sub { @_ > 1 and croak "$pkg->$field invoked with
arguments";
- shift->[$idx] };
- }
- $subs{DESTROY} = sub {};
- $subs{AUTOLOAD} = sub :lvalue {
- my ( $field ) = our $AUTOLOAD =~ m/::([^:]+)$/;
- croak "$pkg does not have a '$field' field";
- my $dummy; ## croak can't be last because it isn't lvalue, so this line
is required
- };
+ my %optional;
+ s/^\?// and $optional{$_}++ for @fields;
my $constructor;
if( $named ) {
$constructor = sub {
my %values = @_;
my @values;
- foreach ( @$fields ) {
- exists $values{$_} or croak "usage: $pkg requires '$_'";
+ foreach ( @fields ) {
+ exists $values{$_} or $optional{$_} or
+ croak "usage: $pkg requires '$_'";
push @values, delete $values{$_};
}
if( my ( $extrakey ) = keys %values ) {
@@ -204,14 +201,36 @@
};
}
else {
- my $fieldcount = @$fields;
- my $argnames = join ", ", map "\$$_", @$fields;
+ my $fieldcount = @fields;
+ my $argnames = join ", ", map "\$$_", @fields;
$constructor = sub {
@_ == $fieldcount or croak "usage: $pkg($argnames)";
bless [ @_ ], $pkg;
};
}
+ my %subs;
+ foreach ( 0 .. $#fields ) {
+ my $idx = $_;
+ my $field = $fields[$idx];
+
+ BEGIN {
+ overloading->unimport if HAVE_OVERLOADING;
+ }
+
+ $subs{$field} = $lvalue
+ ? sub :lvalue { @_ > 1 and croak "$pkg->$field invoked with
arguments";
+ shift->[$idx] }
+ : sub { @_ > 1 and croak "$pkg->$field invoked with
arguments";
+ shift->[$idx] };
+ }
+ $subs{DESTROY} = sub {};
+ $subs{AUTOLOAD} = sub :lvalue {
+ my ( $field ) = our $AUTOLOAD =~ m/::([^:]+)$/;
+ croak "$pkg does not have a '$field' field";
+ my $dummy; ## croak can't be last because it isn't lvalue, so this line
is required
+ };
+
no strict 'refs';
*{"${pkg}::$_"} = $subs{$_} for keys %subs;
*{"${caller}::$name"} = $constructor;
@@ -233,6 +252,11 @@
'bool' => sub { 1 },
fallback => 1,
);
+
+ $_STRUCT_PACKAGES{$pkg} = {
+ named => $named,
+ fields => \@fields,
+ }
}
=head2 struct
@@ -278,6 +302,22 @@
=cut
+=head1 DATA::DUMP FILTER
+
+I<Since version 0.10.>
+
+If L<Data::Dump> is loaded, an extra filter is applied so that struct
+instances are printed in a format matching that which would construct them.
+
+ struct Colour => [qw( red green blue )];
+
+ use Data::Dump;
+
+ my %hash = ( col => Colour( 0.8, 0.5, 0.2 ) );
+ Data::Dump::dd \%hash;
+
+ # prints {col => main::Colour(0.8, 0.5, 0.2)}
+
=head1 NOTES
=head2 Allowing ARRAY dereference
@@ -319,4 +359,41 @@
=cut
+sub apply_datadump_filter
+{
+ require Data::Dump::Filtered;
+
+ Data::Dump::Filtered::add_dump_filter( sub {
+ my ( $ctx, $obj ) = @_;
+ return undef unless my $meta = $_STRUCT_PACKAGES{ $ctx->class };
+
+ BEGIN {
+ overloading->unimport if HAVE_OVERLOADING;
+ }
+
+ my $fields = $meta->{fields};
+ return {
+ dump => sprintf "%s(%s)", $ctx->class,
+ join ", ", map {
+ ( $meta->{named} ? "$fields->[$_] => " : "" ) .
+ Data::Dump::dump($obj->[$_])
+ } 0 .. $#$fields
+ };
+ });
+}
+
+if( defined &Data::Dump::dump ) {
+ apply_datadump_filter;
+}
+else {
+ $Data::Dump::VERSION = bless \( my $x = \&apply_datadump_filter ),
"Struct::Dumb::_DestroyWatch";
+}
+
+{
+ package Struct::Dumb::_DestroyWatch;
+ my $GD = 0;
+ END { $GD = 1 }
+ sub DESTROY { ${$_[0]}->() unless $GD; }
+}
+
0x55AA;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/t/04named.t
new/Struct-Dumb-0.11/t/04named.t
--- old/Struct-Dumb-0.09/t/04named.t 2016-03-09 18:51:22.000000000 +0100
+++ new/Struct-Dumb-0.11/t/04named.t 2020-04-17 02:24:18.000000000 +0200
@@ -41,4 +41,15 @@
qr/^usage: main::Colour does not recognise 'yellow' at \S+ line
\d+\.?\n/,
'Colour() with yellow throws usage exception' );
+{
+ package named::optional;
+ use Struct::Dumb;
+
+ struct PointXY => [qw( x y ?z )],
+ named_constructor => 1;
+
+ my $point = PointXY( x => 1, y => 2 );
+ ::is( $point->z, undef, '$point->z from named constructor optional
argument' );
+}
+
done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/t/10data-dump.t
new/Struct-Dumb-0.11/t/10data-dump.t
--- old/Struct-Dumb-0.09/t/10data-dump.t 1970-01-01 01:00:00.000000000
+0100
+++ new/Struct-Dumb-0.11/t/10data-dump.t 2020-04-17 02:24:18.000000000
+0200
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Data::Dump 'pp';
+use Struct::Dumb;
+
+struct Point => [qw( x y )];
+
+{
+ my $point = Point( 10, 20 );
+
+ is( pp( $point ),
+ 'main::Point(10, 20)',
+ 'Data::Dump::pp can dump a Point' );
+}
+
+struct PointX => [qw( x y )], named_constructor => 1;
+
+{
+ is( pp( PointX( x => 30, y => 40 ) ),
+ 'main::PointX(x => 30, y => 40)',
+ 'Data::Dump::pp dumps named constructors with names' );
+}
+
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Struct-Dumb-0.09/t/11data-dump-late.t
new/Struct-Dumb-0.11/t/11data-dump-late.t
--- old/Struct-Dumb-0.09/t/11data-dump-late.t 1970-01-01 01:00:00.000000000
+0100
+++ new/Struct-Dumb-0.11/t/11data-dump-late.t 2020-04-17 02:24:18.000000000
+0200
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Struct::Dumb;
+use Data::Dump 'pp';
+
+struct Point => [qw( x y )];
+
+{
+ my $point = Point( 10, 20 );
+
+ is( pp( $point ),
+ 'main::Point(10, 20)',
+ 'Data::Dump::pp can dump a Point when loaded after' );
+}
+
+done_testing;