From: Ryan D Johnson Date: Wed, 23 Apr 2008 18:54:45 +0000 (+0000) Subject: Getopt shouldn't require ConfigFromFile role applied at same level X-Git-Tag: 0_15~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f1ec7c0c8860dae99efddfcbba9b30b4dd4bb3f;p=gitmo%2FMooseX-Getopt.git Getopt shouldn't require ConfigFromFile role applied at same level --- diff --git a/ChangeLog b/ChangeLog index 444fca5..980d80b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ Revision history for Perl extension MooseX-Getopt - Commandline option shouldn't be required in the case that the given "required" attribute has been loaded from config (MooseX::ConfigFromFile) + - Support for MooseX::ConfigFromFile shouldn't require + that role be added at the same level as Getopt. 0.12 Fri. March 14, 2008 ~~ updated copyright dates ~~ diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 8c6385f..97d59c8 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -27,7 +27,7 @@ sub new_with_options { $opt_parser->getoptions( "configfile=s" => \$configfile ); if(!defined $configfile) { - my $cfmeta = $class->meta->get_attribute('configfile'); + my $cfmeta = $class->meta->find_attribute_by_name('configfile'); $configfile = $cfmeta->default if $cfmeta->has_default; } diff --git a/t/008_configfromfile.t b/t/008_configfromfile.t index affcd7e..93700b9 100644 --- a/t/008_configfromfile.t +++ b/t/008_configfromfile.t @@ -12,7 +12,7 @@ if ( !eval { require MooseX::ConfigFromFile } ) } else { - plan tests => 24; + plan tests => 25; } { @@ -150,6 +150,27 @@ else '... optional_from_config is undef as expected' ); } +{ + package BaseApp::WithConfig; + use Moose; + with 'MooseX::ConfigFromFile'; + + sub get_config_from_file { return {}; } +} + +{ + package DerivedApp::Getopt; + use Moose; + extends 'BaseApp::WithConfig'; + with 'MooseX::Getopt'; +} + +# With DerivedApp, the Getopt role was applied at a different level +# than the ConfigFromFile role +{ + lives_ok { DerivedApp::Getopt->new_with_options } 'Can create DerivedApp'; +} + sub app_ok { my $app = shift;