r23027 - in /branches/upstream/libmoosex-getopt-perl/current: ./ inc/Module/ inc/Module/Install/ lib/MooseX/ lib/MooseX/Getopt/ t/
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Fri Jul 11 14:12:02 UTC 2008
Author: eloy
Date: Fri Jul 11 14:12:02 2008
New Revision: 23027
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=23027
Log:
[svn-upgrade] Integrating new upstream version, libmoosex-getopt-perl (0.14)
Added:
branches/upstream/libmoosex-getopt-perl/current/t/009_gld_and_explicit_options.t
branches/upstream/libmoosex-getopt-perl/current/t/100_gld_default_bug.t
Modified:
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/inc/Module/Install.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/AutoInstall.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Base.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Can.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Fetch.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Include.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Makefile.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Metadata.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Win32.pm
branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/WriteAll.pm
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm
branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm
Modified: branches/upstream/libmoosex-getopt-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/ChangeLog?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/ChangeLog (original)
+++ branches/upstream/libmoosex-getopt-perl/current/ChangeLog Fri Jul 11 14:12:02 2008
@@ -1,4 +1,18 @@
Revision history for Perl extension MooseX-Getopt
+
+0.14 Thurs. July 10, 2008
+ * MooseX::Getopt::OptionTypeMap
+ - Change 'Float' which doesn't exist to 'Num' which does (perigrin)
+
+ * MooseX::Getopt
+ - removed the default handling with Getopt::Long::Descriptive
+ as it would override constructor parameters and that was
+ bad. Besides, Moose will just DWIM on this anyway. (stevan)
+ - added test for it (stevan)
+
+ * t/
+ - fixed Getopt::Long::Descriptive specific tests to only run
+ if Getopt::Long::Descriptive is there (stevan)
0.13 Saturday, May 24, 2008
* MooseX::Getopt
Modified: branches/upstream/libmoosex-getopt-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/MANIFEST?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/MANIFEST (original)
+++ branches/upstream/libmoosex-getopt-perl/current/MANIFEST Fri Jul 11 14:12:02 2008
@@ -30,5 +30,7 @@
t/006_metaclass_traits.t
t/007_nogetopt_trait.t
t/008_configfromfile.t
+t/009_gld_and_explicit_options.t
+t/100_gld_default_bug.t
t/pod.t
t/pod_coverage.t
Modified: branches/upstream/libmoosex-getopt-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/META.yml?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/META.yml (original)
+++ branches/upstream/libmoosex-getopt-perl/current/META.yml Fri Jul 11 14:12:02 2008
@@ -6,7 +6,7 @@
Test::Exception: 0.21
Test::More: 0.62
distribution_type: module
-generated_by: 'Module::Install version 0.73'
+generated_by: 'Module::Install version 0.75'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
@@ -20,5 +20,4 @@
Getopt::Long: 2.37
Getopt::Long::Descriptive: 0
Moose: 0.43
-tests: t/*.t
-version: 0.13
+version: 0.14
Modified: branches/upstream/libmoosex-getopt-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/Makefile.PL?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/Makefile.PL (original)
+++ branches/upstream/libmoosex-getopt-perl/current/Makefile.PL Fri Jul 11 14:12:02 2008
@@ -1,4 +1,4 @@
-use inc::Module::Install;
+use inc::Module::Install 0.75;
name 'MooseX-Getopt';
license 'perl';
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install.pm Fri Jul 11 14:12:02 2008
@@ -30,7 +30,7 @@
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '0.73';
+ $VERSION = '0.75';
*inc::Module::Install::VERSION = *VERSION;
@inc::Module::Install::ISA = __PACKAGE__;
@@ -85,7 +85,7 @@
# Build.PL was formerly supported, but no longer is due to excessive
# difficulty in implementing every single feature twice.
-if ( $0 =~ /Build.PL$/i or -f 'Build.PL' ) { die <<"END_DIE" }
+if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" }
Module::Install no longer supports Build.PL.
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/AutoInstall.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/AutoInstall.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/AutoInstall.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/AutoInstall.pm Fri Jul 11 14:12:02 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Base.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Base.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Base.pm Fri Jul 11 14:12:02 2008
@@ -1,7 +1,7 @@
#line 1
package Module::Install::Base;
-$VERSION = '0.73';
+$VERSION = '0.75';
# Suspend handler for "redefined" warnings
BEGIN {
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Can.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Can.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Can.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Can.pm Fri Jul 11 14:12:02 2008
@@ -11,7 +11,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Fetch.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Fetch.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Fetch.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Fetch.pm Fri Jul 11 14:12:02 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Include.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Include.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Include.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Include.pm Fri Jul 11 14:12:02 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Makefile.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Makefile.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Makefile.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Makefile.pm Fri Jul 11 14:12:02 2008
@@ -7,7 +7,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Metadata.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Metadata.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Metadata.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Metadata.pm Fri Jul 11 14:12:02 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION $ISCORE @ISA};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
$ISCORE = 1;
@ISA = qw{Module::Install::Base};
}
@@ -30,6 +30,7 @@
requires
recommends
bundles
+ resources
};
sub Meta { shift }
@@ -72,7 +73,7 @@
my $version = shift || 0;
push @{ $self->{values}->{configure_requires} }, [ $module, $version ];
}
- $self->{values}{configure_requires};
+ $self->{values}->{configure_requires};
}
sub recommends {
@@ -82,7 +83,7 @@
my $version = shift || 0;
push @{ $self->{values}->{recommends} }, [ $module, $version ];
}
- $self->{values}{recommends};
+ $self->{values}->{recommends};
}
sub bundles {
@@ -92,7 +93,24 @@
my $version = shift || 0;
push @{ $self->{values}->{bundles} }, [ $module, $version ];
}
- $self->{values}{bundles};
+ $self->{values}->{bundles};
+}
+
+# Resource handling
+sub resources {
+ my $self = shift;
+ while ( @_ ) {
+ my $resource = shift or last;
+ my $value = shift or next;
+ push @{ $self->{values}->{resources} }, [ $resource, $value ];
+ }
+ $self->{values}->{resources};
+}
+
+sub repository {
+ my $self = shift;
+ $self->resources( repository => shift );
+ return 1;
}
# Aliases for build_requires that will have alternative
@@ -294,7 +312,7 @@
if (
Module::Install::_read($_[0]) =~ m/
^
- use \s*
+ (?:use|require) \s*
v?
([\d_\.]+)
\s* ;
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Win32.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Win32.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Win32.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/Win32.pm Fri Jul 11 14:12:02 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
Modified: branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/WriteAll.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/WriteAll.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/WriteAll.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/inc/Module/Install/WriteAll.pm Fri Jul 11 14:12:02 2008
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.73';
+ $VERSION = '0.75';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
Modified: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm?rev=23027&op=diff
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm (original)
+++ branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt.pm Fri Jul 11 14:12:02 2008
@@ -6,10 +6,12 @@
use MooseX::Getopt::Meta::Attribute;
use MooseX::Getopt::Meta::Attribute::NoGetopt;
+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.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:STEVAN';
has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt");
@@ -36,10 +38,16 @@
}
}
+ my $constructor_params = ( @params == 1 ? $params[0] : {@params} );
+
+ Carp::croak("Single parameters to new_with_options() must be a HASH ref")
+ unless ref($constructor_params) eq 'HASH';
+
my %processed = $class->_parse_argv(
options => [
$class->_attrs_to_options( $config_from_file )
- ]
+ ],
+ params => $constructor_params,
);
my $params = $config_from_file ? { %$config_from_file, %{$processed{params}} } : $processed{params};
@@ -121,13 +129,21 @@
my ( @options, %name_to_init_arg );
+ my $constructor_params = $params{params};
+
foreach my $opt ( @{ $params{options} } ) {
push @options, [
$opt->{opt_string},
$opt->{doc} || ' ', # FIXME new GLD shouldn't need this hack
{
- ( $opt->{required} ? (required => $opt->{required}) : () ),
- ( exists $opt->{default} ? (default => $opt->{default}) : () ),
+ ( ( $opt->{required} && !exists($constructor_params->{$opt->{init_arg}}) ) ? (required => $opt->{required}) : () ),
+ # NOTE:
+ # remove this 'feature' because it didn't work
+ # all the time, and so is better to not bother
+ # since Moose will handle the defaults just
+ # fine anyway.
+ # - SL
+ #( exists $opt->{default} ? (default => $opt->{default}) : () ),
},
];
@@ -189,7 +205,15 @@
init_arg => $attr->init_arg,
opt_string => $opt_string,
required => $attr->is_required && !$attr->has_default && !$attr->has_builder && !exists $config_from_file->{$attr->name},
- ( ( $attr->has_default && ( $attr->is_default_a_coderef xor $attr->is_lazy ) ) ? ( default => $attr->default({}) ) : () ),
+ # NOTE:
+ # this "feature" was breaking because
+ # Getopt::Long::Descriptive would return
+ # the default value as if it was a command
+ # line flag, which would then override the
+ # one passed into a constructor.
+ # See 100_gld_default_bug.t for an example
+ # - SL
+ #( ( $attr->has_default && ( $attr->is_default_a_coderef xor $attr->is_lazy ) ) ? ( default => $attr->default({}) ) : () ),
( $attr->has_documentation ? ( doc => $attr->documentation ) : () ),
}
}
@@ -425,6 +449,8 @@
Brandon L. Black, E<lt>blblack at gmail.comE<gt>
+Yuval Kogman, E<lt>nothingmuch at woobling.orgE<gt>
+
=head1 CONTRIBUTORS
Ryan D Johnson, E<lt>ryan at innerfence.comE<gt>
Modified: branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/lib/MooseX/Getopt/OptionTypeMap.pm?rev=23027&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 Fri Jul 11 14:12:02 2008
@@ -11,7 +11,7 @@
'Bool' => '!',
'Str' => '=s',
'Int' => '=i',
- 'Float' => '=f',
+ 'Num' => '=f',
'ArrayRef' => '=s@',
'HashRef' => '=s%',
);
Added: branches/upstream/libmoosex-getopt-perl/current/t/009_gld_and_explicit_options.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/t/009_gld_and_explicit_options.t?rev=23027&op=file
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/t/009_gld_and_explicit_options.t (added)
+++ branches/upstream/libmoosex-getopt-perl/current/t/009_gld_and_explicit_options.t Fri Jul 11 14:12:02 2008
@@ -1,0 +1,49 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+BEGIN {
+ eval 'use Getopt::Long::Descriptive;';
+ plan skip_all => "Getopt::Long::Descriptive required for this test" if $@;
+ plan tests => 5;
+ use_ok('MooseX::Getopt');
+}
+
+{
+ package Testing::Foo;
+ use Moose;
+
+ with 'MooseX::Getopt';
+
+ has 'bar' => (
+ is => 'ro',
+ isa => 'Int',
+ required => 1,
+ );
+
+ has 'baz' => (
+ is => 'ro',
+ isa => 'Int',
+ required => 1,
+ );
+}
+
+ at ARGV = qw(--bar 10);
+
+my $foo;
+lives_ok {
+ $foo = Testing::Foo->new_with_options(baz => 100);
+} '... this should work';
+isa_ok($foo, 'Testing::Foo');
+
+is($foo->bar, 10, '... got the right values');
+is($foo->baz, 100, '... got the right values');
+
+
+
+
+
Added: branches/upstream/libmoosex-getopt-perl/current/t/100_gld_default_bug.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-getopt-perl/current/t/100_gld_default_bug.t?rev=23027&op=file
==============================================================================
--- branches/upstream/libmoosex-getopt-perl/current/t/100_gld_default_bug.t (added)
+++ branches/upstream/libmoosex-getopt-perl/current/t/100_gld_default_bug.t Fri Jul 11 14:12:02 2008
@@ -1,0 +1,48 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+BEGIN {
+ eval 'use Getopt::Long::Descriptive;';
+ plan skip_all => "Getopt::Long::Descriptive required for this test" if $@;
+ plan tests => 5;
+ use_ok('MooseX::Getopt');
+}
+
+{
+ package Engine::Foo;
+ use Moose;
+
+ with 'MooseX::Getopt';
+
+ has 'nproc' => (
+ metaclass => 'Getopt',
+ is => 'ro',
+ isa => 'Int',
+ default => sub { 1 },
+ cmd_aliases => 'n',
+ );
+}
+
+ at ARGV = ();
+
+{
+ my $foo = Engine::Foo->new_with_options(nproc => 10);
+ isa_ok($foo, 'Engine::Foo');
+
+ is($foo->nproc, 10, '... got the right value (10), not the default (1)');
+}
+
+{
+ my $foo = Engine::Foo->new_with_options();
+ isa_ok($foo, 'Engine::Foo');
+
+ is($foo->nproc, 1, '... got the right value (1), without GLD needing to handle defaults');
+}
+
+
+
More information about the Pkg-perl-cvs-commits
mailing list