Merge
Tomas Doran [Thu, 27 Aug 2009 00:29:14 +0000 (01:29 +0100)]
15 files changed:
.gitignore [new file with mode: 0644]
ChangeLog
MANIFEST [deleted file]
MANIFEST.SKIP
Makefile.PL
README
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
t/005_strict.t
t/008_configfromfile.t
t/101_argv_bug.t [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..dc5027d
--- /dev/null
@@ -0,0 +1,8 @@
+pm_to_blib
+inc
+blib
+Makefile
+Makefile.old
+META.yml
+MANIFEST
+MANIFEST.bak
index 6a3ce26..5c800d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,22 @@
 Revision history for Perl extension MooseX-Getopt
 
-0.19
   * MooseX::Getopt
+    - Enable and document the argv parameter to the constructor.
     - Applied patches in RT43200 and RT43255
 
+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)
+    - Add support for --usage/--help/--? (drew@drewtaylor.com)
+    - Fix new_with_options to accept a hashref (DOUGDUDE@cpan.org)
+
+  * Tests
+    - Fix warning from tests with new Moose (t0m)
+    - Fix tests on Win32 from RT#44909 (taro-nishino)
+
 0.18 Thu. April 9 2009
   * MooseX::Getopt::Dashes
     - New module, for converting undercores to dashes (ilmari)
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644 (file)
index bec9b4b..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,38 +0,0 @@
-ChangeLog
-inc/Module/AutoInstall.pm
-inc/Module/Install.pm
-inc/Module/Install/AutoInstall.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Include.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
-lib/MooseX/Getopt.pm
-lib/MooseX/Getopt/Dashes.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
-META.yml
-README
-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/008_configfromfile.t
-t/009_gld_and_explicit_options.t
-t/010_dashes.t
-t/100_gld_default_bug.t
-t/pod.t
-t/pod_coverage.t
index 3de3ebc..45ff306 100644 (file)
@@ -1,3 +1,4 @@
+^.git
 ^_build
 ^Build$
 ^blib
@@ -16,4 +17,5 @@ cover_db
 \.old$
 ^#.*#$
 ^\.#
-^TODO$
\ No newline at end of file
+^TODO$
+^MooseX-Getopt
index 3ab0c74..681fd58 100644 (file)
@@ -15,6 +15,6 @@ build_requires 'Test::More'       => '0.62';
 build_requires 'Test::Exception'  => '0.21';
 
 tests_recursive();
-auto_install;
+auto_manifest();
 
 WriteAll;
diff --git a/README b/README
index 3978368..5c6b104 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-MooseX::Getopt version 0.18
+MooseX::Getopt version 0.20
 ===========================
 
 See the individual module documentation for more information
index d310230..0321f62 100644 (file)
@@ -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.18';
+our $VERSION   = '0.20';
 our $AUTHORITY = 'cpan:STEVAN';
 
 has ARGV       => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt");
@@ -69,7 +69,7 @@ sub new_with_options {
 sub _parse_argv {
     my ( $class, %params ) = @_;
 
-    local @ARGV = @{ $params{argv} || \@ARGV };
+    local @ARGV = @{ $params{params}{argv} || \@ARGV };
 
     my ( $opt_spec, $name_to_init_arg ) = ( HAVE_GLD ? $class->_gld_spec(%params) : $class->_traditional_spec(%params) );
 
@@ -199,7 +199,10 @@ sub _attrs_to_options {
 
         my $opt_string = join(q{|}, $flag, @aliases);
 
-        if ($attr->has_type_constraint) {
+        if ($attr->name eq 'configfile') {
+            $opt_string .= '=s';
+        }
+        elsif ($attr->has_type_constraint) {
             my $type = $attr->type_constraint;
             if (MooseX::Getopt::OptionTypeMap->has_option_type($type)) {
                 $opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type)
@@ -282,8 +285,8 @@ 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
-to have the leading underscore in thier name, you can do this:
+to L<MooseX::Getopt::Meta::Attribute>. If you don't want your accessors
+to have the leading underscore in their name, you can do this:
 
   # for read/write attributes
   has '_foo' => (accessor => 'foo', ...);
@@ -420,6 +423,9 @@ This method will take a set of default C<%params> and then collect
 params from the command line (possibly overriding those in C<%params>)
 and then return a newly constructed object.
 
+The special parameter C<argv>, if specified should point to an array  
+reference with an array to use instead of C<@ARGV>.
+
 If L<Getopt::Long/GetOptions> fails (due to invalid arguments),
 C<new_with_options> will throw an exception.
 
@@ -432,7 +438,7 @@ B<documentation> option for each attribute to document.
   --help
   --usage
 
-If you have L<Getopt::Long::Descriptive> a the C<usage> param is also passed to
+If you have L<Getopt::Long::Descriptive> the C<usage> param is also passed to
 C<new>.
 
 =item B<ARGV>
index f71ea67..7bb6477 100644 (file)
@@ -3,7 +3,7 @@ package MooseX::Getopt::Meta::Attribute;
 use Moose;
 use Moose::Util::TypeConstraints;
 
-our $VERSION   = '0.18';
+our $VERSION   = '0.20';
 our $AUTHORITY = 'cpan:STEVAN';
 
 extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
index 69be43d..1d98a83 100644 (file)
@@ -2,7 +2,7 @@
 package MooseX::Getopt::Meta::Attribute::NoGetopt;
 use Moose;
 
-our $VERSION   = '0.18';
+our $VERSION   = '0.20';
 our $AUTHORITY = 'cpan:STEVAN';
 
 extends 'Moose::Meta::Attribute'; # << Moose extending Moose :)
index 3171837..74177d5 100644 (file)
@@ -3,7 +3,7 @@ package MooseX::Getopt::Meta::Attribute::Trait;
 use Moose::Role;
 use Moose::Util::TypeConstraints;
 
-our $VERSION   = '0.18';
+our $VERSION   = '0.20';
 our $AUTHORITY = 'cpan:STEVAN';
 
 has 'cmd_flag' => (
index c618f0b..180d705 100644 (file)
@@ -2,7 +2,7 @@
 package MooseX::Getopt::Meta::Attribute::Trait::NoGetopt;
 use Moose::Role;
 
-our $VERSION   = '0.18';
+our $VERSION   = '0.20';
 our $AUTHORITY = 'cpan:STEVAN';
 
 no Moose::Role;
index b0157f1..f634726 100644 (file)
@@ -4,7 +4,7 @@ package MooseX::Getopt::OptionTypeMap;
 use Moose 'confess', 'blessed';
 use Moose::Util::TypeConstraints 'find_type_constraint';
 
-our $VERSION   = '0.18';
+our $VERSION   = '0.20';
 our $AUTHORITY = 'cpan:STEVAN';
 
 my %option_type_map = (
index 8a8d634..206cb64 100644 (file)
@@ -70,14 +70,6 @@ BEGIN {
         isa      => 'Int',
         default  => 713
     );
-
-    has '_private_stuff_cmdline' => (
-        is        => 'ro',
-        isa       => 'Int',
-        default   => 832,
-        cmd_flag  => 'p',
-    );
-
 }
 
 {
index 93700b9..292e6f5 100644 (file)
@@ -5,6 +5,7 @@ use warnings;
 
 use Test::Exception;
 use Test::More;
+use File::Spec;
 
 if ( !eval { require MooseX::ConfigFromFile } )
 {
@@ -55,7 +56,8 @@ else
             optional_from_config => 'from_config_2',
         );
 
-        if ( $file ne '/notused/default' ) {
+        my $cpath = File::Spec->canonpath('/notused/default');
+        if ( $file ne $cpath ) {
             $config{config_from_override} = 1;
         }
 
@@ -70,7 +72,7 @@ else
     extends 'App';
 
     has '+configfile' => (
-        default => '/notused/default',
+        default => File::Spec->canonpath('/notused/default'),
     );
 }
 
@@ -88,7 +90,7 @@ else
         ok(  !$app->config_from_override,
             '... config_from_override false as expected' );
 
-        is( $app->configfile, '/notused/default',
+        is( $app->configfile, File::Spec->canonpath('/notused/default'),
             '... configfile is /notused/default as expected' );
     }
 }
@@ -111,7 +113,7 @@ else
         ok( $app->config_from_override,
              '... config_from_override true as expected' );
 
-        is( $app->configfile, '/notused',
+        is( $app->configfile, File::Spec->canonpath('/notused'),
             '... configfile is /notused as expected' );
     }
 }
diff --git a/t/101_argv_bug.t b/t/101_argv_bug.t
new file mode 100644 (file)
index 0000000..6d75ad5
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use MooseX::Getopt;
+
+{
+    package App;
+    use Moose;
+
+    with 'MooseX::Getopt';
+
+    has 'length' => (
+        is      => 'ro',
+        isa     => 'Int',
+        default => 24,
+    );
+
+    has 'verbose' => (
+        is     => 'ro',
+        isa    => 'Bool',
+        default => 0,
+    );
+    no Moose;
+}
+
+{
+    my $app = App->new_with_options(argv => [ '--verbose', '--length', 50 ]);
+    isa_ok($app, 'App');
+
+    ok($app->verbose, '... verbosity is turned on as expected');
+    is($app->length, 50, '... length is 50 as expected');
+}
+