From: Vincent Pit Date: Sun, 5 Oct 2008 22:17:12 +0000 (+0200) Subject: Move root and git checks from App::Rgit::new to App::Rgit::Config::new X-Git-Tag: v0.02~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=f5feb13a168183b64735058599b7fbc7c668fc43;p=perl%2Fmodules%2Frgit.git Move root and git checks from App::Rgit::new to App::Rgit::Config::new --- diff --git a/lib/App/Rgit.pm b/lib/App/Rgit.pm index d2fe602..3d244a1 100644 --- a/lib/App/Rgit.pm +++ b/lib/App/Rgit.pm @@ -3,9 +3,6 @@ package App::Rgit; use strict; use warnings; -use Cwd qw/abs_path/; -use File::Spec::Functions qw/file_name_is_absolute/; - use Object::Tiny qw/config command/; use App::Rgit::Command; @@ -40,14 +37,11 @@ Creates a new L object that's bound to execute the command C<$cmd> on sub new { my ($class, %args) = &validate; - my $root = $args{root}; - return unless defined $root and -d $root; - $root = abs_path $root unless file_name_is_absolute $root; - return unless defined $args{git} and -x $args{git}; my $config = App::Rgit::Config->new( - root => $root, + root => $args{root}, git => $args{git}, ); + return unless defined $config; $class->SUPER::new( config => $config, command => App::Rgit::Command->new( diff --git a/lib/App/Rgit/Config.pm b/lib/App/Rgit/Config.pm index 20ef223..212fa33 100644 --- a/lib/App/Rgit/Config.pm +++ b/lib/App/Rgit/Config.pm @@ -4,6 +4,8 @@ use strict; use warnings; use Carp qw/croak/; +use Cwd qw/abs_path/; +use File::Spec::Functions qw/file_name_is_absolute/; use Object::Tiny qw/root git/; @@ -33,6 +35,10 @@ Creates a new configuration object based on the root directory C<$root> and usin sub new { my ($class, %args) = &validate; + my $root = $args{root}; + return unless defined $root and -d $root; + $root = abs_path $root unless file_name_is_absolute $root; + return unless defined $args{git} and -x $args{git}; my $conf = 'App::Rgit::Config::Default'; eval "require $conf; 1" or croak "Couldn't load $conf: $@"; $conf->SUPER::new(