From: gfx Date: Thu, 24 Sep 2009 05:09:47 +0000 (+0900) Subject: Fix Makefile.PL to use Mouse::Spec X-Git-Tag: 0.35~33^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=121acb8a89acd75e7a664241df7e8220d864c879;p=gitmo%2FMouse.git Fix Makefile.PL to use Mouse::Spec --- diff --git a/Changes b/Changes index 5ec5318..5fead64 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,9 @@ Revision history for Mouse -0.33 +0.34 + * Implement traits => [...] in has() (gfx) + +0.33 Wed Sep 23 15:06:40 2009 * Fix RT #49902: 0.32 fails tests reported by GRUBER (gfx) * Add some tests diff --git a/Makefile.PL b/Makefile.PL index 20396d5..81c3dfe 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -17,8 +17,8 @@ test_requires 'Test::More' => 0.80; if ($Module::Install::AUTHOR) { local @INC = ('lib', @INC); - require 'lib/Mouse.pm'; # for moose_version() - my $require_version = Mouse->moose_version; + require 'lib/Mouse/Spec.pm'; + my $require_version = Mouse::Spec->MooseVersion; if (eval{ require Moose; Moose->VERSION($require_version) }) { if (eval 'use Module::Install::AuthorTests; 1') { diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 0e3a586..af7bebc 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -6,8 +6,6 @@ use base 'Exporter'; our $VERSION = '0.32'; -sub moose_version(){ 0.90 } # which Mouse is a subset of - use Carp 'confess'; use Scalar::Util 'blessed'; diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index dec1a54..ef70ea8 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -47,7 +47,7 @@ sub new { my $can_be_required = defined( $options{init_arg} ); if(exists $options{builder}){ - $class->throw_error('builder must be a defined scalar value which is a method name') + $class->throw_error('builder must be a defined scalar value which is a method name') if ref $options{builder} || !(defined $options{builder}); $can_be_required++; @@ -60,8 +60,8 @@ sub new { $can_be_required++; } - if( $options{required} && !$can_be_required ) { - $class->throw_error("You cannot have a required attribute ($name) without a default, builder, or an init_arg"); + if( $options{required} && !$can_be_required ) { + $class->throw_error("You cannot have a required attribute ($name) without a default, builder, or an init_arg"); } # taken from Mouse::Meta::Attribute->new and _process_options @@ -103,41 +103,41 @@ sub new { || $class->throw_error("You cannot have coercion without specifying a type constraint on attribute ($name)"); $options{weak_ref} - && $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)"); + && $class->throw_error("You cannot have a weak reference to a coerced value on attribute ($name)"); } - if ($options{lazy_build}) { + if ($options{lazy_build}) { exists($options{default}) - && $class->throw_error("You can not use lazy_build and default for the same attribute ($name)"); - - $options{lazy} = 1; - $options{builder} ||= "_build_${name}"; - if ($name =~ /^_/) { - $options{clearer} ||= "_clear${name}"; - $options{predicate} ||= "_has${name}"; - } - else { - $options{clearer} ||= "clear_${name}"; - $options{predicate} ||= "has_${name}"; - } + && $class->throw_error("You can not use lazy_build and default for the same attribute ($name)"); + + $options{lazy} = 1; + $options{builder} ||= "_build_${name}"; + if ($name =~ /^_/) { + $options{clearer} ||= "_clear${name}"; + $options{predicate} ||= "_has${name}"; + } + else { + $options{clearer} ||= "clear_${name}"; + $options{predicate} ||= "has_${name}"; + } } if ($options{auto_deref}) { - defined($tc) - || $class->throw_error("You cannot auto-dereference without specifying a type constraint on attribute ($name)"); + defined($tc) + || $class->throw_error("You cannot auto-dereference without specifying a type constraint on attribute ($name)"); - ( $tc->is_a_type_of('ArrayRef') || $tc->is_a_type_of('HashRef') ) - || $class->throw_error("You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute ($name)"); + ( $tc->is_a_type_of('ArrayRef') || $tc->is_a_type_of('HashRef') ) + || $class->throw_error("You cannot auto-dereference anything other than a ArrayRef or HashRef on attribute ($name)"); } - if (exists $options{trigger}) { - ('CODE' eq ref $options{trigger}) - || $class->throw_error("Trigger must be a CODE ref on attribute ($name)"); + if (exists $options{trigger}) { + ('CODE' eq ref $options{trigger}) + || $class->throw_error("Trigger must be a CODE ref on attribute ($name)"); } - if ($options{lazy}) { - (exists $options{default} || defined $options{builder}) - || $class->throw_error("You cannot have lazy attribute ($name) without specifying a default value for it"); + if ($options{lazy}) { + (exists $options{default} || defined $options{builder}) + || $class->throw_error("You cannot have lazy attribute ($name) without specifying a default value for it"); } if(my $metaclass = delete $options{metaclass}){ @@ -146,24 +146,24 @@ sub new { if(my $traits_ref = delete $options{traits}){ my @traits; - for (my $i = 9; $i < @{$traits_ref}; $i++) { - my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1); - - next if $class->does($trait); - - push @traits, $trait; - - # are there options? - push @traits, $traits_ref->[++$i] - if ref($traits_ref->[$i+1]); + for (my $i = 9; $i < @{$traits_ref}; $i++) { + my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1); + + next if $class->does($trait); + + push @traits, $trait; + + # are there options? + push @traits, $traits_ref->[++$i] + if ref($traits_ref->[$i+1]); } - if (@traits) { - $class = Mouse::Meta::Class->create_anon_class( - superclasses => [ $class ], - roles => [ @traits ], - cache => 1, - )->name; + if (@traits) { + $class = Mouse::Meta::Class->create_anon_class( + superclasses => [ $class ], + roles => [ @traits ], + cache => 1, + )->name; } } @@ -412,4 +412,3 @@ C. =cut - \ No newline at end of file