From: Ricardo SIGNES Date: Fri, 10 Jul 2009 00:14:52 +0000 (-0400) Subject: prep new release with fixed MANIFEST.SKIP X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=21e6e763ac3cfe5a1bdf364260a8fa2d0b83fa5b;p=gitmo%2FMooseX-Getopt.git prep new release with fixed MANIFEST.SKIP Gordon Irving goraxe@goraxe.me.uk add BUILDARGS which mimics the functionality of new_with_options but allows objects to be created via standard new function add t/build.t which is a copy of t/basic.t but with new_with_options changed to new() --- diff --git a/ChangeLog b/ChangeLog index 10657ca..10b28cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ Revision history for Perl extension MooseX-Getopt +0.20 Wed. July 9 2009 + ~ fix MANIFEST.SKIP to avoid double-packaging + 0.19 Wed. July 8 2009 * MooseX::Getopt - Fix Getopt config spec for --configfile (t0m) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index ec91334..45ff306 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -18,3 +18,4 @@ cover_db ^#.*#$ ^\.# ^TODO$ +^MooseX-Getopt diff --git a/README b/README index 608abe7..5c6b104 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -MooseX::Getopt version 0.19 +MooseX::Getopt version 0.20 =========================== See the individual module documentation for more information diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 41bedd3..b400247 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -11,7 +11,7 @@ use Carp (); use Getopt::Long (); # GLD uses it anyway, doesn't hurt use constant HAVE_GLD => not not eval { require Getopt::Long::Descriptive }; -our $VERSION = '0.19'; +our $VERSION = '0.20'; our $AUTHORITY = 'cpan:STEVAN'; has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt"); diff --git a/lib/MooseX/Getopt/Meta/Attribute.pm b/lib/MooseX/Getopt/Meta/Attribute.pm index 387060f..7bb6477 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.19'; +our $VERSION = '0.20'; our $AUTHORITY = 'cpan:STEVAN'; extends 'Moose::Meta::Attribute'; # << Moose extending Moose :) diff --git a/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm b/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm index 7dd84b0..1d98a83 100644 --- a/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm +++ b/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm @@ -2,7 +2,7 @@ package MooseX::Getopt::Meta::Attribute::NoGetopt; use Moose; -our $VERSION = '0.19'; +our $VERSION = '0.20'; our $AUTHORITY = 'cpan:STEVAN'; extends 'Moose::Meta::Attribute'; # << Moose extending Moose :) diff --git a/lib/MooseX/Getopt/Meta/Attribute/Trait.pm b/lib/MooseX/Getopt/Meta/Attribute/Trait.pm index 890f368..74177d5 100644 --- a/lib/MooseX/Getopt/Meta/Attribute/Trait.pm +++ b/lib/MooseX/Getopt/Meta/Attribute/Trait.pm @@ -3,7 +3,7 @@ package MooseX::Getopt::Meta::Attribute::Trait; use Moose::Role; use Moose::Util::TypeConstraints; -our $VERSION = '0.19'; +our $VERSION = '0.20'; our $AUTHORITY = 'cpan:STEVAN'; has 'cmd_flag' => ( diff --git a/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm b/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm index 8416169..180d705 100644 --- a/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm +++ b/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm @@ -2,7 +2,7 @@ package MooseX::Getopt::Meta::Attribute::Trait::NoGetopt; use Moose::Role; -our $VERSION = '0.19'; +our $VERSION = '0.20'; our $AUTHORITY = 'cpan:STEVAN'; no Moose::Role; diff --git a/lib/MooseX/Getopt/OptionTypeMap.pm b/lib/MooseX/Getopt/OptionTypeMap.pm index 651bf15..f634726 100644 --- a/lib/MooseX/Getopt/OptionTypeMap.pm +++ b/lib/MooseX/Getopt/OptionTypeMap.pm @@ -4,7 +4,7 @@ package MooseX::Getopt::OptionTypeMap; use Moose 'confess', 'blessed'; use Moose::Util::TypeConstraints 'find_type_constraint'; -our $VERSION = '0.19'; +our $VERSION = '0.20'; our $AUTHORITY = 'cpan:STEVAN'; my %option_type_map = ( diff --git a/t/001_build.t b/t/001_build.t new file mode 100644 index 0000000..c0154f4 --- /dev/null +++ b/t/001_build.t @@ -0,0 +1,224 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 69; + +BEGIN { + use_ok('MooseX::Getopt'); +} + +{ + package App; + use Moose; + + with 'MooseX::Getopt'; + + has 'data' => ( + metaclass => 'MooseX::Getopt::Meta::Attribute', + is => 'ro', + isa => 'Str', + default => 'file.dat', + cmd_flag => 'f', + ); + + has 'cow' => ( + metaclass => 'Getopt', + is => 'ro', + isa => 'Str', + default => 'moo', + cmd_aliases => [qw/ moocow m c /], + ); + + has 'horse' => ( + metaclass => 'MooseX::Getopt::Meta::Attribute', + is => 'ro', + isa => 'Str', + default => 'bray', + cmd_flag => 'horsey', + cmd_aliases => 'x', + ); + + has 'length' => ( + is => 'ro', + isa => 'Int', + default => 24 + ); + + has 'verbose' => ( + is => 'ro', + isa => 'Bool', + ); + + has 'libs' => ( + is => 'ro', + isa => 'ArrayRef', + default => sub { [] }, + ); + + has 'details' => ( + is => 'ro', + isa => 'HashRef', + default => sub { {} }, + ); + + has '_private_stuff' => ( + is => 'ro', + isa => 'Int', + default => 713 + ); + + has '_private_stuff_cmdline' => ( + metaclass => 'MooseX::Getopt::Meta::Attribute', + is => 'ro', + isa => 'Int', + default => 832, + cmd_flag => 'p', + ); + +} + +foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) { + my $attr = App->meta->get_attribute($attr_name); + isa_ok($attr, 'Moose::Meta::Attribute'); + isa_ok($attr, 'MooseX::Getopt::Meta::Attribute'); + can_ok($attr, 'cmd_flag'); + can_ok($attr, 'cmd_aliases'); +} + +{ + local @ARGV = (); + + my $app = App->new; + isa_ok($app, 'App'); + + ok(!$app->verbose, '... verbosity is off as expected'); + is($app->length, 24, '... length is 24 as expected'); + is($app->data, 'file.dat', '... data is file.dat as expected'); + is_deeply($app->libs, [], '... libs is [] as expected'); + is_deeply($app->details, {}, '... details is {} as expected'); +} + +{ + local @ARGV = ('--verbose', '--length', 50); + + my $app = App->new; + isa_ok($app, 'App'); + + ok($app->verbose, '... verbosity is turned on as expected'); + is($app->length, 50, '... length is 50 as expected'); + is($app->data, 'file.dat', '... data is file.dat as expected'); + is_deeply($app->libs, [], '... libs is [] as expected'); + is_deeply($app->details, {}, '... details is {} as expected'); +} + +{ + local @ARGV = ('--verbose', '-f', 'foo.txt'); + + my $app = App->new; + isa_ok($app, 'App'); + + ok($app->verbose, '... verbosity is turned on as expected'); + is($app->length, 24, '... length is 24 as expected'); + is($app->data, 'foo.txt', '... data is foo.txt as expected'); + is_deeply($app->libs, [], '... libs is [] as expected'); + is_deeply($app->details, {}, '... details is {} as expected'); +} + +{ + local @ARGV = ('--verbose', '--libs', 'libs/', '--libs', 'includes/lib'); + + my $app = App->new; + isa_ok($app, 'App'); + + ok($app->verbose, '... verbosity is turned on as expected'); + is($app->length, 24, '... length is 24 as expected'); + is($app->data, 'file.dat', '... data is foo.txt as expected'); + is_deeply($app->libs, + ['libs/', 'includes/lib'], + '... libs is [libs/, includes/lib] as expected'); + is_deeply($app->details, {}, '... details is {} as expected'); +} + +{ + local @ARGV = ('--details', 'os=mac', '--details', 'name=foo'); + + my $app = App->new; + isa_ok($app, 'App'); + + ok(!$app->verbose, '... verbosity is turned on as expected'); + is($app->length, 24, '... length is 24 as expected'); + is($app->data, 'file.dat', '... data is foo.txt as expected'); + is_deeply($app->libs, [], '... libs is [] as expected'); + is_deeply($app->details, + { os => 'mac', name => 'foo' }, + '... details is { os => mac, name => foo } as expected'); +} + +{ + # Test negation on booleans too ... + local @ARGV = ('--noverbose'); + + my $app = App->new; + isa_ok($app, 'App'); + + ok(!$app->verbose, '... verbosity is turned off as expected'); + is($app->length, 24, '... length is 24 as expected'); + is($app->data, 'file.dat', '... file is file.dat as expected'); + is_deeply($app->libs, [], '... libs is [] as expected'); + is_deeply($app->details, {}, '... details is {} as expected'); +} + +# Test cmd_alias without cmd_flag +{ + local @ARGV = ('--cow', '42'); + my $app = App->new; + isa_ok($app, 'App'); + is($app->cow, 42, 'cmd_alias, but not using it'); +} +{ + local @ARGV = ('--moocow', '88'); + my $app = App->new; + isa_ok($app, 'App'); + is($app->cow, 88, 'cmd_alias, using long one'); +} +{ + local @ARGV = ('-c', '99'); + my $app = App->new; + isa_ok($app, 'App'); + is($app->cow, 99, 'cmd_alias, using short one'); +} + +# Test cmd_alias + cmd_flag +{ + local @ARGV = ('--horsey', '123'); + my $app = App->new; + isa_ok($app, 'App'); + is($app->horse, 123, 'cmd_alias+cmd_flag, using flag'); +} +{ + local @ARGV = ('-x', '321'); + my $app = App->new; + isa_ok($app, 'App'); + is($app->horse, 321, 'cmd_alias+cmd_flag, using alias'); +} + +# Test _foo + cmd_flag +{ + local @ARGV = ('-p', '666'); + my $app = App->new; + isa_ok($app, 'App'); + is($app->_private_stuff_cmdline, 666, '_foo + cmd_flag'); +} + +# Test ARGV support +{ + my @args = ('-p', 12345, '-c', 99, '-'); + local @ARGV = @args; + my $app = App->new; + isa_ok($app, 'App'); + is_deeply($app->ARGV, \@args, 'ARGV accessor'); + is_deeply(\@ARGV, \@args, '@ARGV unmangled'); + is_deeply($app->extra_argv, ['-'], 'extra_argv accessor'); +}