r42567 - in /trunk/libmoosex-types-perl: Changes MANIFEST META.yml Makefile.PL README debian/changelog lib/MooseX/Types.pm t/21_coerce_parameterized_types.t

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sun Aug 23 17:25:52 UTC 2009


Author: gregoa
Date: Sun Aug 23 17:25:46 2009
New Revision: 42567

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=42567
Log:
New upstream release

Added:
    trunk/libmoosex-types-perl/t/21_coerce_parameterized_types.t
      - copied unchanged from r42566, branches/upstream/libmoosex-types-perl/current/t/21_coerce_parameterized_types.t
Modified:
    trunk/libmoosex-types-perl/Changes
    trunk/libmoosex-types-perl/MANIFEST
    trunk/libmoosex-types-perl/META.yml
    trunk/libmoosex-types-perl/Makefile.PL
    trunk/libmoosex-types-perl/README
    trunk/libmoosex-types-perl/debian/changelog
    trunk/libmoosex-types-perl/lib/MooseX/Types.pm

Modified: trunk/libmoosex-types-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-types-perl/Changes?rev=42567&op=diff
==============================================================================
--- trunk/libmoosex-types-perl/Changes (original)
+++ trunk/libmoosex-types-perl/Changes Sun Aug 23 17:25:46 2009
@@ -1,4 +1,7 @@
 Revision history for MooseX-Types
+
+0.18    Sat Aug 22 12:50:42 EDT 2009
+        - fix coercions on parameterized types (Hans Dieter Pearcey).
 
 0.17    Tue Aug 18 02:32:31 EDT 2009
         - Documentation typo fix (Dave Rolsky).

Modified: trunk/libmoosex-types-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-types-perl/MANIFEST?rev=42567&op=diff
==============================================================================
--- trunk/libmoosex-types-perl/MANIFEST (original)
+++ trunk/libmoosex-types-perl/MANIFEST Sun Aug 23 17:25:46 2009
@@ -35,6 +35,7 @@
 t/18_combined_libs.t
 t/19_typelib_with_role.t
 t/20_union_with_string_type.t
+t/21_coerce_parameterized_types.t
 t/lib/Combined.pm
 t/lib/DecoratorLibrary.pm
 t/lib/IntrospectTypeExports.pm

Modified: trunk/libmoosex-types-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-types-perl/META.yml?rev=42567&op=diff
==============================================================================
--- trunk/libmoosex-types-perl/META.yml (original)
+++ trunk/libmoosex-types-perl/META.yml Sun Aug 23 17:25:46 2009
@@ -5,6 +5,7 @@
 build_requires:
   ExtUtils::MakeMaker: 6.42
   FindBin: 0
+  Test::Exception: 0
   Test::Moose: 0
   Test::More: 0.80
 configure_requires:
@@ -23,7 +24,7 @@
 provides:
   MooseX::Types:
     file: lib/MooseX/Types.pm
-    version: 0.17
+    version: 0.18
   MooseX::Types::Base:
     file: lib/MooseX/Types/Base.pm
   MooseX::Types::CheckedUtilExports:
@@ -51,4 +52,4 @@
   perl: 5.8.0
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.17
+version: 0.18

Modified: trunk/libmoosex-types-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-types-perl/Makefile.PL?rev=42567&op=diff
==============================================================================
--- trunk/libmoosex-types-perl/Makefile.PL (original)
+++ trunk/libmoosex-types-perl/Makefile.PL Sun Aug 23 17:25:46 2009
@@ -12,6 +12,7 @@
 build_requires  q{Test::More},                  '0.80';
 build_requires  q{FindBin},                     0;
 build_requires  q{Test::Moose},                 0;
+build_requires  q{Test::Exception},             0;
 
 requires        q{Moose},                       '0.61';
 requires        q{Sub::Install},                '0.924';

Modified: trunk/libmoosex-types-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-types-perl/README?rev=42567&op=diff
==============================================================================
--- trunk/libmoosex-types-perl/README (original)
+++ trunk/libmoosex-types-perl/README Sun Aug 23 17:25:46 2009
@@ -11,6 +11,7 @@
             PositiveInt NegativeInt
             ArrayRefOfPositiveInt ArrayRefOfAtLeastThreeNegativeInts
             LotsOfInnerConstraints StrOrArrayRef
+            MyDateTime
         )];
 
       # import builtin types
@@ -21,8 +22,8 @@
           as Int, 
           where { $_ > 0 },
           message { "Int is not larger than 0" };
-      
-  subtype NegativeInt,
+  
+      subtype NegativeInt,
           as Int,
           where { $_ < 0 },
           message { "Int is not smaller than 0" };
@@ -33,25 +34,31 @@
               via { 1 };
 
       # with parameterized constraints.
-      
-  subtype ArrayRefOfPositiveInt,
+  
+      subtype ArrayRefOfPositiveInt,
         as ArrayRef[PositiveInt];
-        
-  subtype ArrayRefOfAtLeastThreeNegativeInts,
+    
+      subtype ArrayRefOfAtLeastThreeNegativeInts,
         as ArrayRef[NegativeInt],
         where { scalar(@$_) > 2 };
 
       subtype LotsOfInnerConstraints,
         as ArrayRef[ArrayRef[HashRef[Int]]];
-        
-  # with TypeConstraint Unions
-      
-  subtype StrOrArrayRef,
+    
+      # with TypeConstraint Unions
+  
+      subtype StrOrArrayRef,
         as Str|ArrayRef;
 
+      # class types
+
       class_type 'DateTime';
 
-      coerce 'DateTime',
+      # or better
+
+      class_type MyDateTime, { class => 'DateTime' };
+
+      coerce MyDateTime,
         from HashRef,
         via { DateTime->new(%$_) };
 
@@ -252,8 +259,8 @@
 
         use Moose;
         use MooseX::Types::Moose qw(HashRef Int);
-        
-    has 'attr' => (isa=>HashRef|Int);
+    
+        has 'attr' => (isa=>HashRef|Int);
 
     And everything should just work as you'd think.
 
@@ -324,21 +331,21 @@
     additional export targets. For example if you do:
 
         package TypeAndSubExporter; {
-            
-        use MooseX::Types::Moose qw(Str);
+        
+            use MooseX::Types::Moose qw(Str);
             use MooseX::Types -declare => [qw(MyStr)];
             use Sub::Exporter -setup => { exports => [ qw(something) ] };
-            
-        subtype MyStr,
+        
+            subtype MyStr,
              as Str;
-             
-        sub something {
+         
+            sub something {
                 return 1;
             }    
-            
-    } 1;
         
-    package Foo; {
+        } 1;
+    
+        package Foo; {
             use TypeAndSubExporter qw(MyStr);
         } 1;
 
@@ -370,6 +377,8 @@
 
     rafl: Florian Ragwitz <rafl at debian.org>
 
+    hdp: Hans Dieter Pearcey <hdp at cpan.org>
+
 COPYRIGHT & LICENSE
     Copyright (c) 2007-2009 Robert Sedlacek
 

Modified: trunk/libmoosex-types-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-types-perl/debian/changelog?rev=42567&op=diff
==============================================================================
--- trunk/libmoosex-types-perl/debian/changelog (original)
+++ trunk/libmoosex-types-perl/debian/changelog Sun Aug 23 17:25:46 2009
@@ -1,5 +1,6 @@
-libmoosex-types-perl (0.17-1) unstable; urgency=low
+libmoosex-types-perl (0.18-1) unstable; urgency=low
 
+  [ Jonathan Yu ]
   * New upstream release
     + Fix for has_available_type_export if the introspected code symbol
       exists but is not a type export
@@ -7,6 +8,9 @@
   * Remove versioned dependency on libnamespace-clean-perl (version in
     stable is 0.08, which meets this requirement)
   * Updated copyright information
+
+  [ gregor herrmann ]
+  * New upstream release
 
  -- Jonathan Yu <frequency at cpan.org>  Fri, 21 Aug 2009 12:17:24 -0400
 

Modified: trunk/libmoosex-types-perl/lib/MooseX/Types.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-types-perl/lib/MooseX/Types.pm?rev=42567&op=diff
==============================================================================
--- trunk/libmoosex-types-perl/lib/MooseX/Types.pm (original)
+++ trunk/libmoosex-types-perl/lib/MooseX/Types.pm Sun Aug 23 17:25:46 2009
@@ -20,7 +20,7 @@
 use namespace::clean -except => [qw( meta )];
 
 use 5.008;
-our $VERSION = '0.17';
+our $VERSION = '0.18';
 my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'};
 
 =head1 SYNOPSIS
@@ -35,6 +35,7 @@
         PositiveInt NegativeInt
         ArrayRefOfPositiveInt ArrayRefOfAtLeastThreeNegativeInts
         LotsOfInnerConstraints StrOrArrayRef
+	MyDateTime
     )];
 
   # import builtin types
@@ -73,9 +74,15 @@
   subtype StrOrArrayRef,
     as Str|ArrayRef;
 
+  # class types
+
   class_type 'DateTime';
 
-  coerce 'DateTime',
+  # or better
+
+  class_type MyDateTime, { class => 'DateTime' };
+
+  coerce MyDateTime,
     from HashRef,
     via { DateTime->new(%$_) };
 
@@ -420,7 +427,16 @@
 sub create_arged_type_constraint {
     my ($class, $name, @args) = @_;  
     my $type_constraint = Moose::Util::TypeConstraints::find_or_create_type_constraint("$name");
-	return $type_constraint->parameterize(@args);
+    my $parameterized = $type_constraint->parameterize(@args);
+    # It's obnoxious to have to parameterize before looking for the TC, but the
+    # alternative is to hard-code the assumption that the name is
+    # "$name[$args[0]]", which would be worse.
+    if (my $existing =
+        Moose::Util::TypeConstraints::find_type_constraint($parameterized->name)) {
+        return $existing;
+    }
+    Moose::Util::TypeConstraints::register_type_constraint($parameterized);
+    return $parameterized;
 }
 
 =head2 create_base_type_constraint ($name)
@@ -577,6 +593,8 @@
 
 rafl: Florian Ragwitz <rafl at debian.org>
 
+hdp: Hans Dieter Pearcey <hdp at cpan.org>
+
 =head1 COPYRIGHT & LICENSE
 
 Copyright (c) 2007-2009 Robert Sedlacek




More information about the Pkg-perl-cvs-commits mailing list