X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FConfigFromFile.pm;h=bb5b984a028e0457d7dcd6e7168a398459901407;hb=36452fa7728d78e7d36219bc3666be627537cfd1;hp=2de2688d3243328a3f5df71ea706f8f7d0c9c388;hpb=7acf2fe9c4c170a0a431d3d2a92c73613c7aea2b;p=gitmo%2FMooseX-ConfigFromFile.git diff --git a/lib/MooseX/ConfigFromFile.pm b/lib/MooseX/ConfigFromFile.pm index 2de2688..bb5b984 100644 --- a/lib/MooseX/ConfigFromFile.pm +++ b/lib/MooseX/ConfigFromFile.pm @@ -1,20 +1,21 @@ package MooseX::ConfigFromFile; use Moose::Role; -use MooseX::Types::Path::Class qw( File ); +use MooseX::Types::Path::Tiny 'Path'; use Try::Tiny qw/ try /; use Carp qw(croak); use namespace::autoclean; -our $VERSION = '0.04'; +our $VERSION = '0.07'; requires 'get_config_from_file'; has configfile => ( is => 'ro', - isa => File, + isa => Path, coerce => 1, predicate => 'has_configfile', + do { try { require MooseX::Getopt; (traits => ['Getopt']) } }, ); sub new_with_config { @@ -126,8 +127,9 @@ during its normal C. =head2 configfile -This is a L object which can be coerced from a regular pathname -string. This is the file your attributes are loaded from. You can add a default +This is a L object which can be coerced from a regular pathname +string or any object that supports stringification. +This is the file your attributes are loaded from. You can add a default configfile in the consuming class and it will be honored at the appropriate time (note that a simple sub declaration is not sufficient, as there is already a sub by that name being added by Moose as the attribute reader) @@ -138,6 +140,10 @@ Note that you can alternately just provide a C method which returns the config file when called - this will be used in preference to the default of the attribute. +If you have L installed, this attribute will also have the +C trait supplied, so you can also set the configfile from the +command line. + =head1 Class Methods =head2 new_with_config @@ -158,7 +164,7 @@ a hashref of arguments to pass to C which are sourced from the configfile =head1 COPYRIGHT -Copyright (c) 2007 - 2009 the MooseX::ConfigFromFile "AUTHOR" and "CONTRIBUTORS" as listed below. +Copyright (c) - the MooseX::ConfigFromFile "AUTHOR" and "CONTRIBUTORS" as listed below. =head1 AUTHOR @@ -168,7 +174,7 @@ Brandon L. Black, Eblblack@gmail.comE =over -=item Tomas Doran C<< >> (current maintainer). +=item Tomas Doran =item Karen Etheridge