r17712 - in /branches/upstream/libmoosex-getopt-perl/current: ./ lib/MooseX/ lib/MooseX/Getopt/ lib/MooseX/Getopt/Meta/ lib/MooseX/Getopt/Meta/Attribute/ lib/MooseX/Getopt/Meta/Attribute/Trait/ t/
roberto at users.alioth.debian.org
roberto at users.alioth.debian.org
Mon Mar 17 02:47:12 UTC 2008
Author: roberto
Date: Mon Mar 17 02:47:11 2008
New Revision: 17712
URL: http://svn.debian.org/wsvn/?sc=1&rev=17712
Log:
[svn-upgrade] Integrating new upstream version, libmoosex-getopt-perl (0.12)
Added:
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait/
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait.pm
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm
branches/upstream/libmoosex-getopt-perl/current/t/006_metaclass_traits.t
branches/upstream/libmoosex-getopt-perl/current/t/007_nogetopt_trait.t
Removed:
branches/upstream/libmoosex-getopt-perl/current/MANIFEST.SKIP
Modified:
branches/upstream/libmoosex-getopt-perl/current/Build.PL
branches/upstream/libmoosex-getopt-perl/current/ChangeLog
branches/upstream/libmoosex-getopt-perl/current/MANIFEST
branches/upstream/libmoosex-getopt-perl/current/META.yml
branches/upstream/libmoosex-getopt-perl/current/Makefile.PL
branches/upstream/libmoosex-getopt-perl/current/README
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute.pm
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Strict.pm
branches/upstream/libmoosex-getopt-perl/current/t/001_basic.t
Modified: branches/upstream/libmoosex-getopt-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/Build.PL?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/Build.PL (original)
+++ branches/upstream/libmoosex-getopt-perl/current/Build.PL Mon Mar 17 02:47:11 2008
@@ -6,10 +6,11 @@
module_name => 'MooseX::Getopt',
license => 'perl',
requires => {
- 'Moose' => '0.19',
+ 'Moose' => '0.39',
'Getopt::Long' => '2.34',
},
optional => {
+ 'Getopt::Long::Descriptive' => 0,
},
build_requires => {
'Test::More' => '0.62',
Modified: branches/upstream/libmoosex-getopt-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/ChangeLog?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/ChangeLog (original)
+++ branches/upstream/libmoosex-getopt-perl/current/ChangeLog Mon Mar 17 02:47:11 2008
@@ -1,19 +1,35 @@
Revision history for Perl extension MooseX-Getopt
+
+0.12 Fri. March 14, 2008
+ ~~ updated copyright dates ~~
+
+ - upped the Moose dependency to support
+ the custom metaclass traits
+ - added Getopt::Long::Descriptive as an
+ optional dependency
+
+ * MooseX::Getopt
+ MooseX::Getopt::Meta::Attribute
+ MooseX::Getopt::Meta::Attribute::Trait
+ MooseX::Getopt::Meta::Attribute::NoGetopt
+ MooseX::Getopt::Meta::Attribute::Trait::NoGetopt
+ - added support for custom metaclass traits
+ - added tests for this
0.11 Sun. Jan. 27, 2008
* MooseX::Getopt
- - Commandline option shouldn't be required in the
- case that the given "required" attribute has
- a default or a builder method.
+ - Commandline option shouldn't be required in the
+ case that the given "required" attribute has
+ a default or a builder method.
0.10 Wed. Jan. 23, 2008
* MooseX::Getopt
- - Support default configfile attribute when
- used with MooseX::ConfigFromFile-based roles
+ - Support default configfile attribute when
+ used with MooseX::ConfigFromFile-based roles
0.09 Tues. Jan. 22, 2008
* MooseX::Getopt
- - Use Getopt::Long::Descriptive if it's available
+ - Use Getopt::Long::Descriptive if it's available
0.08 Tues. Dec. 8, 2007
* MooseX::Getopt
Modified: branches/upstream/libmoosex-getopt-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/MANIFEST?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/MANIFEST (original)
+++ branches/upstream/libmoosex-getopt-perl/current/MANIFEST Mon Mar 17 02:47:11 2008
@@ -1,20 +1,23 @@
Build.PL
ChangeLog
-META.yml
+lib/MooseX/Getopt.pm
+lib/MooseX/Getopt/Meta/Attribute.pm
+lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
+lib/MooseX/Getopt/Meta/Attribute/Trait.pm
+lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm
+lib/MooseX/Getopt/OptionTypeMap.pm
+lib/MooseX/Getopt/Strict.pm
Makefile.PL
MANIFEST
-MANIFEST.SKIP
+META.yml
README
-lib/MooseX/Getopt.pm
-lib/MooseX/Getopt/OptionTypeMap.pm
-lib/MooseX/Getopt/Strict.pm
-lib/MooseX/Getopt/Meta/Attribute.pm
-lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
t/000_load.t
t/001_basic.t
t/002_custom_option_type.t
t/003_inferred_option_type.t
t/004_nogetop.t
t/005_strict.t
+t/006_metaclass_traits.t
+t/007_nogetopt_trait.t
t/pod.t
t/pod_coverage.t
Modified: branches/upstream/libmoosex-getopt-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/META.yml?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/META.yml (original)
+++ branches/upstream/libmoosex-getopt-perl/current/META.yml Mon Mar 17 02:47:11 2008
@@ -1,6 +1,6 @@
---
name: MooseX-Getopt
-version: 0.11
+version: 0.12
author:
- 'Stevan Little E<lt>stevan at iinteractive.comE<gt>'
- 'Brandon L. Black, E<lt>blblack at gmail.comE<gt>'
@@ -10,26 +10,32 @@
license: http://dev.perl.org/licenses/
requires:
Getopt::Long: 2.34
- Moose: 0.19
+ Moose: 0.39
build_requires:
Test::Exception: 0.21
Test::More: 0.62
provides:
MooseX::Getopt:
file: lib/MooseX/Getopt.pm
- version: 0.11
+ version: 0.12
MooseX::Getopt::Meta::Attribute:
file: lib/MooseX/Getopt/Meta/Attribute.pm
- version: 0.04
+ version: 0.05
MooseX::Getopt::Meta::Attribute::NoGetopt:
file: lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
+ version: 0.02
+ MooseX::Getopt::Meta::Attribute::Trait:
+ file: lib/MooseX/Getopt/Meta/Attribute/Trait.pm
+ version: 0.01
+ MooseX::Getopt::Meta::Attribute::Trait::NoGetopt:
+ file: lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm
version: 0.01
MooseX::Getopt::OptionTypeMap:
file: lib/MooseX/Getopt/OptionTypeMap.pm
version: 0.03
MooseX::Getopt::Strict:
file: lib/MooseX/Getopt/Strict.pm
-generated_by: Module::Build version 0.280801
+generated_by: Module::Build version 0.2808
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
Modified: branches/upstream/libmoosex-getopt-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/Makefile.PL?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/Makefile.PL (original)
+++ branches/upstream/libmoosex-getopt-perl/current/Makefile.PL Mon Mar 17 02:47:11 2008
@@ -1,17 +1,17 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.2808_01
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
use ExtUtils::MakeMaker;
WriteMakefile
(
- 'PL_FILES' => {},
- 'INSTALLDIRS' => 'site',
'NAME' => 'MooseX::Getopt',
- 'EXE_FILES' => [],
'VERSION_FROM' => 'lib/MooseX/Getopt.pm',
'PREREQ_PM' => {
- 'Test::More' => '0.62',
'Getopt::Long' => '2.34',
+ 'Moose' => '0.39',
'Test::Exception' => '0.21',
- 'Moose' => '0.19'
- }
+ 'Test::More' => '0.62'
+ },
+ 'INSTALLDIRS' => 'site',
+ 'EXE_FILES' => [],
+ 'PL_FILES' => {}
)
;
Modified: branches/upstream/libmoosex-getopt-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/README?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/README (original)
+++ branches/upstream/libmoosex-getopt-perl/current/README Mon Mar 17 02:47:11 2008
@@ -1,4 +1,4 @@
-MooseX::Getopt version 0.07
+MooseX::Getopt version 0.12
===========================
See the individual module documentation for more information
@@ -21,7 +21,7 @@
COPYRIGHT AND LICENCE
-Copyright (C) 2007 Infinity Interactive, Inc.
+Copyright (C) 2007-2008 Infinity Interactive, Inc.
http://www.iinteractive.com
Modified: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm Mon Mar 17 02:47:11 2008
@@ -9,7 +9,7 @@
use Getopt::Long (); # GLD uses it anyway, doesn't hurt
use constant HAVE_GLD => not not eval { require Getopt::Long::Descriptive };
-our $VERSION = '0.11';
+our $VERSION = '0.12';
our $AUTHORITY = 'cpan:STEVAN';
has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt");
@@ -107,7 +107,11 @@
foreach my $opt ( @{ $params{options} } ) {
push @options, $opt->{opt_string};
- $name_to_init_arg{ $opt->{name} } = $opt->{init_arg};
+
+ my $identifier = $opt->{name};
+ $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names
+
+ $name_to_init_arg{$identifier} = $opt->{init_arg};
}
return ( \@options, \%name_to_init_arg );
@@ -128,7 +132,10 @@
},
];
- $name_to_init_arg{ $opt->{name} } = $opt->{init_arg};
+ my $identifier = $opt->{name};
+ $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names
+
+ $name_to_init_arg{$identifier} = $opt->{init_arg};
}
return ( \@options, \%name_to_init_arg );
@@ -137,12 +144,27 @@
sub _compute_getopt_attrs {
my $class = shift;
grep {
- $_->isa("MooseX::Getopt::Meta::Attribute")
+ $_->does("MooseX::Getopt::Meta::Attribute::Trait")
or
$_->name !~ /^_/
- &&
- !$_->isa('MooseX::Getopt::Meta::Attribute::NoGetopt')
+ } grep {
+ !$_->does('MooseX::Getopt::Meta::Attribute::Trait::NoGetopt')
} $class->meta->compute_all_applicable_attributes
+}
+
+sub _get_cmd_flags_for_attr {
+ my ( $class, $attr ) = @_;
+
+ my $flag = $attr->name;
+
+ my @aliases;
+
+ if ($attr->does('MooseX::Getopt::Meta::Attribute::Trait')) {
+ $flag = $attr->cmd_flag if $attr->has_cmd_flag;
+ @aliases = @{ $attr->cmd_aliases } if $attr->has_cmd_aliases;
+ }
+
+ return ( $flag, @aliases );
}
sub _attrs_to_options {
@@ -151,18 +173,9 @@
my @options;
foreach my $attr ($class->_compute_getopt_attrs) {
- my $name = $attr->name;
-
- my $aliases;
-
- if ($attr->isa('MooseX::Getopt::Meta::Attribute')) {
- $name = $attr->cmd_flag if $attr->has_cmd_flag;
- $aliases = $attr->cmd_aliases if $attr->has_cmd_aliases;
- }
-
- my $opt_string = $aliases
- ? join(q{|}, $name, @$aliases)
- : $name;
+ my ( $flag, @aliases ) = $class->_get_cmd_flags_for_attr($attr);
+
+ my $opt_string = join(q{|}, $flag, @aliases);
if ($attr->has_type_constraint) {
my $type_name = $attr->type_constraint->name;
@@ -172,7 +185,7 @@
}
push @options, {
- name => $name,
+ name => $flag,
init_arg => $attr->init_arg,
opt_string => $opt_string,
required => $attr->is_required && !$attr->has_default && !$attr->has_builder,
@@ -412,7 +425,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>
Modified: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute.pm?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute.pm Mon Mar 17 02:47:11 2008
@@ -3,31 +3,11 @@
use Moose;
use Moose::Util::TypeConstraints;
-our $VERSION = '0.04';
+our $VERSION = '0.05';
our $AUTHORITY = 'cpan:STEVAN';
extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
-
-has 'cmd_flag' => (
- is => 'rw',
- isa => 'Str',
- predicate => 'has_cmd_flag',
-);
-
-# This subtype is to support scalar -> arrayref coercion
-# without polluting the built-in types
-subtype '_MooseX_Getopt_CmdAliases' => as 'ArrayRef';
-
-coerce '_MooseX_Getopt_CmdAliases'
- => from 'Str'
- => via { [$_] };
-
-has 'cmd_aliases' => (
- is => 'rw',
- isa => '_MooseX_Getopt_CmdAliases',
- predicate => 'has_cmd_aliases',
- coerce => 1,
-);
+ with 'MooseX::Getopt::Meta::Attribute::Trait';
no Moose;
@@ -129,7 +109,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>
Modified: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm Mon Mar 17 02:47:11 2008
@@ -2,10 +2,11 @@
package MooseX::Getopt::Meta::Attribute::NoGetopt;
use Moose;
-our $VERSION = '0.01';
+our $VERSION = '0.02';
our $AUTHORITY = 'cpan:STEVAN';
extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
+ with 'MooseX::Getopt::Meta::Attribute::Trait::NoGetopt';
no Moose;
@@ -69,7 +70,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>
Added: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait.pm?rev=17712&op=file
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait.pm (added)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait.pm Mon Mar 17 02:47:11 2008
@@ -1,0 +1,124 @@
+
+package MooseX::Getopt::Meta::Attribute::Trait;
+use Moose::Role;
+use Moose::Util::TypeConstraints;
+
+our $VERSION = '0.01';
+our $AUTHORITY = 'cpan:STEVAN';
+
+has 'cmd_flag' => (
+ is => 'rw',
+ isa => 'Str',
+ predicate => 'has_cmd_flag',
+);
+
+# This subtype is to support scalar -> arrayref coercion
+# without polluting the built-in types
+subtype '_MooseX_Getopt_CmdAliases' => as 'ArrayRef';
+
+coerce '_MooseX_Getopt_CmdAliases'
+ => from 'Str'
+ => via { [$_] };
+
+has 'cmd_aliases' => (
+ is => 'rw',
+ isa => '_MooseX_Getopt_CmdAliases',
+ predicate => 'has_cmd_aliases',
+ coerce => 1,
+);
+
+no Moose::Role;
+
+# register this as a metaclass alias ...
+package # stop confusing PAUSE
+ Moose::Meta::Attribute::Custom::Trait::Getopt;
+sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' }
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+MooseX::Getopt::Meta::Attribute::Trait - Optional meta attribute trait for custom option names
+
+=head1 SYNOPSIS
+
+ package App;
+ use Moose;
+
+ with 'MooseX::Getopt';
+
+ has 'data' => (
+ traits => [ 'Getopt' ],
+ is => 'ro',
+ isa => 'Str',
+ default => 'file.dat',
+
+ # tells MooseX::Getopt to use --somedata as the
+ # command line flag instead of the normal
+ # autogenerated one (--data)
+ cmd_flag => 'somedata',
+
+ # tells MooseX::Getopt to also allow --moosedata,
+ # -m, and -d as aliases for this same option on
+ # the commandline.
+ cmd_aliases => [qw/ moosedata m d /],
+
+ # Or, you can use a plain scalar for a single alias:
+ cmd_aliases => 'm',
+ );
+
+=head1 DESCRIPTION
+
+This is a custom attribute metaclass trait which can be used to
+specify a the specific command line flag to use instead of the
+default one which L<MooseX::Getopt> will create for you.
+
+=head1 METHODS
+
+These methods are of little use to most users, they are used interally
+within L<MooseX::Getopt>.
+
+=over 4
+
+=item B<cmd_flag>
+
+Changes the commandline flag to be this value, instead of the default,
+which is the same as the attribute name.
+
+=item B<cmd_aliases>
+
+Adds more aliases for this commandline flag, useful for short options
+and such.
+
+=item B<has_cmd_flag>
+
+=item B<has_cmd_aliases>
+
+=item B<meta>
+
+=back
+
+=head1 BUGS
+
+All complex software has bugs lurking in it, and this module is no
+exception. If you find a bug please either email me, or add the bug
+to cpan-RT.
+
+=head1 AUTHOR
+
+Stevan Little E<lt>stevan at iinteractive.comE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2007-2008 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Added: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm?rev=17712&op=file
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm (added)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm Mon Mar 17 02:47:11 2008
@@ -1,0 +1,75 @@
+
+package MooseX::Getopt::Meta::Attribute::Trait::NoGetopt;
+use Moose::Role;
+
+our $VERSION = '0.01';
+our $AUTHORITY = 'cpan:STEVAN';
+
+no Moose::Role;
+
+# register this as a metaclass alias ...
+package # stop confusing PAUSE
+ Moose::Meta::Attribute::Custom::Trait::NoGetopt;
+sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait::NoGetopt' }
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+MooseX::Getopt::Meta::Attribute::Trait::NoGetopt - Optional meta attribute trait for ignoring params
+
+=head1 SYNOPSIS
+
+ package App;
+ use Moose;
+
+ with 'MooseX::Getopt';
+
+ has 'data' => (
+ traits => [ 'NoGetopt' ], # do not attempt to capture this param
+ is => 'ro',
+ isa => 'Str',
+ default => 'file.dat',
+ );
+
+=head1 DESCRIPTION
+
+This is a custom attribute metaclass trait which can be used to
+specify that a specific attribute should B<not> be processed by
+C<MooseX::Getopt>. All you need to do is specify the C<NoGetopt>
+metaclass trait.
+
+ has 'foo' => (traits => [ 'NoGetopt', ... ], ... );
+
+=head1 METHODS
+
+=over 4
+
+=item B<meta>
+
+=back
+
+=head1 BUGS
+
+All complex software has bugs lurking in it, and this module is no
+exception. If you find a bug please either email me, or add the bug
+to cpan-RT.
+
+=head1 AUTHOR
+
+Stevan Little E<lt>stevan at iinteractive.comE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2007-2008 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Modified: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm Mon Mar 17 02:47:11 2008
@@ -106,7 +106,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>
Modified: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Strict.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Strict.pm?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Strict.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Strict.pm Mon Mar 17 02:47:11 2008
@@ -50,7 +50,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright 2007 by Infinity Interactive, Inc.
+Copyright 2007-2008 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>
Modified: branches/upstream/libmoosex-getopt-perl/current/t/001_basic.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/t/001_basic.t?rev=17712&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/t/001_basic.t (original)
+++ branches/upstream/libmoosex-getopt-perl/current/t/001_basic.t Mon Mar 17 02:47:11 2008
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 53;
+use Test::More tests => 69;
BEGIN {
use_ok('MooseX::Getopt');
@@ -79,6 +79,14 @@
}
+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 = ();
Added: branches/upstream/libmoosex-getopt-perl/current/t/006_metaclass_traits.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/t/006_metaclass_traits.t?rev=17712&op=file
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/t/006_metaclass_traits.t (added)
+++ branches/upstream/libmoosex-getopt-perl/current/t/006_metaclass_traits.t Mon Mar 17 02:47:11 2008
@@ -1,0 +1,226 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 69;
+use Test::Moose;
+
+BEGIN {
+ use_ok('MooseX::Getopt');
+}
+
+{
+ package App;
+ use Moose;
+
+ with 'MooseX::Getopt';
+
+ has 'data' => (
+ traits => [ 'MooseX::Getopt::Meta::Attribute::Trait' ],
+ is => 'ro',
+ isa => 'Str',
+ default => 'file.dat',
+ cmd_flag => 'f',
+ );
+
+ has 'cow' => (
+ traits => [ 'Getopt' ],
+ is => 'ro',
+ isa => 'Str',
+ default => 'moo',
+ cmd_aliases => [qw/ moocow m c /],
+ );
+
+ has 'horse' => (
+ traits => [ 'Getopt' ],
+ 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' => (
+ traits => [ 'Getopt' ],
+ 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');
+ does_ok($attr, 'MooseX::Getopt::Meta::Attribute::Trait');
+
+ can_ok($attr, 'cmd_flag');
+ can_ok($attr, 'cmd_aliases');
+}
+
+{
+ local @ARGV = ();
+
+ my $app = App->new_with_options;
+ 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_with_options;
+ 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_with_options;
+ 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_with_options;
+ 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_with_options;
+ 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_with_options;
+ 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_with_options;
+ isa_ok($app, 'App');
+ is($app->cow, 42, 'cmd_alias, but not using it');
+}
+{
+ local @ARGV = ('--moocow', '88');
+ my $app = App->new_with_options;
+ isa_ok($app, 'App');
+ is($app->cow, 88, 'cmd_alias, using long one');
+}
+{
+ local @ARGV = ('-c', '99');
+ my $app = App->new_with_options;
+ 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_with_options;
+ isa_ok($app, 'App');
+ is($app->horse, 123, 'cmd_alias+cmd_flag, using flag');
+}
+{
+ local @ARGV = ('-x', '321');
+ my $app = App->new_with_options;
+ 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_with_options;
+ 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_with_options;
+ 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');
+}
Added: branches/upstream/libmoosex-getopt-perl/current/t/007_nogetopt_trait.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmoosex-getopt-perl/current/t/007_nogetopt_trait.t?rev=17712&op=file
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/t/007_nogetopt_trait.t (added)
+++ branches/upstream/libmoosex-getopt-perl/current/t/007_nogetopt_trait.t Mon Mar 17 02:47:11 2008
@@ -1,0 +1,102 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 9;
+use Test::Exception;
+
+BEGIN {
+ use_ok('MooseX::Getopt');
+}
+
+{
+ package App;
+ use Moose;
+
+ with 'MooseX::Getopt';
+
+ has 'data' => (
+ traits => ['Getopt'],
+ is => 'ro',
+ isa => 'Str',
+ default => 'file.dat',
+ cmd_flag => 'f',
+ );
+
+ has 'cow' => (
+ traits => ['Getopt'],
+ is => 'ro',
+ isa => 'Str',
+ default => 'moo',
+ cmd_aliases => [qw/ moocow m c /],
+ );
+
+ has 'horse' => (
+ traits => ['Getopt'],
+ 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' => (
+ traits => ['NoGetopt'],
+ is => 'ro',
+ isa => 'Int',
+ default => 713
+ );
+
+ has '_private_stuff_cmdline' => (
+ traits => ['Getopt'],
+ is => 'ro',
+ isa => 'Int',
+ default => 832,
+ cmd_flag => 'p',
+ );
+
+}
+
+{
+ local @ARGV = ();
+
+ my $app = App->new_with_options;
+ 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' );
+ is($app->private_stuff, 713, '... private stuff is 713 as expected');
+}
+
+{
+ local @ARGV = (qw/--private_stuff 317/);
+
+ throws_ok { App->new_with_options } qr/Unknown option: private_stuff/;
+}
More information about the Pkg-perl-cvs-commits
mailing list