r69836 - in /branches/upstream/libmoosex-params-validate-perl/current: ChangeLog LICENSE MANIFEST META.json META.yml Makefile.PL README SIGNATURE dist.ini lib/MooseX/Params/Validate.pm t/012_ref_as_first_param.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sun Feb 27 04:09:13 UTC 2011


Author: jawnsy-guest
Date: Sun Feb 27 04:08:48 2011
New Revision: 69836

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=69836
Log:
[svn-upgrade] new version libmoosex-params-validate-perl (0.16)

Added:
    branches/upstream/libmoosex-params-validate-perl/current/t/012_ref_as_first_param.t
Modified:
    branches/upstream/libmoosex-params-validate-perl/current/ChangeLog
    branches/upstream/libmoosex-params-validate-perl/current/LICENSE
    branches/upstream/libmoosex-params-validate-perl/current/MANIFEST
    branches/upstream/libmoosex-params-validate-perl/current/META.json
    branches/upstream/libmoosex-params-validate-perl/current/META.yml
    branches/upstream/libmoosex-params-validate-perl/current/Makefile.PL
    branches/upstream/libmoosex-params-validate-perl/current/README
    branches/upstream/libmoosex-params-validate-perl/current/SIGNATURE
    branches/upstream/libmoosex-params-validate-perl/current/dist.ini
    branches/upstream/libmoosex-params-validate-perl/current/lib/MooseX/Params/Validate.pm

Modified: branches/upstream/libmoosex-params-validate-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/ChangeLog?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/ChangeLog (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/ChangeLog Sun Feb 27 04:08:48 2011
@@ -1,29 +1,32 @@
 Revision history for Perl extension MooseX-Params-Validate
 
-0.15
+0.16 2011-01-29
+    - The validated_list and validated_hash functions now accept the values to
+      be validated as both a hash and a hash reference.
+
+0.15 2010-11-29
     - Add MX_PARAMS_VALIDATE_ALLOW_EXTRA which allows extra parameters in
       validation calls (like allow_extra for Params::Validate).
     - Converted to Test::Fatal.
 
-0.14 Sun. Mar. 18, 2010
+0.14 2010-03-18
     - The validated_hash method failed when called on in an overloaded
       stringify method. Patch by Ian Sillitoe. RT #52565.
 
-
-0.13 Sun. Nov. 29, 2009
+0.13 2009-11-29
     - Fix so that validated_hash does not try to coerce optional
       parameters which are not present. Patch by Ian Sillitoe.
 
     - Same fix for pos_validated_list. (Dave Rolsky)
 
-0.12 Tue. Jul. 7, 2009
+0.12 2009-07-07
     - Using the subroutine name as a cache key for validation specs
       broke in the face of method modifiers, which all appear to have
       the same name. Now we use Devel::Caller to get the CV of the
       caller and use its refaddr as the key, which will be unique in
       all cases. Bug report by Jos Boumans. RT #46730.
 
-0.11 Tue. Jul. 7, 2009
+0.11 2009-07-07
     - The validation functions tried to coerce optional keys which
       weren't present in the incoming parameters, leading to weird
       errors. Based on a patch from Jos Boumans. RT #46344.
@@ -33,14 +36,14 @@
       encapsulate everything in the callback instead. Based on a patch
       from Jos Boumans. RT #47647.
 
-0.10 Tue. Jun. 30, 2009
+0.10 2009-06-30
     - Shut up deprecation warnings from the tests. Reported by John
       Goulah.
 
-0.09 Sun. Feb. 1, 2009
+0.09 2009-02-01
     - The subroutine name being reported in error messages was screwy.
 
-0.08 Sun. Feb. 1, 2009
+0.08 2009-02-01
     - Renamed validate to validated_hash and validatep to
       validated_list. The old function names are still available under
       the ":deprecated" import tag.
@@ -52,22 +55,22 @@
       function, rather than coming form inside the validation function
       itself.
 
-0.07 Sun. Sep. 21, 2008
+0.07 2008-09-21
     - No code changes, just fixing missing prereqs (Dave Rolsky)
 
-0.06 Sat. Sep. 20, 2008
+0.06 2008-09-20
     - Fixes to work with Moose 0.58 (Dave Rolsky)
 
     - Switched to using Module::Install (Dave Rolsky)
 
-0.05 Fri. Mar. 7th, 2008
+0.05 2008-03-07
     - This package would cause a fatal error if loaded
       by a non-Moose class (Dave Rolsky)
       - added tests for this (Dave Rolsky)
 
     - Added support for coercions (Dave Rolsky)
 
-0.04 Tues. Jan. 8th, 2008
+0.04 2008-01-08
     - upped the Moose dependency and added support
       for the new improved Moose type constraints
       - added tests for this
@@ -81,14 +84,14 @@
       POD for more details
       - added tests for this
 
-0.03 Fri. June 8th, 2007
+0.03 2007-06-08
     - added support for using this
       within role methods too.
 
-0.02 Wed. April 25, 2007
+0.02 2007-04-25
     - added validatep, which returns the captured
       args as positional instead of as hash
       - added docs and tests
 
-0.01 Wed. April 18, 2007
+0.01 2007-04-18
     - trying to fill a gap, we will see ...

Modified: branches/upstream/libmoosex-params-validate-perl/current/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/LICENSE?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/LICENSE (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/LICENSE Sun Feb 27 04:08:48 2011
@@ -1,4 +1,4 @@
-This software is copyright (c) 2010 by Stevan Little <stevan.little at iinteractive.com>.
+This software is copyright (c) 2011 by Stevan Little <stevan.little at iinteractive.com>.
 
 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) 2010 by Stevan Little <stevan.little at iinteractive.com>.
+This software is Copyright (c) 2011 by Stevan Little <stevan.little at iinteractive.com>.
 
 This is free software, licensed under:
 
@@ -270,7 +270,7 @@
 
 --- The Artistic License 1.0 ---
 
-This software is Copyright (c) 2010 by Stevan Little <stevan.little at iinteractive.com>.
+This software is Copyright (c) 2011 by Stevan Little <stevan.little at iinteractive.com>.
 
 This is free software, licensed under:
 

Modified: branches/upstream/libmoosex-params-validate-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/MANIFEST?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/MANIFEST (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/MANIFEST Sun Feb 27 04:08:48 2011
@@ -21,6 +21,7 @@
 t/009_wrapped.t
 t/010_overloaded.t
 t/011_allow_extra.t
+t/012_ref_as_first_param.t
 t/release-eol.t
 t/release-no-tabs.t
 t/release-pod-coverage.t

Modified: branches/upstream/libmoosex-params-validate-perl/current/META.json
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/META.json?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/META.json (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/META.json Sun Feb 27 04:08:48 2011
@@ -4,7 +4,7 @@
       "Stevan Little <stevan.little at iinteractive.com>"
    ],
    "dynamic_config" : 0,
-   "generated_by" : "Dist::Zilla version 4.102345, CPAN::Meta::Converter version 2.101670",
+   "generated_by" : "Dist::Zilla version 4.200001, CPAN::Meta::Converter version 2.102400",
    "license" : [
       "perl_5"
    ],
@@ -48,6 +48,7 @@
          "web" : "http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/MooseX-Params-Validate.git"
       }
    },
-   "version" : "0.15"
+   "version" : "0.16",
+   "x_authority" : "cpan:STEVAN"
 }
 

Modified: branches/upstream/libmoosex-params-validate-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/META.yml?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/META.yml (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/META.yml Sun Feb 27 04:08:48 2011
@@ -8,7 +8,7 @@
 configure_requires:
   ExtUtils::MakeMaker: 6.31
 dynamic_config: 0
-generated_by: 'Dist::Zilla version 4.102345, CPAN::Meta::Converter version 2.101670'
+generated_by: 'Dist::Zilla version 4.200001, CPAN::Meta::Converter version 2.102400'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -24,4 +24,5 @@
 resources:
   bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX::Params::Validate
   repository: git://git.moose.perl.org/MooseX-Params-Validate.git
-version: 0.15
+version: 0.16
+x_authority: cpan:STEVAN

Modified: branches/upstream/libmoosex-params-validate-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/Makefile.PL?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/Makefile.PL (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/Makefile.PL Sun Feb 27 04:08:48 2011
@@ -30,7 +30,7 @@
     'Scalar::Util' => '0',
     'Sub::Exporter' => '0'
   },
-  'VERSION' => '0.15',
+  'VERSION' => '0.16',
   'test' => {
     'TESTS' => 't/*.t'
   }

Modified: branches/upstream/libmoosex-params-validate-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/README?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/README (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/README Sun Feb 27 04:08:48 2011
@@ -1,11 +1,11 @@
 
 
 This archive contains the distribution MooseX-Params-Validate,
-version 0.15:
+version 0.16:
 
   an extension of Params::Validate using Moose's types
 
-This software is copyright (c) 2010 by Stevan Little <stevan.little at iinteractive.com>.
+This software is copyright (c) 2011 by Stevan Little <stevan.little at iinteractive.com>.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.

Modified: branches/upstream/libmoosex-params-validate-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/SIGNATURE?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/SIGNATURE (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/SIGNATURE Sun Feb 27 04:08:48 2011
@@ -1,5 +1,5 @@
 This file contains message digests of all files listed in MANIFEST,
-signed via the Module::Signature module, version 0.61.
+signed via the Module::Signature module, version 0.66.
 
 To verify the content in this distribution, first make sure you have
 Module::Signature installed, then type:
@@ -14,16 +14,16 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 817f3de5af1b184b7fc03e50dcb535c7fa2510c7 ChangeLog
+SHA1 970a35fb3e29322f0efa382f899e721965c306be ChangeLog
 SHA1 cc4d2fab66c18673004f62a31d4d5e0336bbfe8a INSTALL
-SHA1 c2e7f481b3423397eee994d1272293bdd956d261 LICENSE
-SHA1 288714ab3375009ab4f947b15411d4cef2437d28 MANIFEST
-SHA1 67a1c067dedcae42c9520eac5bf6805e4f6b5b6d META.json
-SHA1 c9a9209e6caa86aaf270d60e8134607e5438f378 META.yml
-SHA1 1a9e5c8ed8b142a5002dbbe5374796dfb63e4ead Makefile.PL
-SHA1 8c9fce17e16b4c9c0da8f73792e2ad95e7bd1755 README
-SHA1 915673a4ab4960ab9c2dfda83c808d96022b4912 dist.ini
-SHA1 ddc5e51be198964d648fbe661e2f5d882a3d5bf9 lib/MooseX/Params/Validate.pm
+SHA1 88c56ea2a245738abbcf23366a6e353ad54743c9 LICENSE
+SHA1 33e2c85e0186487d48a8bc6cf701e311df178ddd MANIFEST
+SHA1 3e1560d258cd62ba5e694354c35dbd51aaacb341 META.json
+SHA1 8a4a1481caac01fe7b1d9a6703d6ed5a436124d7 META.yml
+SHA1 5f3c0e5f392819b1643d9bceb43c0d6ad9288c96 Makefile.PL
+SHA1 3892007cc51e5474bf9cf3a68ec7e853b0d9074b README
+SHA1 482026edd5ae4ed792ec281110e94fcf5a91ea87 dist.ini
+SHA1 a82e8946a1e0ac343f50f9cb8427c27313810bb7 lib/MooseX/Params/Validate.pm
 SHA1 26d791d014ba8912b754a21d94a53c120ffab187 t/000_load.t
 SHA1 9ae33440d43635ab30fdbed609aad4b3ff830420 t/001_basic.t
 SHA1 cda4c07346a1fb86d55c51fb498b66ba5ce2cc1c t/002_basic_list.t
@@ -36,6 +36,7 @@
 SHA1 76bc8865bfd1fd344994252aea881fee194a1cbb t/009_wrapped.t
 SHA1 ae17b92bd2f8a376d7ab5a830110394d59e5adb1 t/010_overloaded.t
 SHA1 5eba65d7bd97ce02725da6e5a90c8b261ff80a89 t/011_allow_extra.t
+SHA1 319a585146905477412b673f5b0b4f7a8a3c9511 t/012_ref_as_first_param.t
 SHA1 a032c41ef6887fab1b900669c2d304fab46680e2 t/release-eol.t
 SHA1 455d1dd1867212a665ad5ea4126b572411de300c t/release-no-tabs.t
 SHA1 287ab1af698d8e0e25b88242dd22162da726cd74 t/release-pod-coverage.t
@@ -44,7 +45,7 @@
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.10 (GNU/Linux)
 
-iEYEARECAAYFAkz0LVwACgkQIgMCsV8qvRIIUACeIY6SNldw+GowwK2ROgKEjv5m
-oyoAnjlmE6AbQbjCXC/4iHiPKG2jhEjO
-=Do5v
+iEYEARECAAYFAk1EUHsACgkQIgMCsV8qvRLK3gCeMA71wBfaewzDcn4fZ1jWVCMO
+jc8An37TNd92uyK0isX0ltu80i37bxQa
+=txJQ
 -----END PGP SIGNATURE-----

Modified: branches/upstream/libmoosex-params-validate-perl/current/dist.ini
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/dist.ini?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/dist.ini (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/dist.ini Sun Feb 27 04:08:48 2011
@@ -1,8 +1,10 @@
 name = MooseX-Params-Validate
-version = 0.15
 author  = Stevan Little <stevan.little at iinteractive.com>
 license = Perl_5
 copyright_holder = Stevan Little <stevan.little at iinteractive.com>
+copyright_year   = 2011
+
+version = 0.16
 
 [Authority]
 authority = cpan:STEVAN

Modified: branches/upstream/libmoosex-params-validate-perl/current/lib/MooseX/Params/Validate.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/lib/MooseX/Params/Validate.pm?rev=69836&op=diff
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/lib/MooseX/Params/Validate.pm (original)
+++ branches/upstream/libmoosex-params-validate-perl/current/lib/MooseX/Params/Validate.pm Sun Feb 27 04:08:48 2011
@@ -1,6 +1,6 @@
 package MooseX::Params::Validate;
 BEGIN {
-  $MooseX::Params::Validate::VERSION = '0.15';
+  $MooseX::Params::Validate::VERSION = '0.16';
 }
 BEGIN {
   $MooseX::Params::Validate::AUTHORITY = 'cpan:STEVAN';
@@ -11,7 +11,7 @@
 
 use Carp 'confess';
 use Devel::Caller 'caller_cv';
-use Scalar::Util 'blessed', 'refaddr';
+use Scalar::Util 'blessed', 'refaddr', 'reftype';
 
 use Moose::Util::TypeConstraints qw( find_type_constraint class_type role_type );
 use Params::Validate             ();
@@ -54,7 +54,10 @@
     my $instance;
     $instance = shift @$args if blessed $args->[0];
 
-    my %args = @$args;
+    my %args
+        = @$args == 1
+        && ref $args->[0]
+        && reftype( $args->[0] ) eq 'HASH' ? %{ $args->[0] } : @$args;
 
     $args{$_} = $spec{$_}{constraint}->coerce( $args{$_} )
         for grep { $spec{$_}{coerce} && exists $args{$_} } keys %spec;
@@ -104,7 +107,10 @@
     my $instance;
     $instance = shift @$args if blessed $args->[0];
 
-    my %args = @$args;
+    my %args
+        = @$args == 1
+        && ref $args->[0]
+        && reftype( $args->[0] ) eq 'HASH' ? %{ $args->[0] } : @$args;
 
     $args{$_} = $spec{$_}{constraint}->coerce( $args{$_} )
         for grep { $spec{$_}{coerce} && exists $args{$_} } keys %spec;
@@ -154,7 +160,7 @@
             if $should_cache;
     }
 
-    my @args = @{$args};
+    my @args = @$args;
 
     $args[$_] = $pv_spec[$_]{constraint}->coerce( $args[$_] )
         for grep { $pv_spec[$_] && $pv_spec[$_]{coerce} } 0 .. $#args;
@@ -254,7 +260,7 @@
 
 =head1 VERSION
 
-version 0.15
+version 0.16
 
 =head1 SYNOPSIS
 
@@ -308,6 +314,9 @@
 it appropriately (unlike Params::Validate which forces you to shift
 you C<$self> first).
 
+The values in C<@_> can either be a set of name-value pairs or a single hash
+reference.
+
 The C<%parameter_spec> accepts the following options:
 
 =over 4
@@ -361,6 +370,9 @@
 return them as a list in the same order. If a param is marked optional
 and not included, then it will be set to C<undef>.
 
+The values in C<@_> can either be a set of name-value pairs or a single hash
+reference.
+
 Like C<validated_hash>, if it spots an object instance as the first
 parameter of C<@_>, it will handle it appropriately, returning it as
 the first argument.
@@ -386,6 +398,10 @@
 Unlike the other functions, this function I<cannot> find C<$self> in
 the argument list. Make sure to shift it off yourself before doing
 validation.
+
+The values in C<@_> must be a list of values. You cannot pass the values as an
+array reference, because this cannot be distinguished from passing one value
+which is itself an array reference.
 
 If a parameter is marked as optional and is not present, it will
 simply not be returned.
@@ -487,7 +503,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-This software is copyright (c) 2010 by Stevan Little <stevan.little at iinteractive.com>.
+This software is copyright (c) 2011 by Stevan Little <stevan.little at iinteractive.com>.
 
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.

Added: branches/upstream/libmoosex-params-validate-perl/current/t/012_ref_as_first_param.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-params-validate-perl/current/t/012_ref_as_first_param.t?rev=69836&op=file
==============================================================================
--- branches/upstream/libmoosex-params-validate-perl/current/t/012_ref_as_first_param.t (added)
+++ branches/upstream/libmoosex-params-validate-perl/current/t/012_ref_as_first_param.t Sun Feb 27 04:08:48 2011
@@ -1,0 +1,57 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Fatal;
+
+{
+    use MooseX::Params::Validate;
+
+    sub foo {
+        my ( $x, $y ) = validated_list(
+            \@_,
+            x => { isa => 'Any' },
+            y => { isa => 'Any' },
+        );
+
+        return { x => $x, y => $y };
+    }
+
+    sub bar {
+        my %p = validated_hash(
+            \@_,
+            x => { isa => 'Any' },
+            y => { isa => 'Any' },
+        );
+
+        return \%p;
+    }
+}
+
+is_deeply(
+    foo( x => 42, y => 84 ),
+    { x => 42, y => 84 },
+    'validated_list accepts a plain hash'
+);
+
+is_deeply(
+    foo( { x => 42, y => 84 } ),
+    { x => 42, y => 84 },
+    'validated_list accepts a hash reference'
+);
+
+is_deeply(
+    bar( x => 42, y => 84 ),
+    { x => 42, y => 84 },
+    'validated_hash accepts a plain hash'
+);
+
+is_deeply(
+    bar( { x => 42, y => 84 } ),
+    { x => 42, y => 84 },
+    'validated_hash accepts a hash reference'
+);
+
+done_testing();




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