r46872 - in /branches/upstream/libmoosex-types-structured-perl/current: Changes META.yml Makefile.PL README lib/MooseX/Types/Structured.pm t/12-error.t
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sat Nov 7 02:40:15 UTC 2009
Author: jawnsy-guest
Date: Sat Nov 7 02:40:07 2009
New Revision: 46872
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=46872
Log:
[svn-upgrade] Integrating new upstream version, libmoosex-types-structured-perl (0.19)
Modified:
branches/upstream/libmoosex-types-structured-perl/current/Changes
branches/upstream/libmoosex-types-structured-perl/current/META.yml
branches/upstream/libmoosex-types-structured-perl/current/Makefile.PL
branches/upstream/libmoosex-types-structured-perl/current/README
branches/upstream/libmoosex-types-structured-perl/current/lib/MooseX/Types/Structured.pm
branches/upstream/libmoosex-types-structured-perl/current/t/12-error.t
Modified: branches/upstream/libmoosex-types-structured-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-structured-perl/current/Changes?rev=46872&op=diff
==============================================================================
--- branches/upstream/libmoosex-types-structured-perl/current/Changes (original)
+++ branches/upstream/libmoosex-types-structured-perl/current/Changes Sat Nov 7 02:40:07 2009
@@ -1,4 +1,8 @@
Revision history for MooseX-Types-Structured
+
+0.19 06 November 2009
+ - Require Devel::PartialDump 0.10 and change tests to expect the
+ correct format of error.
0.18 17 August 2009
- Changed the Makefile.PL to reduce dependencies not needed by users
Modified: branches/upstream/libmoosex-types-structured-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-structured-perl/current/META.yml?rev=46872&op=diff
==============================================================================
--- branches/upstream/libmoosex-types-structured-perl/current/META.yml (original)
+++ branches/upstream/libmoosex-types-structured-perl/current/META.yml Sat Nov 7 02:40:07 2009
@@ -20,11 +20,11 @@
- inc
- t
requires:
- Devel::PartialDump: 0.07
+ Devel::PartialDump: 0.10
Moose: 0.63
MooseX::Types: 0.08
Sub::Exporter: 0.982
perl: 5.8.0
resources:
license: http://dev.perl.org/licenses/
-version: 0.18
+version: 0.19
Modified: branches/upstream/libmoosex-types-structured-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-structured-perl/current/Makefile.PL?rev=46872&op=diff
==============================================================================
--- branches/upstream/libmoosex-types-structured-perl/current/Makefile.PL (original)
+++ branches/upstream/libmoosex-types-structured-perl/current/Makefile.PL Sat Nov 7 02:40:07 2009
@@ -10,7 +10,7 @@
## Module dependencies
requires 'Moose' => '0.63';
requires 'MooseX::Types' => '0.08';
-requires 'Devel::PartialDump' => '0.07';
+requires 'Devel::PartialDump' => '0.10';
requires 'Sub::Exporter' => '0.982';
## Testing dependencies
Modified: branches/upstream/libmoosex-types-structured-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-structured-perl/current/README?rev=46872&op=diff
==============================================================================
--- branches/upstream/libmoosex-types-structured-perl/current/README (original)
+++ branches/upstream/libmoosex-types-structured-perl/current/README Sat Nov 7 02:40:07 2009
@@ -77,7 +77,7 @@
first => 'Vanessa',
middle => [1,2],
last => 'Li',
- });
+ });
And these would cause a constraint error for the 'description'
attribute:
@@ -123,7 +123,7 @@
subtype StringFollowedByInt,
as Tuple[Str,Int];
-
+
would constrain it's value to things like ['hello', 111] but ['hello',
'world'] would fail, as well as ['hello', 111, 'world'] and so on.
Here's another example:
@@ -139,12 +139,12 @@
Str, Int,
Optional[HashRef]
];
-
+
This defines a type constraint that validates values like:
['Hello', 100, {key1 => 'value1', key2 => 'value2'}];
['World', 200];
-
+
Notice that the last type constraint in the structure is optional. This
is enabled via the helper Optional type constraint, which is a variation
of the core Moose type constraint 'Maybe'. The main difference is that
@@ -153,7 +153,7 @@
validate:
StringIntOptionalHashRef->validate(['Hello Undefined', 1000, undef]);
-
+
Please note the subtle difference between undefined and null. If you
wish to allow both null and undefined, you should use the core Moose
'Maybe' type constraint instead:
@@ -188,7 +188,7 @@
This would constrain a HashRef that validates something like:
{firstname => 'Christopher', lastname => 'Parsons'};
-
+
but all the following would fail validation:
## Incorrect keys
@@ -198,7 +198,7 @@
{firstname => 'Christopher', lastname => 'Parsons', middlename => 'Allen'};
## Not a HashRef
- ['Christopher', 'Parsons'];
+ ['Christopher', 'Parsons'];
These structures can be as simple or elaborate as you wish. You can even
combine various structured, parameterized and simple constraints all
@@ -210,7 +210,7 @@
Dict[name=>Str, age=>Int],
ArrayRef[Int]
];
-
+
Which would match:
[1, {name=>'John', age=>25},[10,11,12]];
@@ -258,7 +258,7 @@
age_in_years => 39,
),
);
-
+
This method may take some additional time to setup but will give you
more flexibility. However, structured constraints are highly compatible
with this method, granting some interesting possibilities for coercion.
@@ -307,15 +307,15 @@
);
};
- has person => (isa=>MyStruct);
-
+ has person => (isa=>MyStruct);
+
This would allow you to instantiate with something like:
my $obj = MyApp::MyClass->new( person => {
full_name=>'John Napiorkowski',
age_in_years=>39,
});
-
+
Or even:
my $obj = MyApp::MyClass->new( person => {
@@ -340,7 +340,7 @@
name => Str,
total_friends => Int,
];
-
+
This will actually work BUT you have to take care that the subtype has a
structure that does not contradict the structure of it's parent. For now
the above works, but I will clarify the syntax for this at a future
@@ -390,7 +390,7 @@
age =>$age->years
}
};
-
+
And that should just work as expected. However, if there are any 'inner'
coercions, such as a coercion on 'Fullname' or on 'DateTime', that
coercion won't currently get activated.
@@ -411,7 +411,7 @@
ArrayRef[Person]
],
];
-
+
This would declare a Person subtype that contains a name and an optional
ArrayRef of Persons who are friends as in:
@@ -438,7 +438,7 @@
Str,
Str|Tuple,
];
-
+
Which validates:
[
@@ -498,7 +498,7 @@
last=>Str,
middle=>Optional[Str],
];
-
+
Creates a constraint that validates against a hashref with the keys
'first' and 'last' being strings and required while an optional key
'middle' is must be a string if it appears but doesn't have to appear.
@@ -536,7 +536,7 @@
[10,"Hello", $obj, [11,12,13,...] ]; # Notice element 4 is an ArrayRef
In order to allow structured validation of, "and then some", arguments,
- you can use the </slurpy> method against a type constraint. For example:
+ you can use the "slurpy" method against a type constraint. For example:
use MooseX::Types::Structured qw(Tuple slurpy);
@@ -551,7 +551,7 @@
This will now work as expected, validating ArrayRef structures such as:
[1,"hello", $obj, 2,3,4,5,6,...]
-
+
A few caveats apply. First, the slurpy type constraint must be the last
one in the list of type constraint parameters. Second, the parent type
of the slurpy type constraint must match that of the containing type
@@ -561,7 +561,7 @@
Dict constraints).
Please note the the technical way this works 'under the hood' is that
- the slurpy keywork transforms the target type constraint into a coderef.
+ the slurpy keyword transforms the target type constraint into a coderef.
Please do not try to create your own custom coderefs; always use the
slurpy method. The underlying technology may change in the future but
the slurpy keyword will be supported.
@@ -635,7 +635,7 @@
}};
has person => (is=>'rw', isa=>Person, coerce=>1);
-
+
And now you can instantiate with all the following:
__PACKAGE__->new(
@@ -666,7 +666,7 @@
),
},
);
-
+
This technique is a way to support various ways to instantiate your
class in a clean and declarative way.
@@ -682,17 +682,18 @@
* All POD examples need test cases in t/documentation/*.t
* Want to break out the examples section to a separate cookbook style POD.
* Want more examples and best practice / usage guidance for authors
- * Need to clarify deep coercions,
+ * Need to clarify deep coercions,
AUTHOR
- John Napiorkowski "<jjnapiork at cpan.org>"
+ John Napiorkowski <jjnapiork at cpan.org>
CONTRIBUTORS
The following people have contributed to this module and agree with the
listed Copyright & license information included below:
- Florian Ragwitz, C<< <rafl at debian.org> >>
- Yuval Kogman, C<< <nothingmuch at woobling.org> >>
+ Florian Ragwitz, <rafl at debian.org>
+ Yuval Kogman, <nothingmuch at woobling.org>
+ Tomas Doran, <bobtfish at bobtfish.net>
COPYRIGHT & LICENSE
Copyright 2008-2009, John Napiorkowski <jjnapiork at cpan.org>
Modified: branches/upstream/libmoosex-types-structured-perl/current/lib/MooseX/Types/Structured.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-structured-perl/current/lib/MooseX/Types/Structured.pm?rev=46872&op=diff
==============================================================================
--- branches/upstream/libmoosex-types-structured-perl/current/lib/MooseX/Types/Structured.pm (original)
+++ branches/upstream/libmoosex-types-structured-perl/current/lib/MooseX/Types/Structured.pm Sat Nov 7 02:40:07 2009
@@ -10,7 +10,7 @@
use Devel::PartialDump;
use Scalar::Util qw(blessed);
-our $VERSION = '0.18';
+our $VERSION = '0.19';
our $AUTHORITY = 'cpan:JJNAPIORK';
=head1 NAME
@@ -553,7 +553,7 @@
[10,"Hello", $obj, [11,12,13,...] ]; # Notice element 4 is an ArrayRef
In order to allow structured validation of, "and then some", arguments, you can
-use the </slurpy> method against a type constraint. For example:
+use the L</slurpy> method against a type constraint. For example:
use MooseX::Types::Structured qw(Tuple slurpy);
@@ -577,7 +577,7 @@
HashRef, also including other Dict constraints).
Please note the the technical way this works 'under the hood' is that the
-slurpy keywork transforms the target type constraint into a coderef. Please do
+slurpy keyword transforms the target type constraint into a coderef. Please do
not try to create your own custom coderefs; always use the slurpy method. The
underlying technology may change in the future but the slurpy keyword will be
supported.
@@ -858,15 +858,16 @@
=head1 AUTHOR
-John Napiorkowski C<< <jjnapiork at cpan.org> >>
+John Napiorkowski <jjnapiork at cpan.org>
=head1 CONTRIBUTORS
The following people have contributed to this module and agree with the listed
Copyright & license information included below:
- Florian Ragwitz, C<< <rafl at debian.org> >>
- Yuval Kogman, C<< <nothingmuch at woobling.org> >>
+ Florian Ragwitz, <rafl at debian.org>
+ Yuval Kogman, <nothingmuch at woobling.org>
+ Tomas Doran, <bobtfish at bobtfish.net>
=head1 COPYRIGHT & LICENSE
Modified: branches/upstream/libmoosex-types-structured-perl/current/t/12-error.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-types-structured-perl/current/t/12-error.t?rev=46872&op=diff
==============================================================================
--- branches/upstream/libmoosex-types-structured-perl/current/t/12-error.t (original)
+++ branches/upstream/libmoosex-types-structured-perl/current/t/12-error.t Sat Nov 7 02:40:07 2009
@@ -23,7 +23,7 @@
## Let's check all the expected validation errors for tuple
like $simple_tuple->validate({a=>1,b=>2}),
- qr/Validation failed for 'simple_tuple' failed with value { a => 1, b => 2 }/,
+ qr/Validation failed for 'simple_tuple' failed with value { a: 1, b: 2 }/,
'Wrong basic type';
like $simple_tuple->validate(['a','b']),
@@ -53,7 +53,7 @@
'Correctly failed due to age not an Int';
like $simple_dict->validate({name=>$simple_dict,age=>1}),
- qr/failed with value { age => 1, name => MooseX:/,
+ qr/failed with value { age: 1, name: MooseX:/,
'Correctly failed due to object not a Str';
like $simple_dict->validate({name=>'John'}),
@@ -70,7 +70,7 @@
my $optional_dict = subtype 'optional_dict', as Dict[name=>Str,age=>Optional[Int]];
like $optional_tuple->validate({a=>1,b=>2}),
- qr/Validation failed for 'optional_tuple' failed with value { a => 1, b => 2 }/,
+ qr/Validation failed for 'optional_tuple' failed with value { a: 1, b: 2 }/,
'Wrong basic type';
like $optional_tuple->validate(['a','b']),
@@ -94,7 +94,7 @@
'Correctly failed due to age not an Int';
like $optional_dict->validate({name=>$simple_dict,age=>1}),
- qr/failed with value { age => 1, name => MooseX:/,
+ qr/failed with value { age: 1, name: MooseX:/,
'Correctly failed due to object not a Str';
like $optional_dict->validate({name=>'Vincent', age=>15,extra=>'morethanIneed'}),
More information about the Pkg-perl-cvs-commits
mailing list