Hello community,
here is the log from the commit of package perl-MooseX-Types for openSUSE:Factory checked in at 2012-05-31 17:08:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-MooseX-Types (Old)
and /work/SRC/openSUSE:Factory/.perl-MooseX-Types.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-MooseX-Types", Maintainer is ""
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-MooseX-Types/perl-MooseX-Types.changes 2012-03-05 14:02:53.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.perl-MooseX-Types.new/perl-MooseX-Types.changes 2012-05-31 17:08:52.000000000 +0200
@@ -1,0 +2,14 @@
+Wed May 30 12:27:14 UTC 2012 - coolo@suse.com
+
+- updated to 0.35
+ - The new delegation code could fail when a type had no
+ parent. Attempting to subtype Any was one way to trigger the
+ bug. (Dave Rolsky)
+ - The new delegation code broke calling ->can or ->isa on
+ MooseX::Types::TypeDecorator as a class method. (Dave Rolsky)
+ - Special case new to avoid unexpected exceptions on unloaded classes
+ - Switch delegation order to prioritise type over class except for new
+ - Support delegation of methods to the class for class types
+ - Factor out _try_delegate method
+
+-------------------------------------------------------------------
Old:
----
MooseX-Types-0.31.tar.gz
New:
----
MooseX-Types-0.35.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-MooseX-Types.spec ++++++
--- /var/tmp/diff_new_pack.XV6U4o/_old 2012-05-31 17:08:53.000000000 +0200
+++ /var/tmp/diff_new_pack.XV6U4o/_new 2012-05-31 17:08:53.000000000 +0200
@@ -16,86 +16,100 @@
#
-%if 0%{?suse_version} < 1119
-%define with_test 1
-%endif
-
Name: perl-MooseX-Types
-Version: 0.31
+Version: 0.35
Release: 0
+%define cpan_name MooseX-Types
Summary: Organise your Moose types in libraries
License: Artistic-1.0 or GPL-1.0+
Group: Development/Libraries/Perl
-Source: ftp://ftp.cpan.org/pub/CPAN/authors/id/D/DR/DROLSKY/MooseX-Types-%{version}.tar.gz
-Url: http://search.cpan.org/dist/MooseX-Types
+Url: http://search.cpan.org/dist/MooseX-Types/
+Source: http://www.cpan.org/authors/id/D/DR/DROLSKY/%{cpan_name}-%{version}.tar.gz
+BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-%{perl_requires}
-BuildRequires: make
BuildRequires: perl
BuildRequires: perl-macros
-%if 0%{?with_test}
-BuildRequires: perl(Test::More) >= 0.80
-BuildRequires: perl(Test::Requires)
+BuildRequires: perl(Carp::Clan) >= 6.00
+BuildRequires: perl(Moose) >= 1.06
+BuildRequires: perl(Sub::Install) >= 0.924
+BuildRequires: perl(Sub::Name)
BuildRequires: perl(Test::Fatal)
BuildRequires: perl(Test::Moose)
-%endif
-BuildRequires: perl(FindBin)
-BuildRequires: perl(ExtUtils::MakeMaker) >= 6.42
-BuildRequires: perl(Scalar::Util) >= 1.19
-BuildRequires: perl(Sub::Name)
-BuildRequires: perl(Carp)
+BuildRequires: perl(Test::More) >= 0.88
+BuildRequires: perl(Test::Requires)
BuildRequires: perl(namespace::clean) >= 0.19
-BuildRequires: perl(Sub::Install) >= 0.924
-BuildRequires: perl(Carp::Clan) >= 6.00
-BuildRequires: perl(Moose) >= 1.06
-Requires: perl(Scalar::Util) >= 1.19
-Requires: perl(Sub::Name)
-Requires: perl(Carp)
-Requires: perl(namespace::clean) >= 0.19
-Requires: perl(Sub::Install) >= 0.924
+#BuildRequires: perl(Class::MOP)
+#BuildRequires: perl(DecoratorLibrary)
+#BuildRequires: perl(IntrospectTypeExports)
+#BuildRequires: perl(Moose::Exporter)
+#BuildRequires: perl(Moose::Meta::TypeConstraint::Union)
+#BuildRequires: perl(Moose::Role)
+#BuildRequires: perl(Moose::Util::TypeConstraints)
+#BuildRequires: perl(MooseX::Types)
+#BuildRequires: perl(MooseX::Types::Base)
+#BuildRequires: perl(MooseX::Types::CheckedUtilExports)
+#BuildRequires: perl(MooseX::Types::Combine)
+#BuildRequires: perl(MooseX::Types::Moose)
+#BuildRequires: perl(MooseX::Types::TypeDecorator)
+#BuildRequires: perl(MooseX::Types::UndefinedType)
+#BuildRequires: perl(MooseX::Types::Util)
+#BuildRequires: perl(MooseX::Types::Wrapper)
+#BuildRequires: perl(Sub::Exporter)
+#BuildRequires: perl(SubExporterCompatibility)
+#BuildRequires: perl(TestLibrary)
+#BuildRequires: perl(TestNamespaceSep)
+#BuildRequires: perl(Test::Spelling)
+#BuildRequires: perl(TestWrapper)
Requires: perl(Carp::Clan) >= 6.00
Requires: perl(Moose) >= 1.06
+Requires: perl(Sub::Install) >= 0.924
+Requires: perl(Sub::Name)
+Requires: perl(namespace::clean) >= 0.19
+%{perl_requires}
%description
-The types provided with Moose are by design global. This package helps you
-to organise and selectively import your own and the built-in types in
-libraries. As a nice side effect, it catches typos at compile-time too.
-However, the main reason for this module is to provide an easy way to not
-have conflicts with your type names, since the internal fully qualified
-names of the types will be prefixed with the library's name.
-This module will also provide you with some helper functions to make it
-easier to use Moose types in your code.
+The type system provided by Moose effectively makes all of its builtin type
+global, as are any types you declare with Moose. This means that every
+module that declares a type named "PositiveInt" is sharing the same type
+object. This can be a problem when different parts of the code base want to
+use the same name for different things.
+
+This package lets you declare types using short names, but behind the
+scenes it namespaces all your type declarations, effectively prevent name
+clashes between packages.
+
+This is done by creating a type library module like 'MyApp::Types' and then
+importing types from that module into other modules.
+
+As a side effect, the declaration mechanism allows you to write type names
+as barewords (really function calls), which catches typos in names at
+compile time rather than run time.
+
+This module also provides some helper functions for using Moose types
+outside of attribute declarations.
+
+If you mix string-based names with types created by this module, it will
+warn, with a few exceptions. If you are declaring a 'class_type()' or
+'role_type()' within your type library, or if you use a fully qualified
+name like '"MyApp::Foo"'.
%prep
-%setup -q -n "MooseX-Types-%{version}"
-%__sed -i '/^auto_install/d' Makefile.PL
+%setup -q -n %{cpan_name}-%{version}
%build
-%__perl Makefile.PL PREFIX="%{_prefix}"
-%__make %{?_smp_flags}
+%{__perl} Makefile.PL INSTALLDIRS=vendor
+%{__make} %{?_smp_mflags}
+
+%check
+%{__make} test
%install
%perl_make_install
%perl_process_packlist
+%perl_gen_filelist
-%if 0%{?with_test}
-
-%check
-%__make test
-%endif
-
-%clean
-%{?buildroot:%__rm -rf "%{buildroot}"}
-
-%files
-%defattr(-,root,root)
-%doc Changes README
-%dir %{perl_vendorlib}/MooseX
-%{perl_vendorlib}/MooseX/Types.pm
-%{perl_vendorlib}/MooseX/Types
-%dir %{perl_vendorarch}/auto/MooseX
-%{perl_vendorarch}/auto/MooseX/Types
-%doc %{perl_man3dir}/MooseX::Types.%{perl_man3ext}%{ext_man}
-%doc %{perl_man3dir}/MooseX::Types::*.%{perl_man3ext}%{ext_man}
+%files -f %{name}.files
+%defattr(-,root,root,755)
+%doc Changes LICENSE README
%changelog
++++++ MooseX-Types-0.31.tar.gz -> MooseX-Types-0.35.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/Changes new/MooseX-Types-0.35/Changes
--- old/MooseX-Types-0.31/Changes 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/Changes 2012-05-19 07:43:55.000000000 +0200
@@ -1,5 +1,27 @@
Revision history for MooseX-Types
+0.35 2012-05-19
+
+ - The new delegation code could fail when a type had no
+ parent. Attempting to subtype Any was one way to trigger the
+ bug. (Dave Rolsky)
+
+ - The new delegation code broke calling ->can or ->isa on
+ MooseX::Types::TypeDecorator as a class method. (Dave Rolsky)
+
+0.34 2012-05-18
+
+ - Special case new to avoid unexpected exceptions on unloaded classes
+
+0.33 2012-05-18
+
+ - Switch delegation order to prioritise type over class except for new
+
+0.32 2012-05-18
+
+ - Support delegation of methods to the class for class types
+ - Factor out _try_delegate method
+
0.31 2011-12-22
- Add support for qw( :all ) on MooseX::Types::Combine libraries. (kentnl)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/LICENSE new/MooseX-Types-0.35/LICENSE
--- old/MooseX-Types-0.31/LICENSE 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/LICENSE 2012-05-19 07:43:55.000000000 +0200
@@ -1,4 +1,4 @@
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
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) 2011 by Robert "phaylon" Sedlacek.
+This software is Copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software, licensed under:
@@ -272,7 +272,7 @@
--- The Artistic License 1.0 ---
-This software is Copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is Copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software, licensed under:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/MANIFEST new/MooseX-Types-0.35/MANIFEST
--- old/MooseX-Types-0.31/MANIFEST 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/MANIFEST 2012-05-19 07:43:55.000000000 +0200
@@ -28,6 +28,9 @@
t/19_typelib_with_role.t
t/20_union_with_string_type.t
t/21_coerce_parameterized_types.t
+t/22_class_type.t
+t/23_any_subtype.t
+t/24_class_can_isa.t
t/lib/Combined.pm
t/lib/DecoratorLibrary.pm
t/lib/Empty.pm
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/META.json new/MooseX-Types-0.35/META.json
--- old/MooseX-Types-0.31/META.json 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/META.json 2012-05-19 07:43:55.000000000 +0200
@@ -4,7 +4,7 @@
"Robert \"phaylon\" Sedlacek "
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 4.300005, CPAN::Meta::Converter version 2.112150",
+ "generated_by" : "Dist::Zilla version 4.300015, CPAN::Meta::Converter version 2.120900",
"license" : [
"perl_5"
],
@@ -16,11 +16,11 @@
"prereqs" : {
"build" : {
"requires" : {
- "FindBin" : 0,
- "Test::Fatal" : 0,
- "Test::Moose" : 0,
+ "FindBin" : "0",
+ "Test::Fatal" : "0",
+ "Test::Moose" : "0",
"Test::More" : "0.88",
- "Test::Requires" : 0
+ "Test::Requires" : "0"
}
},
"configure" : {
@@ -30,12 +30,12 @@
},
"runtime" : {
"requires" : {
- "Carp" : 0,
+ "Carp" : "0",
"Carp::Clan" : "6.00",
"Moose" : "1.06",
"Scalar::Util" : "1.19",
"Sub::Install" : "0.924",
- "Sub::Name" : 0,
+ "Sub::Name" : "0",
"namespace::clean" : "0.19",
"perl" : "v5.8.0"
}
@@ -53,6 +53,6 @@
"web" : "http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/MooseX-Types.git;a=summ..."
}
},
- "version" : "0.31"
+ "version" : "0.35"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/META.yml new/MooseX-Types-0.35/META.yml
--- old/MooseX-Types-0.31/META.yml 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/META.yml 2012-05-19 07:43:55.000000000 +0200
@@ -11,7 +11,7 @@
configure_requires:
ExtUtils::MakeMaker: 6.30
dynamic_config: 0
-generated_by: 'Dist::Zilla version 4.300005, CPAN::Meta::Converter version 2.112150'
+generated_by: 'Dist::Zilla version 4.300015, CPAN::Meta::Converter version 2.120900'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -29,4 +29,4 @@
resources:
bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Types
repository: git://git.moose.perl.org/MooseX-Types.git
-version: 0.31
+version: 0.35
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/Makefile.PL new/MooseX-Types-0.35/Makefile.PL
--- old/MooseX-Types-0.31/Makefile.PL 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/Makefile.PL 2012-05-19 07:43:55.000000000 +0200
@@ -34,7 +34,7 @@
"Sub::Name" => 0,
"namespace::clean" => "0.19"
},
- "VERSION" => "0.31",
+ "VERSION" => "0.35",
"test" => {
"TESTS" => "t/*.t t/regressions/*.t"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/README new/MooseX-Types-0.35/README
--- old/MooseX-Types-0.31/README 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/README 2012-05-19 07:43:55.000000000 +0200
@@ -1,11 +1,11 @@
This archive contains the distribution MooseX-Types,
-version 0.31:
+version 0.35:
Organise your Moose types in libraries
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/dist.ini new/MooseX-Types-0.35/dist.ini
--- old/MooseX-Types-0.31/dist.ini 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/dist.ini 2012-05-19 07:43:55.000000000 +0200
@@ -3,7 +3,7 @@
license = Perl_5
copyright_holder = Robert "phaylon" Sedlacek
-version = 0.31
+version = 0.35
[NextRelease]
format = %-7v %{yyyy-MM-dd}d
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/Base.pm new/MooseX-Types-0.35/lib/MooseX/Types/Base.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/Base.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/Base.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::Base;
{
- $MooseX::Types::Base::VERSION = '0.31';
+ $MooseX::Types::Base::VERSION = '0.35';
}
use Moose;
@@ -209,7 +209,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 DESCRIPTION
@@ -286,7 +286,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/CheckedUtilExports.pm new/MooseX-Types-0.35/lib/MooseX/Types/CheckedUtilExports.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/CheckedUtilExports.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/CheckedUtilExports.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::CheckedUtilExports;
{
- $MooseX::Types::CheckedUtilExports::VERSION = '0.31';
+ $MooseX::Types::CheckedUtilExports::VERSION = '0.35';
}
#ABSTRACT: Wrap LMoose::Util::TypeConstraints to be safer for LMooseX::Types
@@ -70,7 +70,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 DESCRIPTION
@@ -109,7 +109,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/Combine.pm new/MooseX-Types-0.35/lib/MooseX/Types/Combine.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/Combine.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/Combine.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::Combine;
{
- $MooseX::Types::Combine::VERSION = '0.31';
+ $MooseX::Types::Combine::VERSION = '0.35';
}
# ABSTRACT: Combine type libraries for exporting
@@ -94,7 +94,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 SYNOPSIS
@@ -136,7 +136,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/Moose.pm new/MooseX-Types-0.35/lib/MooseX/Types/Moose.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/Moose.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/Moose.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::Moose;
{
- $MooseX::Types::Moose::VERSION = '0.31';
+ $MooseX::Types::Moose::VERSION = '0.35';
}
# ABSTRACT: Type exports that match the types shipped with L<Moose>
@@ -35,7 +35,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 SYNOPSIS
@@ -91,7 +91,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/TypeDecorator.pm new/MooseX-Types-0.35/lib/MooseX/Types/TypeDecorator.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/TypeDecorator.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/TypeDecorator.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::TypeDecorator;
{
- $MooseX::Types::TypeDecorator::VERSION = '0.31';
+ $MooseX::Types::TypeDecorator::VERSION = '0.35';
}
#ABSTRACT: Wraps Moose::Meta::TypeConstraint objects with added features
@@ -57,7 +57,11 @@
sub new {
- my $class = shift @_;
+ my $proto = shift;
+ if (ref($proto)) {
+ return $proto->_try_delegate('new', @_);
+ }
+ my $class = $proto;
if(my $arg = shift @_) {
if(blessed $arg && $arg->isa('Moose::Meta::TypeConstraint')) {
return bless {'__type_constraint'=>$arg}, $class;
@@ -92,39 +96,21 @@
sub isa {
- my ($self, $target) = @_;
- if(defined $target) {
- if(blessed $self) {
- return $self->__type_constraint->isa($target);
- } else {
- return;
- }
- } else {
- return;
- }
+ my $self = shift;
+ return
+ blessed $self
+ ? $self->__type_constraint->isa(@_)
+ || $self->_try_delegate( 'isa', @_ )
+ : $self->SUPER::isa(@_);
}
-
sub can {
- my ($self, $target) = @_;
- if(defined $target) {
- if(blessed $self) {
- return $self->__type_constraint->can($target);
- } else {
- return;
- }
- } else {
- return;
- }
-}
-
+ my $self = shift;
-sub meta {
- my $self = shift @_;
- if(blessed $self) {
- return $self->__type_constraint->meta;
- }
+ return blessed $self
+ ? $self->_try_delegate( 'can', @_ )
+ : $self->SUPER::can(@_);
}
@@ -142,22 +128,49 @@
sub AUTOLOAD {
-
my ($self, @args) = @_;
my ($method) = (our $AUTOLOAD =~ /([^:]+)$/);
## We delegate with this method in an attempt to support a value of
## __type_constraint which is also AUTOLOADing, in particular the class
## MooseX::Types::UndefinedType which AUTOLOADs during autovivication.
-
- my $return;
- eval {
- $return = $self->__type_constraint->$method(@args);
- }; if($@) {
- __PACKAGE__->_throw_error($@);
- } else {
- return $return;
+
+ $self->_try_delegate($method, @args);
+}
+
+sub _try_delegate {
+ my ($self, $method, @args) = @_;
+ my $tc = $self->__type_constraint;
+ my $class;
+ if ($tc->can('is_subtype_of')) { # Union can't
+ my $search_tc = $tc;
+ while (1) {
+ if ($search_tc->isa('Moose::Meta::TypeConstraint::Class')) {
+ $class = $search_tc->class;
+ last;
+ }
+ $search_tc = $search_tc->parent;
+ last unless $search_tc && $search_tc->is_subtype_of('Object');
+ }
}
+
+ my $inv = do {
+ if ($method eq 'new') {
+ die "new called on type decorator for non-class-type ".$tc->name
+ unless $class;
+ die "new called on class type decorator ".$tc->name."\n"
+ ." for class ${class}\n"
+ ." which does not provide a new method - did you forget to load it?"
+ unless $class->can('new');
+ $class
+ } elsif ($class && !$tc->can($method)) {
+ $class
+ } else {
+ $tc
+ }
+ };
+
+ $inv->$method(@args);
}
@@ -172,7 +185,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 DESCRIPTION
@@ -193,16 +206,13 @@
=head2 isa
-handle $self->isa since AUTOLOAD can't.
+handle $self->isa since AUTOLOAD can't - this tries both the type constraint,
+and for a class type, the class.
=head2 can
handle $self->can since AUTOLOAD can't.
-=head2 meta
-
-have meta examine the underlying type constraints
-
=head2 _throw_error
properly delegate error messages
@@ -213,7 +223,11 @@
=head2 AUTOLOAD
-Delegate to the decorator target.
+Delegate to the decorator target, unless this is a class type, in which
+case it will try to delegate to the type object, then if that fails try
+the class. The method 'new' is special cased to only be permitted on
+the class; if there is no class, or it does not provide a new method,
+an exception will be thrown.
=head1 LICENSE
@@ -226,7 +240,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/UndefinedType.pm new/MooseX-Types-0.35/lib/MooseX/Types/UndefinedType.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/UndefinedType.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/UndefinedType.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::UndefinedType;
{
- $MooseX::Types::UndefinedType::VERSION = '0.31';
+ $MooseX::Types::UndefinedType::VERSION = '0.35';
}
use warnings;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/Util.pm new/MooseX-Types-0.35/lib/MooseX/Types/Util.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/Util.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/Util.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::Util;
{
- $MooseX::Types::Util::VERSION = '0.31';
+ $MooseX::Types::Util::VERSION = '0.35';
}
#ABSTRACT: Common utility functions for the distribution
@@ -53,7 +53,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 DESCRIPTION
@@ -119,7 +119,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types/Wrapper.pm new/MooseX-Types-0.35/lib/MooseX/Types/Wrapper.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types/Wrapper.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types/Wrapper.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types::Wrapper;
{
- $MooseX::Types::Wrapper::VERSION = '0.31';
+ $MooseX::Types::Wrapper::VERSION = '0.35';
}
#ABSTRACT: Wrap exports from a library
@@ -48,7 +48,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 DESCRIPTION
@@ -73,7 +73,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/lib/MooseX/Types.pm new/MooseX-Types-0.35/lib/MooseX/Types.pm
--- old/MooseX-Types-0.31/lib/MooseX/Types.pm 2011-12-23 00:43:56.000000000 +0100
+++ new/MooseX-Types-0.35/lib/MooseX/Types.pm 2012-05-19 07:43:55.000000000 +0200
@@ -1,6 +1,6 @@
package MooseX::Types;
{
- $MooseX::Types::VERSION = '0.31';
+ $MooseX::Types::VERSION = '0.35';
}
use Moose;
@@ -24,7 +24,7 @@
sub import {
my ($class, %args) = @_;
- my $callee = caller;
+ my $caller = caller;
# everyone should want this
strict->import;
@@ -32,7 +32,7 @@
# inject base class into new library
{ no strict 'refs';
- unshift @{ $callee . '::ISA' }, 'MooseX::Types::Base';
+ unshift @{ $caller . '::ISA' }, 'MooseX::Types::Base';
}
# generate predeclared type helpers
@@ -46,18 +46,18 @@
if $type =~ /::/;
# add type to library and remember to export
- $callee->add_type($type);
+ $caller->add_type($type);
push @to_export, $type;
}
- $callee->import({ -full => 1, -into => $callee }, @to_export);
+ $caller->import({ -full => 1, -into => $caller }, @to_export);
}
# run type constraints import
- Moose::Util::TypeConstraints->import({ into => $callee });
+ Moose::Util::TypeConstraints->import({ into => $caller });
# override some with versions that check for syntax errors
- MooseX::Types::CheckedUtilExports->import({ into => $callee });
+ MooseX::Types::CheckedUtilExports->import({ into => $caller });
1;
}
@@ -176,7 +176,7 @@
=head1 VERSION
-version 0.31
+version 0.35
=head1 SYNOPSIS
@@ -299,7 +299,7 @@
If you mix string-based names with types created by this module, it will warn,
with a few exceptions. If you are declaring a C or
-c within your type library, or if you use a fully qualified name
+C within your type library, or if you use a fully qualified name
like C<"MyApp::Foo">.
=head1 LIBRARY DEFINITION
@@ -620,7 +620,7 @@
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2011 by Robert "phaylon" Sedlacek.
+This software is copyright (c) 2012 by Robert "phaylon" Sedlacek.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/t/22_class_type.t new/MooseX-Types-0.35/t/22_class_type.t
--- old/MooseX-Types-0.31/t/22_class_type.t 1970-01-01 01:00:00.000000000 +0100
+++ new/MooseX-Types-0.35/t/22_class_type.t 2012-05-19 07:43:55.000000000 +0200
@@ -0,0 +1,56 @@
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+ package MyTypes;
+
+ use MooseX::Types::Moose qw( Item );
+ use MooseX::Types -declare => [ 'ClassyType', 'NoClass' ];
+
+ class_type 'ClassyClass';
+
+ subtype ClassyType, as 'ClassyClass';
+
+ subtype NoClass, as Item, where { 1 };
+}
+
+BEGIN {
+
+ ok(!eval { MyTypes::ClassyType->new }, 'new without class loaded explodes');
+
+ like($@, qr/does not provide/, 'right exception');
+
+ ok(!eval { MyTypes::NoClass->new }, 'new on non-class type');
+
+ like($@, qr/non-class-type/, 'right exception');
+}
+
+BEGIN {
+
+ package ClassyClass;
+
+ use Moose;
+
+ sub check { die "FAIL" }
+
+ package ClassyClassConsumer;
+
+ BEGIN { MyTypes->import('ClassyType') }
+ use Moose;
+
+ has om_nom => (
+ is => 'ro', isa => ClassyType, default => sub { ClassyType->new }
+ );
+
+}
+
+ok(my $o = ClassyClassConsumer->new, "Constructor happy");
+
+is(ref($o->om_nom), 'ClassyClass', 'Attribute happy');
+
+ok(ClassyClassConsumer->new(om_nom => ClassyClass->new), 'Constructor happy');
+
+ok(!eval { ClassyClassConsumer->new(om_nom => 3) }, 'Type checked');
+
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/t/23_any_subtype.t new/MooseX-Types-0.35/t/23_any_subtype.t
--- old/MooseX-Types-0.31/t/23_any_subtype.t 1970-01-01 01:00:00.000000000 +0100
+++ new/MooseX-Types-0.35/t/23_any_subtype.t 2012-05-19 07:43:55.000000000 +0200
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Fatal;
+
+use MooseX::Types -declare => ['Foo'];
+use MooseX::Types::Moose qw( Any );
+
+is(
+ exception { subtype Foo, as Any },
+ undef,
+ 'no exception when subtyping Any type'
+);
+
+done_testing();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MooseX-Types-0.31/t/24_class_can_isa.t new/MooseX-Types-0.35/t/24_class_can_isa.t
--- old/MooseX-Types-0.31/t/24_class_can_isa.t 1970-01-01 01:00:00.000000000 +0100
+++ new/MooseX-Types-0.35/t/24_class_can_isa.t 2012-05-19 07:43:55.000000000 +0200
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Fatal;
+
+use MooseX::Types::TypeDecorator;
+
+is(
+ exception { MooseX::Types::TypeDecorator->isa('X') },
+ undef,
+ 'no exception calling ->isa on MooseX::Types::TypeDecorator as class method'
+);
+
+is(
+ exception { MooseX::Types::TypeDecorator->can('X') },
+ undef,
+ 'no exception calling ->can on MooseX::Types::TypeDecorator as class method'
+);
+
+done_testing();
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org