r11243 - in /trunk/libmoosex-getopt-perl: ./ debian/ lib/MooseX/ lib/MooseX/Getopt/ lib/MooseX/Getopt/Meta/ lib/MooseX/Getopt/Meta/Attribute/ t/
gregoa-guest at users.alioth.debian.org
gregoa-guest at users.alioth.debian.org
Sun Dec 16 19:48:07 UTC 2007
Author: gregoa-guest
Date: Sun Dec 16 19:48:07 2007
New Revision: 11243
URL: http://svn.debian.org/wsvn/?sc=1&rev=11243
Log:
New upstream release.
Added:
trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/Meta/Attribute/
- copied from r11242, branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Meta/Attribute/
trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/Strict.pm
- copied unchanged from r11242, branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/Strict.pm
trunk/libmoosex-getopt-perl/t/004_nogetop.t
- copied unchanged from r11242, branches/upstream/libmoosex-getopt-perl/current/t/004_nogetop.t
trunk/libmoosex-getopt-perl/t/005_strict.t
- copied unchanged from r11242, branches/upstream/libmoosex-getopt-perl/current/t/005_strict.t
Modified:
trunk/libmoosex-getopt-perl/Build.PL
trunk/libmoosex-getopt-perl/ChangeLog
trunk/libmoosex-getopt-perl/MANIFEST
trunk/libmoosex-getopt-perl/META.yml
trunk/libmoosex-getopt-perl/Makefile.PL
trunk/libmoosex-getopt-perl/README
trunk/libmoosex-getopt-perl/debian/changelog
trunk/libmoosex-getopt-perl/lib/MooseX/Getopt.pm
trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/Meta/Attribute.pm
trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/OptionTypeMap.pm
Modified: trunk/libmoosex-getopt-perl/Build.PL
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/Build.PL?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/Build.PL (original)
+++ trunk/libmoosex-getopt-perl/Build.PL Sun Dec 16 19:48:07 2007
@@ -7,7 +7,7 @@
license => 'perl',
requires => {
'Moose' => '0.19',
- 'Getopt::Long' => '2.35',
+ 'Getopt::Long' => '2.34',
},
optional => {
},
Modified: trunk/libmoosex-getopt-perl/ChangeLog
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/ChangeLog?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/ChangeLog (original)
+++ trunk/libmoosex-getopt-perl/ChangeLog Sun Dec 16 19:48:07 2007
@@ -1,4 +1,26 @@
Revision history for Perl extension MooseX-Getopt
+
+0.07 Tues. Dec. 4, 2007
+ * MooseX::Getopt::Meta::Attribute::NoGetopt
+ - fixed miscapitalization of NoGetopt in the docs
+
+0.06 Fri. Nov. 23, 2007
+ * MooseX::Getopt
+ - refactored &new_with_option some so that
+ this will work better with other Getopt
+ modules (nuffin)
+
+ + MooseX::Getopt::Strict
+ - version of MooseX::Getopt which requires
+ you to specify which attributes you want
+ processed explicity
+ - added tests for this
+
+ + MooseX::Getopt::Meta::Attribute::NoGetopt
+ - a custom meta-attribute which can be
+ used to specify that an attribute should
+ not be processed
+ - added tests for this
0.05 Tues. July 3, 2007
* MooseX::Getopt::OptionTypeMap
Modified: trunk/libmoosex-getopt-perl/MANIFEST
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/MANIFEST?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/MANIFEST (original)
+++ trunk/libmoosex-getopt-perl/MANIFEST Sun Dec 16 19:48:07 2007
@@ -7,10 +7,14 @@
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/pod.t
t/pod_coverage.t
Modified: trunk/libmoosex-getopt-perl/META.yml
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/META.yml?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/META.yml (original)
+++ trunk/libmoosex-getopt-perl/META.yml Sun Dec 16 19:48:07 2007
@@ -1,6 +1,6 @@
---
name: MooseX-Getopt
-version: 0.05
+version: 0.07
author:
- 'Stevan Little E<lt>stevan at iinteractive.comE<gt>'
- 'Brandon L. Black, E<lt>blblack at gmail.comE<gt>'
@@ -9,24 +9,27 @@
resources:
license: http://dev.perl.org/licenses/
requires:
- Getopt::Long: 2.35
+ Getopt::Long: 2.34
Moose: 0.19
build_requires:
Test::Exception: 0.21
Test::More: 0.62
provides:
- Moose::Meta::Attribute::Custom::Getopt:
- file: lib/MooseX/Getopt/Meta/Attribute.pm
MooseX::Getopt:
file: lib/MooseX/Getopt.pm
- version: 0.05
+ version: 0.07
MooseX::Getopt::Meta::Attribute:
file: lib/MooseX/Getopt/Meta/Attribute.pm
- version: 0.03
+ version: 0.04
+ MooseX::Getopt::Meta::Attribute::NoGetopt:
+ file: lib/MooseX/Getopt/Meta/Attribute/NoGetopt.pm
+ version: 0.01
MooseX::Getopt::OptionTypeMap:
file: lib/MooseX/Getopt/OptionTypeMap.pm
version: 0.03
-generated_by: Module::Build version 0.2805
+ MooseX::Getopt::Strict:
+ file: lib/MooseX/Getopt/Strict.pm
+generated_by: Module::Build version 0.2808
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
Modified: trunk/libmoosex-getopt-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/Makefile.PL?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/Makefile.PL (original)
+++ trunk/libmoosex-getopt-perl/Makefile.PL Sun Dec 16 19:48:07 2007
@@ -2,16 +2,16 @@
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.35',
+ 'Getopt::Long' => '2.34',
+ 'Moose' => '0.19',
'Test::Exception' => '0.21',
- 'Moose' => '0.19'
- }
+ 'Test::More' => '0.62'
+ },
+ 'INSTALLDIRS' => 'site',
+ 'EXE_FILES' => [],
+ 'PL_FILES' => {}
)
;
Modified: trunk/libmoosex-getopt-perl/README
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/README?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/README (original)
+++ trunk/libmoosex-getopt-perl/README Sun Dec 16 19:48:07 2007
@@ -1,4 +1,4 @@
-MooseX::Getopt version 0.05
+MooseX::Getopt version 0.07
===========================
See the individual module documentation for more information
Modified: trunk/libmoosex-getopt-perl/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/debian/changelog?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/debian/changelog (original)
+++ trunk/libmoosex-getopt-perl/debian/changelog Sun Dec 16 19:48:07 2007
@@ -1,3 +1,9 @@
+libmoosex-getopt-perl (0.07-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- gregor herrmann <gregor+debian at comodo.priv.at> Sun, 16 Dec 2007 20:46:05 +0100
+
libmoosex-getopt-perl (0.05-2) unstable; urgency=medium
[ Damyan Ivanov ]
Modified: trunk/libmoosex-getopt-perl/lib/MooseX/Getopt.pm
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/lib/MooseX/Getopt.pm?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/lib/MooseX/Getopt.pm (original)
+++ trunk/libmoosex-getopt-perl/lib/MooseX/Getopt.pm Sun Dec 16 19:48:07 2007
@@ -6,18 +6,82 @@
use MooseX::Getopt::OptionTypeMap;
use MooseX::Getopt::Meta::Attribute;
-
-our $VERSION = '0.05';
+use MooseX::Getopt::Meta::Attribute::NoGetopt;
+
+our $VERSION = '0.07';
our $AUTHORITY = 'cpan:STEVAN';
has ARGV => (is => 'rw', isa => 'ArrayRef');
has extra_argv => (is => 'rw', isa => 'ArrayRef');
sub new_with_options {
- my ($class, %params) = @_;
-
- my (@options, %name_to_init_arg);
- foreach my $attr ($class->meta->compute_all_applicable_attributes) {
+ my ($class, @params) = @_;
+
+ my %processed = $class->_parse_argv(
+ options => [
+ $class->_attrs_to_options( @params )
+ ]
+ );
+
+ $class->new(
+ ARGV => $processed{argv_copy},
+ extra_argv => $processed{argv},
+ @params, # explicit params to ->new
+ %{ $processed{params} }, # params from CLI
+ );
+}
+
+sub _parse_argv {
+ my ( $class, %params ) = @_;
+
+ local @ARGV = @{ $params{argv} || \@ARGV };
+
+ my ( @options, %name_to_init_arg, %options );
+
+ foreach my $opt ( @{ $params{options} } ) {
+ push @options, $opt->{opt_string};
+ $name_to_init_arg{ $opt->{name} } = $opt->{init_arg};
+ }
+
+ # Get a clean copy of the original @ARGV
+ my $argv_copy = [ @ARGV ];
+
+ {
+ local $SIG{__WARN__} = sub { die $_[0] };
+ Getopt::Long::GetOptions(\%options, @options);
+ }
+
+ # Get a copy of the Getopt::Long-mangled @ARGV
+ my $argv_mangled = [ @ARGV ];
+
+ return (
+ argv_copy => $argv_copy,
+ argv => $argv_mangled,
+ params => {
+ map {
+ $name_to_init_arg{$_} => $options{$_}
+ } keys %options,
+ }
+ );
+}
+
+sub _compute_getopt_attrs {
+ my $class = shift;
+ grep {
+ $_->isa("MooseX::Getopt::Meta::Attribute")
+ or
+ $_->name !~ /^_/
+ &&
+ !$_->isa('MooseX::Getopt::Meta::Attribute::NoGetopt')
+ } $class->meta->compute_all_applicable_attributes
+}
+
+sub _attrs_to_options {
+ my $class = shift;
+
+ my @options;
+
+ foreach my $attr ($class->_compute_getopt_attrs) {
my $name = $attr->name;
my $aliases;
@@ -26,12 +90,7 @@
$name = $attr->cmd_flag if $attr->has_cmd_flag;
$aliases = $attr->cmd_aliases if $attr->has_cmd_aliases;
}
- else {
- next if $name =~ /^_/;
- }
-
- $name_to_init_arg{$name} = $attr->init_arg;
-
+
my $opt_string = $aliases
? join(q{|}, $name, @$aliases)
: $name;
@@ -42,39 +101,17 @@
$opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type_name);
}
}
-
- push @options => $opt_string;
+
+ push @options, {
+ name => $name,
+ init_arg => $attr->init_arg,
+ opt_string => $opt_string,
+ required => $attr->is_required,
+ ( $attr->has_documentation ? ( doc => $attr->documentation ) : () ),
+ }
}
- my %options;
-
- # Get a clean copy of the original @ARGV
- my $argv_copy = [ @ARGV ];
-
- {
- local $SIG{__WARN__} = sub { die $_[0] };
- Getopt::Long::GetOptions(\%options, @options);
- }
-
- # Get a copy of the Getopt::Long-mangled @ARGV
- my $argv_mangled = [ @ARGV ];
-
- # Restore the original @ARGV;
- @ARGV = @$argv_copy;
-
- #use Data::Dumper;
- #warn Dumper \@options;
- #warn Dumper \%name_to_init_arg;
- #warn Dumper \%options;
-
- $class->new(
- ARGV => $argv_copy,
- extra_argv => $argv_mangled,
- %params,
- map {
- $name_to_init_arg{$_} => $options{$_}
- } keys %options,
- );
+ return @options;
}
no Moose::Role; 1;
@@ -125,6 +162,9 @@
You can use the attribute metaclass L<MooseX::Getopt::Meta::Attribute>
to get non-default commandline option names and aliases.
+You can use the attribute metaclass L<MooseX::Getopt::Meta::Attribute::NoGetOpt>
+to have C<MooseX::Getopt> ignore your attribute in the commandline options.
+
By default, attributes which start with an underscore are not given
commandline argument support, unless the attribute's metaclass is set
to L<MooseX::Getopt::Meta::Attribute>. If you don't want you accessors
Modified: trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/Meta/Attribute.pm
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/Meta/Attribute.pm?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/Meta/Attribute.pm (original)
+++ trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/Meta/Attribute.pm Sun Dec 16 19:48:07 2007
@@ -3,7 +3,7 @@
use Moose;
use Moose::Util::TypeConstraints;
-our $VERSION = '0.03';
+our $VERSION = '0.04';
our $AUTHORITY = 'cpan:STEVAN';
extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
@@ -16,9 +16,7 @@
# This subtype is to support scalar -> arrayref coercion
# without polluting the built-in types
-subtype '_MooseX_Getopt_CmdAliases'
- => as 'ArrayRef'
- => where { 1 };
+subtype '_MooseX_Getopt_CmdAliases' => as 'ArrayRef';
coerce '_MooseX_Getopt_CmdAliases'
=> from 'Str'
@@ -34,7 +32,8 @@
no Moose;
# register this as a metaclass alias ...
-package Moose::Meta::Attribute::Custom::Getopt;
+package # stop confusing PAUSE
+ Moose::Meta::Attribute::Custom::Getopt;
sub register_implementation { 'MooseX::Getopt::Meta::Attribute' }
1;
Modified: trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/OptionTypeMap.pm
URL: http://svn.debian.org/wsvn/trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/OptionTypeMap.pm?rev=11243&op=diff
==============================================================================
--- trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/OptionTypeMap.pm (original)
+++ trunk/libmoosex-getopt-perl/lib/MooseX/Getopt/OptionTypeMap.pm Sun Dec 16 19:48:07 2007
@@ -90,6 +90,8 @@
=item B<add_option_type_to_map ($type_name, $option_spec)>
+=item B<meta>
+
=back
=head1 BUGS
More information about the Pkg-perl-cvs-commits
mailing list