Hello community, here is the log from the commit of package perl-Struct-Dumb for openSUSE:Factory checked in at 2015-10-14 16:45:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Struct-Dumb (Old) and /work/SRC/openSUSE:Factory/.perl-Struct-Dumb.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Struct-Dumb" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Struct-Dumb/perl-Struct-Dumb.changes 2015-05-11 19:49:22.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Struct-Dumb.new/perl-Struct-Dumb.changes 2015-10-14 16:45:20.000000000 +0200 @@ -1,0 +2,39 @@ +Mon Oct 12 09:14:03 UTC 2015 - [email protected] + +- updated to 0.07 + see /usr/share/doc/packages/perl-Struct-Dumb/Changes + + 0.07 2015/10/11 12:37:51 + [BUGFIXES] + * Provide the other conversion overload operations and allow fallback + +------------------------------------------------------------------- +Sat Oct 10 09:26:35 UTC 2015 - [email protected] + +- updated to 0.06 + see /usr/share/doc/packages/perl-Struct-Dumb/Changes + + 0.06 2015/10/07 00:24:52 + [BUGFIXES] + * Ensure that structs are still boolean true + + 0.05 2015/10/06 23:12:58 + [BUGFIXES] + * Throw an exception on attempts to dereference a struct as an + array (RT107583) + * Throw an exception if accessor-mutators are invoked with extra + arguments + * Give AUTOLOAD :lvalue context so it reports the right message for + attempts to assign to missing fields (RT107577) + +------------------------------------------------------------------- +Fri Oct 2 09:37:16 UTC 2015 - [email protected] + +- updated to 0.04 + see /usr/share/doc/packages/perl-Struct-Dumb/Changes + + 0.04 2015/09/30 18:29:01 + [CHANGES] + * Support creating a predicate test function + +------------------------------------------------------------------- Old: ---- Struct-Dumb-0.03.tar.gz New: ---- Struct-Dumb-0.07.tar.gz cpanspec.yml ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Struct-Dumb.spec ++++++ --- /var/tmp/diff_new_pack.TThf3R/_old 2015-10-14 16:45:21.000000000 +0200 +++ /var/tmp/diff_new_pack.TThf3R/_new 2015-10-14 16:45:21.000000000 +0200 @@ -17,7 +17,7 @@ Name: perl-Struct-Dumb -Version: 0.03 +Version: 0.07 Release: 0 %define cpan_name Struct-Dumb Summary: Make Simple Lightweight Record-Like Structures @@ -25,6 +25,7 @@ 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 +Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl @@ -51,7 +52,9 @@ slightly nicer way to store data structures, where otherwise you might be tempted to abuse a hash, complete with the risk of typoing key names. The constructor will 'croak' if passed the wrong number of arguments, as will -attempts to refer to fields that don't exist. +attempts to refer to fields that don't exist. Accessor-mutators will +'croak' if invoked with extra arguments; a likely bug in case of mutations, +or attempts to invoke a stored 'CODE' reference. $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(30)' usage: main::Point($x, $y) at -e line 1 @@ -59,6 +62,9 @@ $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(10,20)->z' main::Point does not have a 'z' field at -e line 1 + $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(1,2)->x(3)' + main::Point->x invoked with arguments at -e line 1. + %prep %setup -q -n %{cpan_name}-%{version} ++++++ Struct-Dumb-0.03.tar.gz -> Struct-Dumb-0.07.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/Changes new/Struct-Dumb-0.07/Changes --- old/Struct-Dumb-0.03/Changes 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/Changes 2015-10-11 13:39:45.000000000 +0200 @@ -1,5 +1,26 @@ Revision history for Struct-Dumb +0.07 2015/10/11 12:37:51 + [BUGFIXES] + * Provide the other conversion overload operations and allow fallback + +0.06 2015/10/07 00:24:52 + [BUGFIXES] + * Ensure that structs are still boolean true + +0.05 2015/10/06 23:12:58 + [BUGFIXES] + * Throw an exception on attempts to dereference a struct as an + array (RT107583) + * Throw an exception if accessor-mutators are invoked with extra + arguments + * Give AUTOLOAD :lvalue context so it reports the right message for + attempts to assign to missing fields (RT107577) + +0.04 2015/09/30 18:29:01 + [CHANGES] + * Support creating a predicate test function + 0.03 2014/07/25 10:01:02 [CHANGES] * Support named constructors (RT97452) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/LICENSE new/Struct-Dumb-0.07/LICENSE --- old/Struct-Dumb-0.03/LICENSE 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/LICENSE 2015-10-11 13:39:45.000000000 +0200 @@ -1,4 +1,4 @@ -This software is copyright (c) 2014 by Paul Evans <[email protected]>. +This software is copyright (c) 2015 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) 2014 by Paul Evans <[email protected]>. +This software is Copyright (c) 2015 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) 2014 by Paul Evans <[email protected]>. +This software is Copyright (c) 2015 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.03/MANIFEST new/Struct-Dumb-0.07/MANIFEST --- old/Struct-Dumb-0.03/MANIFEST 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/MANIFEST 2015-10-11 13:39:45.000000000 +0200 @@ -12,4 +12,5 @@ t/02scope.t t/03readonly.t t/04named.t +t/05predicate.t t/99pod.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/META.json new/Struct-Dumb-0.07/META.json --- old/Struct-Dumb-0.03/META.json 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/META.json 2015-10-11 13:39:45.000000000 +0200 @@ -4,7 +4,7 @@ "Paul Evans <[email protected]>" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.4205", + "generated_by" : "Module::Build version 0.4211", "license" : [ "perl_5" ], @@ -24,7 +24,7 @@ "provides" : { "Struct::Dumb" : { "file" : "lib/Struct/Dumb.pm", - "version" : "0.03" + "version" : "0.07" } }, "release_status" : "stable", @@ -33,5 +33,5 @@ "http://dev.perl.org/licenses/" ] }, - "version" : "0.03" + "version" : "0.07" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/META.yml new/Struct-Dumb-0.07/META.yml --- old/Struct-Dumb-0.03/META.yml 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/META.yml 2015-10-11 13:39:45.000000000 +0200 @@ -6,7 +6,7 @@ Test::Fatal: '0' Test::More: '0.88' dynamic_config: 1 -generated_by: 'Module::Build version 0.4205, CPAN::Meta::Converter version 2.133380' +generated_by: 'Module::Build version 0.4211, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -15,7 +15,7 @@ provides: Struct::Dumb: file: lib/Struct/Dumb.pm - version: '0.03' + version: '0.07' resources: license: http://dev.perl.org/licenses/ -version: '0.03' +version: '0.07' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/Makefile.PL new/Struct-Dumb-0.07/Makefile.PL --- old/Struct-Dumb-0.03/Makefile.PL 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/Makefile.PL 2015-10-11 13:39:45.000000000 +0200 @@ -1,4 +1,4 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.4205 +# Note: this file was auto-generated by Module::Build::Compat version 0.4211 use ExtUtils::MakeMaker; WriteMakefile ( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/README new/Struct-Dumb-0.07/README --- old/Struct-Dumb-0.03/README 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/README 2015-10-11 13:39:45.000000000 +0200 @@ -23,6 +23,14 @@ + struct Point3D => [qw( x y z )], predicate => "is_Point3D"; + + my $point3d = Point3D( 1, 2, 3 ); + + printf "This is a Point3D\n" if is_Point3D( $point3d ); + + + use Struct::Dumb qw( -named_constructors ) struct Point3D => [qw( x y z ]; @@ -46,7 +54,9 @@ slightly nicer way to store data structures, where otherwise you might be tempted to abuse a hash, complete with the risk of typoing key names. The constructor will `croak' if passed the wrong number of arguments, as - will attempts to refer to fields that don't exist. + will attempts to refer to fields that don't exist. Accessor-mutators + will `croak' if invoked with extra arguments; a likely bug in case of + mutations, or attempts to invoke a stored `CODE' reference. $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(30)' usage: main::Point($x, $y) at -e line 1 @@ -54,6 +64,9 @@ $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(10,20)->z' main::Point does not have a 'z' field at -e line 1 + $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(1,2)->x(3)' + main::Point->x invoked with arguments at -e line 1. + CONSTRUCTOR FORMS The `struct' and `readonly_struct' declarations create two different kinds of constructor function, depending on the setting of the @@ -68,7 +81,11 @@ the `use' statement. FUNCTIONS - struct $name => [ @fieldnames ], %opts + struct + struct $name => [ @fieldnames ], + named_constructor => (1|0), + predicate => "is_$name"; + Creates a new structure type. This exports a new function of the type's name into the caller's namespace. Invoking this function returns a new instance of a type that implements those field names, as accessors and @@ -80,12 +97,25 @@ Determines whether the structure will take positional or named arguments. - readonly_struct $name => [ @fieldnames ], %opts - Similar to `struct', but instances of this type are immutable once + predicate => STR + If defined, gives the name of a second function to export to the + caller's namespace. This function will be a type test predicate; + that is, a function that takes a single argmuent, and returns true + if-and-only-if that argument is an instance of this structure type. + + readonly_struct + readonly_struct $name => [ @fieldnames ], + ... + + Similar to struct, but instances of this type are immutable once constructed. The field accessor methods will not be marked with the `:lvalue' attribute. - Takes the same options as `struct'. + Takes the same options as struct. + +TODO + * Consider adding an `coerce_hash' option, giving name of another + function to convert structs to key/value pairs, or a HASH ref. AUTHOR Paul Evans <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/lib/Struct/Dumb.pm new/Struct-Dumb-0.07/lib/Struct/Dumb.pm --- old/Struct-Dumb-0.03/lib/Struct/Dumb.pm 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/lib/Struct/Dumb.pm 2015-10-11 13:39:45.000000000 +0200 @@ -1,17 +1,19 @@ # 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-2014 -- [email protected] +# (C) Paul Evans, 2012-2015 -- [email protected] package Struct::Dumb; use strict; use warnings; -our $VERSION = '0.03'; +our $VERSION = '0.07'; use Carp; +use Scalar::Util qw( refaddr ); + =head1 NAME C<Struct::Dumb> - make simple lightweight record-like structures @@ -39,6 +41,14 @@ Z<> + struct Point3D => [qw( x y z )], predicate => "is_Point3D"; + + my $point3d = Point3D( 1, 2, 3 ); + + printf "This is a Point3D\n" if is_Point3D( $point3d ); + +Z<> + use Struct::Dumb qw( -named_constructors ) struct Point3D => [qw( x y z ]; @@ -63,7 +73,9 @@ slightly nicer way to store data structures, where otherwise you might be tempted to abuse a hash, complete with the risk of typoing key names. The constructor will C<croak> if passed the wrong number of arguments, as will -attempts to refer to fields that don't exist. +attempts to refer to fields that don't exist. Accessor-mutators will C<croak> +if invoked with extra arguments; a likely bug in case of mutations, or +attempts to invoke a stored C<CODE> reference. $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(30)' usage: main::Point($x, $y) at -e line 1 @@ -71,6 +83,9 @@ $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(10,20)->z' main::Point does not have a 'z' field at -e line 1 + $ perl -E 'use Struct::Dumb; struct Point => [qw( x y )]; Point(1,2)->x(3)' + main::Point->x invoked with arguments at -e line 1. + =head2 CONSTRUCTOR FORMS The C<struct> and C<readonly_struct> declarations create two different kinds @@ -144,13 +159,20 @@ my %subs; foreach ( 0 .. $#$fields ) { my $idx = $_; - $subs{$fields->[$idx]} = $lvalue ? sub :lvalue { shift->[$idx] } - : sub { shift->[$idx] }; + my $field = $fields->[$idx]; + + no 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 { + $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 $constructor; @@ -180,9 +202,26 @@ no strict 'refs'; *{"${pkg}::$_"} = $subs{$_} for keys %subs; *{"${caller}::$name"} = $constructor; + + if( my $predicate = $opts{predicate} ) { + *{"${caller}::$predicate"} = sub { ( ref($_[0]) // "" ) eq $pkg }; + } + + require overload; + $pkg->overload::OVERLOAD( + '@{}' => sub { croak "Cannot use $pkg as an ARRAY reference" }, + '0+' => sub { refaddr $_[0] }, + '""' => sub { sprintf "%s=Struct::Dumb(%#x)", $pkg, refaddr $_[0] }, + 'bool' => sub { 1 }, + fallback => 1, + ); } -=head2 struct $name => [ @fieldnames ], %opts +=head2 struct + + struct $name => [ @fieldnames ], + named_constructor => (1|0), + predicate => "is_$name"; Creates a new structure type. This exports a new function of the type's name into the caller's namespace. Invoking this function returns a new instance of @@ -197,20 +236,41 @@ Determines whether the structure will take positional or named arguments. +=item predicate => STR + +If defined, gives the name of a second function to export to the caller's +namespace. This function will be a type test predicate; that is, a function +that takes a single argmuent, and returns true if-and-only-if that argument is +an instance of this structure type. + =back =cut -=head2 readonly_struct $name => [ @fieldnames ], %opts +=head2 readonly_struct -Similar to C<struct>, but instances of this type are immutable once + readonly_struct $name => [ @fieldnames ], + ... + +Similar to L</struct>, but instances of this type are immutable once constructed. The field accessor methods will not be marked with the C<:lvalue> attribute. -Takes the same options as C<struct>. +Takes the same options as L</struct>. =cut +=head1 TODO + +=over 4 + +=item * + +Consider adding an C<coerce_hash> option, giving name of another function to +convert structs to key/value pairs, or a HASH ref. + +=back + =head1 AUTHOR Paul Evans <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/t/01point.t new/Struct-Dumb-0.07/t/01point.t --- old/Struct-Dumb-0.03/t/01point.t 2014-07-25 11:07:36.000000000 +0200 +++ new/Struct-Dumb-0.07/t/01point.t 2015-10-11 13:39:45.000000000 +0200 @@ -6,6 +6,8 @@ use Test::More; use Test::Fatal; +use Scalar::Util qw( refaddr ); + use Struct::Dumb; struct Point => [qw( x y )]; @@ -24,8 +26,29 @@ qr/^main::Point does not have a 'z' field at \S+ line \d+\.?\n/, '$point->z throws exception' ); +like( exception { $point->z = 40 }, + qr/^main::Point does not have a 'z' field at \S+ line \d+\.?\n/, + '$point->z :lvalue throws exception' ); + like( exception { Point(30) }, qr/^usage: main::Point\(\$x, \$y\) at \S+ line \d+\.?\n/, 'Point(30) throws usage exception' ); +like( exception { @{ Point(0, 0) } }, + qr/^Cannot use main::Point as an ARRAY reference at \S+ line \d+\.?\n/, + 'Array deref throws exception' ); + +like( exception { $point->x(50) }, + qr/^main::Point->x invoked with arguments at \S+ line \d+\.?\n/, + 'Accessor with arguments throws exception' ); + +ok( !( local $@ = exception { !! Point(0, 0) } ), + 'Point is boolean true' ) or diag( "Exception was $@" ); + +is( $point + 0, refaddr $point, + 'Point numifies to its reference address' ); + +like( "$point", qr/^main::Point=Struct::Dumb\(0x[0-9a-fA-F]+\)$/, + 'Point stringifies to something sensible' ); + done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Struct-Dumb-0.03/t/05predicate.t new/Struct-Dumb-0.07/t/05predicate.t --- old/Struct-Dumb-0.03/t/05predicate.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Struct-Dumb-0.07/t/05predicate.t 2015-10-11 13:39:45.000000000 +0200 @@ -0,0 +1,18 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; +use Test::Fatal; + +use Struct::Dumb; + +struct Point => [qw( x y )], predicate => "is_Point"; + +my $point = Point(10, 20); +ok( is_Point( $point ), '$point is a Point' ); + +ok( !is_Point( [] ), 'unblessed ARRAYref is not a Point' ); + +done_testing; ++++++ cpanspec.yml ++++++ --- #description_paragraphs: 3 #no_testing: broken upstream #sources: # - source1 # - source2 #patches: # foo.patch: -p1 # bar.patch: #preamble: |- # BuildRequires: gcc-c++ #post_prep: |- # hunspell=`pkg-config --libs hunspell | sed -e 's,-l,,; s, *,,g'` # sed -i -e "s,hunspell-X,$hunspell," t/00-prereq.t Makefile.PL #post_install: |- # sed on %{name}.files #license: SUSE-NonFree #skip_noarch: 1 #custom_build: |- #./Build build flags=%{?_smp_mflags} --myflag #custom_test: |- #startserver && make test #ignore_requires: Bizarre::Module
