Hello community,
here is the log from the commit of package perl-Class-Tiny for openSUSE:Factory checked in at 2015-02-10 20:22:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Class-Tiny (Old)
and /work/SRC/openSUSE:Factory/.perl-Class-Tiny.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Class-Tiny"
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Class-Tiny/perl-Class-Tiny.changes 2014-08-25 11:05:17.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.perl-Class-Tiny.new/perl-Class-Tiny.changes 2015-02-10 20:22:42.000000000 +0100
@@ -1,0 +2,10 @@
+Sat Feb 7 07:21:44 UTC 2015 - coolo@suse.com
+
+- updated to 1.001
+ [ADDED]
+ - Added support for BUILDARGS for Moo(se) compatibility
+
+ [INTERNAL]
+ - Implements BUILDALL via method (was inline) for Moo(se) compatibility
+
+-------------------------------------------------------------------
Old:
----
Class-Tiny-1.000.tar.gz
New:
----
Class-Tiny-1.001.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Class-Tiny.spec ++++++
--- /var/tmp/diff_new_pack.366q8R/_old 2015-02-10 20:22:43.000000000 +0100
+++ /var/tmp/diff_new_pack.366q8R/_new 2015-02-10 20:22:43.000000000 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-Class-Tiny
#
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 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
@@ -17,42 +17,24 @@
Name: perl-Class-Tiny
-Version: 1.000
+Version: 1.001
Release: 0
%define cpan_name Class-Tiny
Summary: Minimalist class construction
License: Apache-2.0
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/Class-Tiny/
-Source: Class-Tiny-1.000.tar.gz
+Source: http://www.cpan.org/authors/id/D/DA/DAGOLDEN/%{cpan_name}-%{version}.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(Test::More) >= 0.96
-BuildRequires: perl(version)
%{perl_requires}
%description
This module offers a minimalist class construction kit in around 120 lines
-of code. Here is a list of features:
-
-* defines attributes via import arguments
-* generates read-write accessors
-* supports lazy attribute defaults
-* supports custom accessors
-* superclass provides a standard 'new' constructor
-* 'new' takes a hash reference or list of key/value pairs
-* 'new' calls 'BUILD' for each class from parent to child
-* superclass provides a 'DESTROY' method
-* 'DESTROY' calls 'DEMOLISH' for each class from child to parent
-
-Multiple-inheritance is possible, with superclass order determined via
-mro/Functions.
-
-It uses no non-core modules for any recent Perl. On Perls older than v5.10
-it requires the MRO::Compat manpage. On Perls older than v5.14, it requires
-the Devel::GlobalDestruction manpage.
+of code.
%prep
%setup -q -n %{cpan_name}-%{version}
@@ -71,6 +53,6 @@
%files -f %{name}.files
%defattr(-,root,root,755)
-%doc Changes CONTRIBUTING cpanfile LICENSE perlcritic.rc README tidyall.ini
+%doc Changes CONTRIBUTING.mkdn cpanfile LICENSE perlcritic.rc README tidyall.ini
%changelog
++++++ Class-Tiny-1.000.tar.gz -> Class-Tiny-1.001.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/CONTRIBUTING new/Class-Tiny-1.001/CONTRIBUTING
--- old/Class-Tiny-1.000/CONTRIBUTING 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/CONTRIBUTING 1970-01-01 01:00:00.000000000 +0100
@@ -1,70 +0,0 @@
-## HOW TO CONTRIBUTE
-
-Thank you for considering contributing to this distribution. This file
-contains instructions that will help you work with the source code.
-
-The distribution is managed with Dist::Zilla. This means than many of the
-usual files you might expect are not in the repository, but are generated
-at release time (e.g. Makefile.PL).
-
-### Getting dependencies
-
-See the included `cpanfile` file for a list of dependencies. If you have
-App::cpanminus 1.6 or later installed, you can use `cpanm` to satisfy
-dependencies like this:
-
- $ cpanm --installdeps .
-
-Otherwise, you can install Module::CPANfile 1.0002 or later and then satisfy
-dependencies with the regular `cpan` client and `cpanfile-dump`:
-
- $ cpan `cpanfile-dump`
-
-### Running tests
-
-You can run tests directly using the `prove` tool:
-
- $ prove -l
- $ prove -lv t/some_test_file.t
-
-For most distributions, `prove` is entirely sufficent for you to test any
-patches you have.
-
-### Code style and tidying
-
-Please try to match any existing coding style. If there is a `.perltidyrc`
-file, please install Perl::Tidy and use perltidy before submitting patches.
-
-If there is a `tidyall.ini` file, you can also install Code::TidyAll and run
-`tidyall` on a file or `tidyall -a` to tidy all files.
-
-### Patching documentation
-
-Much of the documentation Pod is generated at release time.
-Depending on the distribution, some documentation may be written in a Pod
-dialect called WikiDoc. (See Pod::WikiDoc on CPAN.)
-
-If you would like to submit a documentation edit, please limit yourself to the
-documentation you see.
-
-If you see typos or documentation issues in the generated docs, please
-email or open a bug ticket instead of patching.
-
-### Learning Dist::Zilla
-
-Dist::Zilla is a very powerful authoring tool, but requires a number of
-author-specific plugins. If you would like to use it for contributing,
-install it from CPAN, then run one of the following commands, depending on
-your CPAN client:
-
- $ cpan `dzil authordeps`
- $ dzil authordeps | cpanm
-
-Once installed, here are some dzil commands you might try:
-
- $ dzil build
- $ dzil test
- $ dzil xtest
-
-You can learn more about Dist::Zilla at http://dzil.org/
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/CONTRIBUTING.mkdn new/Class-Tiny-1.001/CONTRIBUTING.mkdn
--- old/Class-Tiny-1.000/CONTRIBUTING.mkdn 1970-01-01 01:00:00.000000000 +0100
+++ new/Class-Tiny-1.001/CONTRIBUTING.mkdn 2015-01-31 03:13:12.000000000 +0100
@@ -0,0 +1,87 @@
+## HOW TO CONTRIBUTE
+
+Thank you for considering contributing to this distribution. This file
+contains instructions that will help you work with the source code.
+
+The distribution is managed with Dist::Zilla. This means than many of the
+usual files you might expect are not in the repository, but are generated at
+release time, as is much of the documentation. Some generated files are
+kept in the repository as a convenience (e.g. Makefile.PL or cpanfile).
+
+Generally, **you do not need Dist::Zilla to contribute patches**. You do need
+Dist::Zilla to create a tarball. See below for guidance.
+
+### Getting dependencies
+
+If you have App::cpanminus 1.6 or later installed, you can use `cpanm` to
+satisfy dependencies like this:
+
+ $ cpanm --installdeps .
+
+Otherwise, look for either a `Makefile.PL` or `cpanfile` file for
+a list of dependencies to satisfy.
+
+### Running tests
+
+You can run tests directly using the `prove` tool:
+
+ $ prove -l
+ $ prove -lv t/some_test_file.t
+
+For most of my distributions, `prove` is entirely sufficient for you to test any
+patches you have. I use `prove` for 99% of my testing during development.
+
+### Code style and tidying
+
+Please try to match any existing coding style. If there is a `.perltidyrc`
+file, please install Perl::Tidy and use perltidy before submitting patches.
+
+If there is a `tidyall.ini` file, you can also install Code::TidyAll and run
+`tidyall` on a file or `tidyall -a` to tidy all files.
+
+### Patching documentation
+
+Much of the documentation Pod is generated at release time. Some is
+generated boilerplate; other documentation is built from pseudo-POD
+directives in the source like C<=method> or C<=func>.
+
+If you would like to submit a documentation edit, please limit yourself to
+the documentation you see.
+
+If you see typos or documentation issues in the generated docs, please
+email or open a bug ticket instead of patching.
+
+### Installing and using Dist::Zilla
+
+Dist::Zilla is a very powerful authoring tool, optimized for maintaining a
+large number of distributions with a high degree of automation, but it has a
+large dependency chain, a bit of a learning curve and requires a number of
+author-specific plugins.
+
+To install it from CPAN, I recommend one of the following approaches for
+the quickest installation:
+
+ # using CPAN.pm, but bypassing non-functional pod tests
+ $ cpan TAP::Harness::Restricted
+ $ PERL_MM_USE_DEFAULT=1 HARNESS_CLASS=TAP::Harness::Restricted cpan Dist::Zilla
+
+ # using cpanm, bypassing *all* tests
+ $ cpanm -n Dist::Zilla
+
+In either case, it's probably going to take about 10 minutes. Go for a walk,
+go get a cup of your favorite beverage, take a bathroom break, or whatever.
+When you get back, Dist::Zilla should be ready for you.
+
+Then you need to install any plugins specific to this distribution:
+
+ $ cpan `dzil authordeps`
+ $ dzil authordeps | cpanm
+
+Once installed, here are some dzil commands you might try:
+
+ $ dzil build
+ $ dzil test
+ $ dzil xtest
+
+You can learn more about Dist::Zilla at http://dzil.org/
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/Changes new/Class-Tiny-1.001/Changes
--- old/Class-Tiny-1.000/Changes 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/Changes 2015-01-31 03:13:12.000000000 +0100
@@ -1,5 +1,15 @@
Revision history for Class-Tiny
+1.001 2015-01-30 21:13:07-05:00 America/New_York
+
+ [ADDED]
+
+ - Added support for BUILDARGS for Moo(se) compatibility
+
+ [INTERNAL]
+
+ - Implements BUILDALL via method (was inline) for Moo(se) compatibility
+
1.000 2014-07-16 09:55:29-04:00 America/New_York
[*** INCOMPATIBLE CHANGES ***]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/MANIFEST new/Class-Tiny-1.001/MANIFEST
--- old/Class-Tiny-1.000/MANIFEST 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/MANIFEST 2015-01-31 03:13:12.000000000 +0100
@@ -1,5 +1,5 @@
-# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.019.
-CONTRIBUTING
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.031.
+CONTRIBUTING.mkdn
Changes
LICENSE
MANIFEST
@@ -11,6 +11,7 @@
dist.ini
lib/Class/Tiny.pm
perlcritic.rc
+t/00-report-prereqs.dd
t/00-report-prereqs.t
t/alfa.t
t/baker.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/META.json new/Class-Tiny-1.001/META.json
--- old/Class-Tiny-1.000/META.json 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/META.json 2015-01-31 03:13:12.000000000 +0100
@@ -4,13 +4,13 @@
"David Golden "
],
"dynamic_config" : 1,
- "generated_by" : "Dist::Zilla version 5.019, CPAN::Meta::Converter version 2.141170",
+ "generated_by" : "Dist::Zilla version 5.031, CPAN::Meta::Converter version 2.143240",
"license" : [
"apache_2_0"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
- "version" : "2"
+ "version" : 2
},
"name" : "Class-Tiny",
"no_index" : {
@@ -27,7 +27,8 @@
"prereqs" : {
"configure" : {
"requires" : {
- "ExtUtils::MakeMaker" : "6.17"
+ "ExtUtils::MakeMaker" : "6.17",
+ "perl" : "5.006"
}
},
"develop" : {
@@ -37,7 +38,7 @@
"Dist::Zilla::Plugin::PerlVersionPrereqs" : "0",
"Dist::Zilla::Plugin::Prereqs" : "0",
"Dist::Zilla::Plugin::RemovePrereqs" : "0",
- "Dist::Zilla::PluginBundle::DAGOLDEN" : "0.052",
+ "Dist::Zilla::PluginBundle::DAGOLDEN" : "0.072",
"File::Spec" : "0",
"File::Temp" : "0",
"IO::Handle" : "0",
@@ -47,7 +48,8 @@
"Test::More" : "0",
"Test::Pod" : "1.41",
"Test::Pod::Coverage" : "1.08",
- "Test::Spelling" : "0.12"
+ "Test::Spelling" : "0.12",
+ "Test::Version" : "1"
}
},
"runtime" : {
@@ -60,31 +62,29 @@
},
"test" : {
"recommends" : {
- "CPAN::Meta" : "0",
- "CPAN::Meta::Requirements" : "2.120900",
+ "CPAN::Meta" : "2.120900",
"Test::FailWarnings" : "0"
},
"requires" : {
"Exporter" : "0",
"ExtUtils::MakeMaker" : "0",
- "File::Spec::Functions" : "0",
- "List::Util" : "0",
+ "File::Spec" : "0",
"Test::More" : "0.96",
"base" : "0",
"lib" : "0",
- "subs" : "0",
- "version" : "0"
+ "perl" : "5.006",
+ "subs" : "0"
}
}
},
"provides" : {
"Class::Tiny" : {
"file" : "lib/Class/Tiny.pm",
- "version" : "1.000"
+ "version" : "1.001"
},
"Class::Tiny::Object" : {
"file" : "lib/Class/Tiny.pm",
- "version" : "1.000"
+ "version" : "1.001"
}
},
"release_status" : "stable",
@@ -99,7 +99,7 @@
"web" : "https://github.com/dagolden/Class-Tiny"
}
},
- "version" : "1.000",
+ "version" : "1.001",
"x_authority" : "cpan:DAGOLDEN",
"x_contributors" : [
"Dagfinn Ilmari Mannsåker ",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/META.yml new/Class-Tiny-1.001/META.yml
--- old/Class-Tiny-1.000/META.yml 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/META.yml 2015-01-31 03:13:12.000000000 +0100
@@ -5,17 +5,17 @@
build_requires:
Exporter: '0'
ExtUtils::MakeMaker: '0'
- File::Spec::Functions: '0'
- List::Util: '0'
+ File::Spec: '0'
Test::More: '0.96'
base: '0'
lib: '0'
+ perl: '5.006'
subs: '0'
- version: '0'
configure_requires:
ExtUtils::MakeMaker: '6.17'
+ perl: '5.006'
dynamic_config: 1
-generated_by: 'Dist::Zilla version 5.019, CPAN::Meta::Converter version 2.141170'
+generated_by: 'Dist::Zilla version 5.031, CPAN::Meta::Converter version 2.143240'
license: apache
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -32,10 +32,10 @@
provides:
Class::Tiny:
file: lib/Class/Tiny.pm
- version: '1.000'
+ version: '1.001'
Class::Tiny::Object:
file: lib/Class/Tiny.pm
- version: '1.000'
+ version: '1.001'
requires:
Carp: '0'
perl: '5.006'
@@ -45,7 +45,7 @@
bugtracker: https://github.com/dagolden/Class-Tiny/issues
homepage: https://github.com/dagolden/Class-Tiny
repository: https://github.com/dagolden/Class-Tiny.git
-version: '1.000'
+version: '1.001'
x_authority: cpan:DAGOLDEN
x_contributors:
- 'Dagfinn Ilmari Mannsåker '
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/Makefile.PL new/Class-Tiny-1.001/Makefile.PL
--- old/Class-Tiny-1.000/Makefile.PL 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/Makefile.PL 2015-01-31 03:13:12.000000000 +0100
@@ -1,5 +1,5 @@
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.019.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.031.
use strict;
use warnings;
@@ -18,6 +18,7 @@
"DISTNAME" => "Class-Tiny",
"EXE_FILES" => [],
"LICENSE" => "apache",
+ "MIN_PERL_VERSION" => "5.006",
"NAME" => "Class::Tiny",
"PREREQ_PM" => {
"Carp" => 0,
@@ -27,15 +28,13 @@
"TEST_REQUIRES" => {
"Exporter" => 0,
"ExtUtils::MakeMaker" => 0,
- "File::Spec::Functions" => 0,
- "List::Util" => 0,
+ "File::Spec" => 0,
"Test::More" => "0.96",
"base" => 0,
"lib" => 0,
- "subs" => 0,
- "version" => 0
+ "subs" => 0
},
- "VERSION" => "1.000",
+ "VERSION" => "1.001",
"test" => {
"TESTS" => "t/*.t"
}
@@ -45,15 +44,13 @@
my %FallbackPrereqs = (
"Carp" => 0,
"Exporter" => 0,
- "ExtUtils::MakeMaker" => 0,
- "File::Spec::Functions" => 0,
- "List::Util" => 0,
+ "ExtUtils::MakeMaker" => "6.17",
+ "File::Spec" => 0,
"Test::More" => "0.96",
"base" => 0,
"lib" => 0,
"strict" => 0,
"subs" => 0,
- "version" => 0,
"warnings" => 0
);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/README new/Class-Tiny-1.001/README
--- old/Class-Tiny-1.000/README 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/README 2015-01-31 03:13:12.000000000 +0100
@@ -2,7 +2,7 @@
Class::Tiny - Minimalist class construction
VERSION
- version 1.000
+ version 1.001
SYNOPSIS
In Person.pm:
@@ -50,6 +50,9 @@
* "new" takes a hash reference or list of key/value pairs
+ * "new" supports providing "BUILDARGS" to customize constructor
+ options
+
* "new" calls "BUILD" for each class from parent to child
* superclass provides a "DESTROY" method
@@ -181,6 +184,22 @@
harder for people to cleanly subclass Class::Tiny classes so this
feature was removed.
+ You can define a "BUILDARGS" method to change how arguments to new are
+ handled. It will receive the constructor arguments as they were provided
+ and must return a hash reference of key/value pairs (or else throw an
+ exception).
+
+ sub BUILDARGS {
+ my $class = shift;
+ my $name = shift || "John Doe";
+ return { name => $name };
+ };
+
+ Foo::Bar->new( "David" );
+ Foo::Bar->new(); # "John Doe"
+
+ Unknown attributes returned from "BUILDARGS" will be ignored.
+
BUILD
If your class or any superclass defines a "BUILD" method, it will be
called by the constructor from the furthest parent class down to the
@@ -281,6 +300,7 @@
provides DESTROY yes no no
new takes either hashref or list yes no (list) no (hash)
Moo(se)-like BUILD/DEMOLISH yes no no
+ Moo(se)-like BUILDARGS yes no no
no extraneous methods via @ISA yes yes no
Why this instead of Moose or Moo?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/cpanfile new/Class-Tiny-1.001/cpanfile
--- old/Class-Tiny-1.000/cpanfile 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/cpanfile 2015-01-31 03:13:12.000000000 +0100
@@ -6,23 +6,22 @@
on 'test' => sub {
requires "Exporter" => "0";
requires "ExtUtils::MakeMaker" => "0";
- requires "File::Spec::Functions" => "0";
- requires "List::Util" => "0";
+ requires "File::Spec" => "0";
requires "Test::More" => "0.96";
requires "base" => "0";
requires "lib" => "0";
+ requires "perl" => "5.006";
requires "subs" => "0";
- requires "version" => "0";
};
on 'test' => sub {
- recommends "CPAN::Meta" => "0";
- recommends "CPAN::Meta::Requirements" => "2.120900";
+ recommends "CPAN::Meta" => "2.120900";
recommends "Test::FailWarnings" => "0";
};
on 'configure' => sub {
requires "ExtUtils::MakeMaker" => "6.17";
+ requires "perl" => "5.006";
};
on 'develop' => sub {
@@ -31,7 +30,7 @@
requires "Dist::Zilla::Plugin::PerlVersionPrereqs" => "0";
requires "Dist::Zilla::Plugin::Prereqs" => "0";
requires "Dist::Zilla::Plugin::RemovePrereqs" => "0";
- requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.052";
+ requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.072";
requires "File::Spec" => "0";
requires "File::Temp" => "0";
requires "IO::Handle" => "0";
@@ -42,4 +41,5 @@
requires "Test::Pod" => "1.41";
requires "Test::Pod::Coverage" => "1.08";
requires "Test::Spelling" => "0.12";
+ requires "Test::Version" => "1";
};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/dist.ini new/Class-Tiny-1.001/dist.ini
--- old/Class-Tiny-1.000/dist.ini 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/dist.ini 2015-01-31 03:13:12.000000000 +0100
@@ -5,7 +5,9 @@
copyright_year = 2013
[@DAGOLDEN]
-:version = 0.052
+:version = 0.072
+RewriteVersion.global = 1
+BumpVersionAfterRelease.global = 1
stopwords = destructor
stopwords = fatpacking
stopwords = interoperability
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/lib/Class/Tiny.pm new/Class-Tiny-1.001/lib/Class/Tiny.pm
--- old/Class-Tiny-1.000/lib/Class/Tiny.pm 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/lib/Class/Tiny.pm 2015-01-31 03:13:12.000000000 +0100
@@ -5,7 +5,8 @@
package Class::Tiny;
# ABSTRACT: Minimalist class construction
-our $VERSION = '1.000'; # VERSION
+
+our $VERSION = '1.001';
use Carp ();
@@ -78,57 +79,65 @@
package Class::Tiny::Object;
# ABSTRACT: Base class for classes built with Class::Tiny
-our $VERSION = '1.000'; # VERSION
-my ( %LINEAR_ISA_CACHE, %BUILD_CACHE, %DEMOLISH_CACHE, %ATTR_CACHE );
+our $VERSION = '1.001';
+
+my ( %HAS_BUILDARGS, %BUILD_CACHE, %DEMOLISH_CACHE, %ATTR_CACHE );
my $_PRECACHE = sub {
+ no warnings 'once'; # needed to avoid downstream warnings
my ($class) = @_;
- $LINEAR_ISA_CACHE{$class} =
+ my $linear_isa =
@{"$class\::ISA"} == 1 && ${"$class\::ISA"}[0] eq "Class::Tiny::Object"
? [$class]
: mro::get_linear_isa($class);
- for my $s ( @{ $LINEAR_ISA_CACHE{$class} } ) {
- no warnings 'once'; # needed to avoid downstream warnings
- $BUILD_CACHE{$s} = *{"$s\::BUILD"}{CODE};
- $DEMOLISH_CACHE{$s} = *{"$s\::DEMOLISH"}{CODE};
- }
- $ATTR_CACHE{$class} =
+ $DEMOLISH_CACHE{$class} = [
+ map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
+ map { "$_\::DEMOLISH" } @$linear_isa
+ ];
+ $BUILD_CACHE{$class} = [
+ map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
+ map { "$_\::BUILD" } reverse @$linear_isa
+ ];
+ $HAS_BUILDARGS{$class} = $class->can("BUILDARGS");
+ return $ATTR_CACHE{$class} =
{ map { $_ => 1 } Class::Tiny->get_all_attributes_for($class) };
- return $LINEAR_ISA_CACHE{$class};
};
sub new {
- my $class = shift;
- my $linear_isa = $LINEAR_ISA_CACHE{$class} || $_PRECACHE->($class);
- my $valid_attrs = $ATTR_CACHE{$class};
+ my $class = shift;
+ my $valid_attrs = $ATTR_CACHE{$class} || $_PRECACHE->($class);
# handle hash ref or key/value arguments
my $args;
- if ( @_ == 1 && ref $_[0] ) {
- my %copy = eval { %{ $_[0] } }; # try shallow copy
- Carp::croak("Argument to $class->new() could not be dereferenced as a hash") if $@;
- $args = \%copy;
- }
- elsif ( @_ % 2 == 0 ) {
- $args = {@_};
+ if ( $HAS_BUILDARGS{$class} ) {
+ $args = $class->BUILDARGS(@_);
}
else {
- Carp::croak("$class->new() got an odd number of elements");
+ if ( @_ == 1 && ref $_[0] ) {
+ my %copy = eval { %{ $_[0] } }; # try shallow copy
+ Carp::croak("Argument to $class->new() could not be dereferenced as a hash") if $@;
+ $args = \%copy;
+ }
+ elsif ( @_ % 2 == 0 ) {
+ $args = {@_};
+ }
+ else {
+ Carp::croak("$class->new() got an odd number of elements");
+ }
}
# create object and invoke BUILD (unless we were given __no_BUILD__)
my $self =
bless { map { $_ => $args->{$_} } grep { exists $valid_attrs->{$_} } keys %$args },
$class;
- for my $s ( delete $args->{__no_BUILD__} ? () : reverse @$linear_isa ) {
- next unless my $builder = $BUILD_CACHE{$s};
- $builder->( $self, $args );
- }
+ $self->BUILDALL($args) if !delete $args->{__no_BUILD__} && @{ $BUILD_CACHE{$class} };
return $self;
}
+sub BUILDALL { $_->(@_) for @{ $BUILD_CACHE{ ref $_[0] } } }
+
# Adapted from Moo and its dependencies
require Devel::GlobalDestruction unless defined ${^GLOBAL_PHASE};
@@ -139,8 +148,7 @@
defined ${^GLOBAL_PHASE}
? ${^GLOBAL_PHASE} eq 'DESTRUCT'
: Devel::GlobalDestruction::in_global_destruction();
- for my $s ( @{ $LINEAR_ISA_CACHE{$class} } ) {
- next unless my $demolisher = $DEMOLISH_CACHE{$s};
+ for my $demolisher ( @{ $DEMOLISH_CACHE{$class} } ) {
my $e = do {
local ( $?, $@ );
eval { $demolisher->( $self, $in_global_destruction ) };
@@ -168,7 +176,7 @@
=head1 VERSION
-version 1.000
+version 1.001
=head1 SYNOPSIS
@@ -234,6 +242,10 @@
=item *
+C<new> supports providing C<BUILDARGS> to customize constructor options
+
+=item *
+
C<new> calls C<BUILD> for each class from parent to child
=item *
@@ -372,6 +384,22 @@
version 1.000, unknown attributes were an error, but this made it harder for
people to cleanly subclass Class::Tiny classes so this feature was removed.
+You can define a C<BUILDARGS> method to change how arguments to new are
+handled. It will receive the constructor arguments as they were provided and
+must return a hash reference of key/value pairs (or else throw an
+exception).
+
+ sub BUILDARGS {
+ my $class = shift;
+ my $name = shift || "John Doe";
+ return { name => $name };
+ };
+
+ Foo::Bar->new( "David" );
+ Foo::Bar->new(); # "John Doe"
+
+Unknown attributes returned from C<BUILDARGS> will be ignored.
+
=head2 BUILD
If your class or any superclass defines a C<BUILD> method, it will be called
@@ -478,6 +506,7 @@
provides DESTROY yes no no
new takes either hashref or list yes no (list) no (hash)
Moo(se)-like BUILD/DEMOLISH yes no no
+ Moo(se)-like BUILDARGS yes no no
no extraneous methods via @ISA yes yes no
=head2 Why this instead of Moose or Moo?
@@ -522,6 +551,8 @@
=head1 CONTRIBUTORS
+=for stopwords Dagfinn Ilmari Mannsåker Gelu Lupas Karen Etheridge Matt S Trout Olivier Mengué Toby Inkster
+
=over 4
=item *
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/t/00-report-prereqs.dd new/Class-Tiny-1.001/t/00-report-prereqs.dd
--- old/Class-Tiny-1.000/t/00-report-prereqs.dd 1970-01-01 01:00:00.000000000 +0100
+++ new/Class-Tiny-1.001/t/00-report-prereqs.dd 2015-01-31 03:13:12.000000000 +0100
@@ -0,0 +1,55 @@
+do { my $x = {
+ 'configure' => {
+ 'requires' => {
+ 'ExtUtils::MakeMaker' => '6.17',
+ 'perl' => '5.006'
+ }
+ },
+ 'develop' => {
+ 'requires' => {
+ 'Dist::Zilla' => '5',
+ 'Dist::Zilla::Plugin::OnlyCorePrereqs' => '0.003',
+ 'Dist::Zilla::Plugin::PerlVersionPrereqs' => '0',
+ 'Dist::Zilla::Plugin::Prereqs' => '0',
+ 'Dist::Zilla::Plugin::RemovePrereqs' => '0',
+ 'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.072',
+ 'File::Spec' => '0',
+ 'File::Temp' => '0',
+ 'IO::Handle' => '0',
+ 'IPC::Open3' => '0',
+ 'Pod::Coverage::TrustPod' => '0',
+ 'Test::CPAN::Meta' => '0',
+ 'Test::More' => '0',
+ 'Test::Pod' => '1.41',
+ 'Test::Pod::Coverage' => '1.08',
+ 'Test::Spelling' => '0.12',
+ 'Test::Version' => '1'
+ }
+ },
+ 'runtime' => {
+ 'requires' => {
+ 'Carp' => '0',
+ 'perl' => '5.006',
+ 'strict' => '0',
+ 'warnings' => '0'
+ }
+ },
+ 'test' => {
+ 'recommends' => {
+ 'CPAN::Meta' => '2.120900',
+ 'Test::FailWarnings' => '0'
+ },
+ 'requires' => {
+ 'Exporter' => '0',
+ 'ExtUtils::MakeMaker' => '0',
+ 'File::Spec' => '0',
+ 'Test::More' => '0.96',
+ 'base' => '0',
+ 'lib' => '0',
+ 'perl' => '5.006',
+ 'subs' => '0'
+ }
+ }
+ };
+ $x;
+ }
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/t/00-report-prereqs.t new/Class-Tiny-1.001/t/00-report-prereqs.t
--- old/Class-Tiny-1.000/t/00-report-prereqs.t 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/t/00-report-prereqs.t 2015-01-31 03:13:12.000000000 +0100
@@ -3,185 +3,179 @@
use strict;
use warnings;
-# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.013
+# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.020
use Test::More tests => 1;
use ExtUtils::MakeMaker;
-use File::Spec::Functions;
-use List::Util qw/max/;
-use version;
+use File::Spec;
+
+# from $version::LAX
+my $lax_version_re =
+ qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )?
+ |
+ (?:\.[0-9]+) (?:_[0-9]+)?
+ ) | (?:
+ v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )?
+ |
+ (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)?
+ )
+ )/x;
# hide optional CPAN::Meta modules from prereq scanner
# and check if they are available
my $cpan_meta = "CPAN::Meta";
-my $cpan_meta_req = "CPAN::Meta::Requirements";
-my $HAS_CPAN_META = eval "require $cpan_meta"; ## no critic
-my $HAS_CPAN_META_REQ = eval "require $cpan_meta_req; $cpan_meta_req->VERSION('2.120900')";
+my $cpan_meta_pre = "CPAN::Meta::Prereqs";
+my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic
# Verify requirements?
my $DO_VERIFY_PREREQS = 1;
-sub _merge_requires {
+sub _max {
+ my $max = shift;
+ $max = ( $_ > $max ) ? $_ : $max for @_;
+ return $max;
+}
+
+sub _merge_prereqs {
my ($collector, $prereqs) = @_;
- for my $phase ( qw/configure build test runtime develop/ ) {
- next unless exists $prereqs->{$phase};
- if ( my $req = $prereqs->{$phase}{'requires'} ) {
- my $cmr = CPAN::Meta::Requirements->from_string_hash( $req );
- $collector->add_requirements( $cmr );
+
+ # CPAN::Meta::Prereqs object
+ if (ref $collector eq $cpan_meta_pre) {
+ return $collector->with_merged_prereqs(
+ CPAN::Meta::Prereqs->new( $prereqs )
+ );
+ }
+
+ # Raw hashrefs
+ for my $phase ( keys %$prereqs ) {
+ for my $type ( keys %{ $prereqs->{$phase} } ) {
+ for my $module ( keys %{ $prereqs->{$phase}{$type} } ) {
+ $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module};
+ }
}
}
+
+ return $collector;
}
-my %include = map {; $_ => 1 } qw(
+my @include = qw(
);
-my %exclude = map {; $_ => 1 } qw(
+my @exclude = qw(
);
# Add static prereqs to the included modules list
-my $static_prereqs = do { my $x = {
- 'configure' => {
- 'requires' => {
- 'ExtUtils::MakeMaker' => '6.17'
- }
- },
- 'develop' => {
- 'requires' => {
- 'Dist::Zilla' => '5',
- 'Dist::Zilla::Plugin::OnlyCorePrereqs' => '0.003',
- 'Dist::Zilla::Plugin::PerlVersionPrereqs' => '0',
- 'Dist::Zilla::Plugin::Prereqs' => '0',
- 'Dist::Zilla::Plugin::RemovePrereqs' => '0',
- 'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.052',
- 'File::Spec' => '0',
- 'File::Temp' => '0',
- 'IO::Handle' => '0',
- 'IPC::Open3' => '0',
- 'Pod::Coverage::TrustPod' => '0',
- 'Test::CPAN::Meta' => '0',
- 'Test::More' => '0',
- 'Test::Pod' => '1.41',
- 'Test::Pod::Coverage' => '1.08',
- 'Test::Spelling' => '0.12'
- }
- },
- 'runtime' => {
- 'requires' => {
- 'Carp' => '0',
- 'perl' => '5.006',
- 'strict' => '0',
- 'warnings' => '0'
- }
- },
- 'test' => {
- 'recommends' => {
- 'CPAN::Meta' => '0',
- 'CPAN::Meta::Requirements' => '2.120900',
- 'Test::FailWarnings' => '0'
- },
- 'requires' => {
- 'Exporter' => '0',
- 'ExtUtils::MakeMaker' => '0',
- 'File::Spec::Functions' => '0',
- 'List::Util' => '0',
- 'Test::More' => '0.96',
- 'base' => '0',
- 'lib' => '0',
- 'subs' => '0',
- 'version' => '0'
- }
- }
- };
- $x;
- };
-
-delete $static_prereqs->{develop} if not $ENV{AUTHOR_TESTING};
-$include{$_} = 1 for map { keys %$_ } map { values %$_ } values %$static_prereqs;
-
-# Merge requirements for major phases (if we can)
-my $all_requires;
-if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META_REQ ) {
- $all_requires = $cpan_meta_req->new;
- _merge_requires($all_requires, $static_prereqs);
-}
+my $static_prereqs = do 't/00-report-prereqs.dd';
+# Merge all prereqs (either with ::Prereqs or a hashref)
+my $full_prereqs = _merge_prereqs(
+ ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ),
+ $static_prereqs
+);
# Add dynamic prereqs to the included modules list (if we can)
my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml';
if ( $source && $HAS_CPAN_META ) {
- if ( my $meta = eval { CPAN::Meta->load_file($source) } ) {
- my $dynamic_prereqs = $meta->prereqs;
- delete $dynamic_prereqs->{develop} if not $ENV{AUTHOR_TESTING};
- $include{$_} = 1 for map { keys %$_ } map { values %$_ } values %$dynamic_prereqs;
-
- if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META_REQ ) {
- _merge_requires($all_requires, $dynamic_prereqs);
+ if ( my $meta = eval { CPAN::Meta->load_file($source) } ) {
+ $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs);
}
- }
}
else {
- $source = 'static metadata';
+ $source = 'static metadata';
}
-my @modules = sort grep { ! $exclude{$_} } keys %include;
-my @reports = [qw/Version Module/];
+my @full_reports;
my @dep_errors;
-my $req_hash = defined($all_requires) ? $all_requires->as_string_hash : {};
+my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs;
-for my $mod ( @modules ) {
- next if $mod eq 'perl';
- my $file = $mod;
- $file =~ s{::}{/}g;
- $file .= ".pm";
- my ($prefix) = grep { -e catfile($_, $file) } @INC;
- if ( $prefix ) {
- my $ver = MM->parse_version( catfile($prefix, $file) );
- $ver = "undef" unless defined $ver; # Newer MM should do this anyway
- push @reports, [$ver, $mod];
-
- if ( $DO_VERIFY_PREREQS && $all_requires ) {
- my $req = $req_hash->{$mod};
- if ( defined $req && length $req ) {
- if ( ! defined eval { version->parse($ver) } ) {
- push @dep_errors, "$mod version '$ver' cannot be parsed (version '$req' required)";
+# Add static includes into a fake section
+for my $mod (@include) {
+ $req_hash->{other}{modules}{$mod} = 0;
+}
+
+for my $phase ( qw(configure build test runtime develop other) ) {
+ next unless $req_hash->{$phase};
+ next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING});
+
+ for my $type ( qw(requires recommends suggests conflicts modules) ) {
+ next unless $req_hash->{$phase}{$type};
+
+ my $title = ucfirst($phase).' '.ucfirst($type);
+ my @reports = [qw/Module Want Have/];
+
+ for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) {
+ next if $mod eq 'perl';
+ next if grep { $_ eq $mod } @exclude;
+
+ my $file = $mod;
+ $file =~ s{::}{/}g;
+ $file .= ".pm";
+ my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC;
+
+ my $want = $req_hash->{$phase}{$type}{$mod};
+ $want = "undef" unless defined $want;
+ $want = "any" if !$want && $want == 0;
+
+ my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required";
+
+ if ($prefix) {
+ my $have = MM->parse_version( File::Spec->catfile($prefix, $file) );
+ $have = "undef" unless defined $have;
+ push @reports, [$mod, $want, $have];
+
+ if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) {
+ if ( $have !~ /\A$lax_version_re\z/ ) {
+ push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)";
+ }
+ elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) {
+ push @dep_errors, "$mod version '$have' is not in required range '$want'";
+ }
+ }
+ }
+ else {
+ push @reports, [$mod, $want, "missing"];
+
+ if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) {
+ push @dep_errors, "$mod is not installed ($req_string)";
+ }
+ }
}
- elsif ( ! $all_requires->accepts_module( $mod => $ver ) ) {
- push @dep_errors, "$mod version '$ver' is not in required range '$req'";
- }
- }
- }
- }
- else {
- push @reports, ["missing", $mod];
-
- if ( $DO_VERIFY_PREREQS && $all_requires ) {
- my $req = $req_hash->{$mod};
- if ( defined $req && length $req ) {
- push @dep_errors, "$mod is not installed (version '$req' required)";
- }
+ if ( @reports ) {
+ push @full_reports, "=== $title ===\n\n";
+
+ my $ml = _max( map { length $_->[0] } @reports );
+ my $wl = _max( map { length $_->[1] } @reports );
+ my $hl = _max( map { length $_->[2] } @reports );
+
+ if ($type eq 'modules') {
+ splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl];
+ push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports;
+ }
+ else {
+ splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl];
+ push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports;
+ }
+
+ push @full_reports, "\n";
+ }
}
- }
}
-if ( @reports ) {
- my $vl = max map { length $_->[0] } @reports;
- my $ml = max map { length $_->[1] } @reports;
- splice @reports, 1, 0, ["-" x $vl, "-" x $ml];
- diag "\nVersions for all modules listed in $source (including optional ones):\n",
- map {sprintf(" %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @reports;
+if ( @full_reports ) {
+ diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports;
}
if ( @dep_errors ) {
- diag join("\n",
- "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n",
- "The following REQUIRED prerequisites were not satisfied:\n",
- @dep_errors,
- "\n"
- );
+ diag join("\n",
+ "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n",
+ "The following REQUIRED prerequisites were not satisfied:\n",
+ @dep_errors,
+ "\n"
+ );
}
pass;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/xt/author/00-compile.t new/Class-Tiny-1.001/xt/author/00-compile.t
--- old/Class-Tiny-1.000/xt/author/00-compile.t 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/xt/author/00-compile.t 2015-01-31 03:13:12.000000000 +0100
@@ -2,11 +2,11 @@
use strict;
use warnings;
-# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.043
-
-use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
+# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.051
+use Test::More;
+plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
my @module_files = (
'Class/Tiny.pm'
@@ -48,6 +48,7 @@
-is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING};
+is(scalar(@warnings), 0, 'no warnings found')
+ or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Class-Tiny-1.000/xt/release/test-version.t new/Class-Tiny-1.001/xt/release/test-version.t
--- old/Class-Tiny-1.000/xt/release/test-version.t 2014-07-16 15:55:35.000000000 +0200
+++ new/Class-Tiny-1.001/xt/release/test-version.t 2015-01-31 03:13:12.000000000 +0100
@@ -2,8 +2,8 @@
use warnings;
use Test::More;
-# generated by Dist::Zilla::Plugin::Test::Version 0.002004
-BEGIN { eval "use Test::Version; 1;" or die $@; }
+# generated by Dist::Zilla::Plugin::Test::Version 0.003001
+use Test::Version;
my @imports = ( 'version_all_ok' );
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org