@@ -1,6 +1,11 @@
Revision history for Perl extension MooseX-Params-Validate
-0.13 Sun., Nov. 29, 2009
+0.14 Sun. Mar. 18, 2010
+ - 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
- Fix so that validated_hash does not try to coerce optional
parameters which are not present. Patch by Ian Sillitoe.
@@ -22,5 +22,8 @@ t/006_not_moose.t
t/007_deprecated.t
t/008_positional.t
t/009_wrapped.t
-t/pod.t
-t/pod_coverage.t
+t/010.overloaded.t
+xt/kwalitee.t
+xt/pod-coverage.t
+xt/pod-spell.t
+xt/pod.t
@@ -19,6 +19,7 @@ no_index:
directory:
- inc
- t
+ - xt
requires:
Carp: 0
Devel::Caller: 0
@@ -29,4 +30,4 @@ requires:
resources:
license: http://dev.perl.org/licenses/
repository: http://code2.0beta.co.uk/moose/svn/MooseX-Params-Validate
-version: 0.13
+version: 0.14
@@ -1,4 +1,4 @@
-MooseX::Params::Validate version 0.12
+MooseX::Params::Validate version 0.13
===========================
See the individual module documentation for more information
@@ -19,7 +19,7 @@ use Sub::Exporter -setup => {
},
};
-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:STEVAN';
my %CACHED_SPECS;
@@ -60,7 +60,7 @@ sub validated_hash {
called => _caller_name(),
);
- return ( ( $instance ? $instance : () ), %args );
+ return ( ( defined $instance ? $instance : () ), %args );
}
*validate = \&validated_hash;
@@ -108,7 +108,7 @@ sub validated_list {
);
return (
- ( $instance ? $instance : () ),
+ ( defined $instance ? $instance : () ),
@args{@ordered_spec}
);
}
@@ -0,0 +1,51 @@
+use Test::More tests => 4;
+use strict;
+use warnings;
+
+{
+ package Foo;
+
+ use Moose;
+ use MooseX::Params::Validate;
+ use overload (
+ qw{""} => 'to_string',
+ );
+
+ has 'id' => (
+ is => 'ro',
+ isa => 'Str',
+ default => '1.10.100',
+ );
+
+ sub to_string {
+ my ( $self, %args ) = validated_hash(
+ \@_,
+ padded => {
+ isa => 'Bool',
+ optional => 1,
+ default => 0,
+ },
+ );
+
+ # 1.10.100 => 0001.0010.0100
+ my $id
+ = $args{padded}
+ ? join( '.',
+ map { sprintf( "%04d", $_ ) } split( /\./, $self->id ) )
+ : $self->id;
+
+ return $id;
+ }
+}
+
+isa_ok( my $foo = Foo->new(), 'Foo', 'new' );
+
+is( $foo->id, '1.10.100', 'id' );
+
+is( $foo->to_string, '1.10.100', 'to_string' );
+
+is(
+ $foo->to_string( padded => 1 ), '0001.0010.0100',
+ 'to_string( padded => 1 )'
+);
+
@@ -1,11 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use Test::More;
-
-eval "use Test::Pod 1.14";
-plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
-
-all_pod_files_ok();
@@ -1,11 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use Test::More;
-
-eval "use Test::Pod::Coverage 1.04";
-plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
-
-all_pod_coverage_ok( { trustme => [ qr/^(?:validatep?|import)$/ ] } );
@@ -0,0 +1,8 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+eval { require Test::Kwalitee; Test::Kwalitee->import() };
+plan skip_all => "Test::Kwalitee needed for testing kwalitee"
+ if $@;
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+
+all_pod_coverage_ok( { trustme => [ qr/^(?:validatep?|import)$/ ] } );
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+eval "use Test::Spelling";
+plan skip_all => "Test::Spelling required for testing POD coverage"
+ if $@;
+
+my @stopwords;
+for (<DATA>) {
+ chomp;
+ push @stopwords, $_
+ unless /\A (?: \# | \s* \z)/msx; # skip comments, whitespace
+}
+
+add_stopwords(@stopwords);
+set_spell_cmd('aspell list -l en');
+
+# This prevents a weird segfault from the aspell command - see
+# https://bugs.launchpad.net/ubuntu/+source/aspell/+bug/71322
+local $ENV{LC_ALL} = 'C';
+all_pod_files_spelling_ok();
+
+__DATA__
+Stevan
+cpan
+isa
+param
+subname
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+
+all_pod_files_ok();