From: Stevan Little Date: Thu, 5 Apr 2007 19:40:18 +0000 (+0000) Subject: adding metaclass laliasing X-Git-Tag: 0_02^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Getopt.git;a=commitdiff_plain;h=1a8b4ed19c6096c389d094504e81b524d7af7120 adding metaclass laliasing --- diff --git a/Build.PL b/Build.PL index 2b51fe1..df1d611 100644 --- a/Build.PL +++ b/Build.PL @@ -6,7 +6,7 @@ my $build = Module::Build->new( module_name => 'MooseX::Getopt', license => 'perl', requires => { - 'Moose' => '0.17', + 'Moose' => '0.19', 'Getopt::Long' => '2.36', }, optional => { diff --git a/ChangeLog b/ChangeLog index 1503cd8..94274b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,17 @@ Revision history for Perl extension MooseX-Getopt +0.02 + + * MooseX::Getopt + - added the ARGV attribute (thanks to blblack) + - added tests and docs for this + + * MooseX::Getopt::Meta::Attribute + - added the cmd_aliases attribute (thanks to blblack) + - added tests and docs for this + - added support for Moose 0.19's custom + attribute metaclass alias registry. + - added tests and docs for this + 0.01 Friday, March 9, 2007 - module released to CPAN \ No newline at end of file diff --git a/README b/README index 0b60b0f..dc0ec1a 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -MooseX::Getopt version 0.01 +MooseX::Getopt version 0.02 =========================== See the individual module documentation for more information diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 572be04..688f4ef 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -7,7 +7,7 @@ use Getopt::Long; use MooseX::Getopt::OptionTypeMap; use MooseX::Getopt::Meta::Attribute; -our $VERSION = '0.01'; +our $VERSION = '0.02'; our $AUTHORITY = 'cpan:STEVAN'; has ARGV => (is => 'rw', isa => 'ArrayRef'); diff --git a/lib/MooseX/Getopt/Meta/Attribute.pm b/lib/MooseX/Getopt/Meta/Attribute.pm index 55d1750..5f29df1 100644 --- a/lib/MooseX/Getopt/Meta/Attribute.pm +++ b/lib/MooseX/Getopt/Meta/Attribute.pm @@ -3,7 +3,7 @@ package MooseX::Getopt::Meta::Attribute; use Moose; use Moose::Util::TypeConstraints; -our $VERSION = '0.01'; +our $VERSION = '0.02'; our $AUTHORITY = 'cpan:STEVAN'; extends 'Moose::Meta::Attribute'; # << Moose extending Moose :) @@ -30,10 +30,15 @@ has 'cmd_aliases' => ( coerce => 1, ); -no Moose; 1; +no Moose; -__END__ +# register this as a metaclass alias ... +package Moose::Meta::Attribute::Custom::Getopt; +sub register_implementation { 'MooseX::Getopt::Meta::Attribute' } + +1; +__END__ =pod @@ -49,7 +54,7 @@ MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option name with 'MooseX::Getopt'; has 'data' => ( - metaclass => 'MooseX::Getopt::Meta::Attribute', + metaclass => 'MooseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Str', default => 'file.dat', @@ -77,6 +82,14 @@ which L will create for you. This is certainly not the prettiest way to go about this, but for now it works for those who might need such a feature. +=head2 Custom Metaclass alias + +This now takes advantage of the Moose 0.19 feature to support +custom attribute metaclass aliases. This means you can also +use this as the B alias, like so: + + has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f'); + =head1 METHODS These methods are of little use to most users, they are used interally diff --git a/t/001_basic.t b/t/001_basic.t index 438a9a8..7ffbe5b 100644 --- a/t/001_basic.t +++ b/t/001_basic.t @@ -24,7 +24,7 @@ BEGIN { ); has 'cow' => ( - metaclass => 'MooseX::Getopt::Meta::Attribute', + metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'moo',