1 package App::Rgit::Config;
8 use File::Spec (); # canonpath, catfile, path
10 use App::Rgit::Repository;
11 use App::Rgit::Utils qw/:levels/; # :levels, abs_path
13 use constant IS_WIN32 => $^O eq 'MSWin32';
17 App::Rgit::Config - Base class for App::Rgit configurations.
25 our $VERSION = '0.08';
29 Base class for L<App::Rgit> configurations.
31 This is an internal class to L<rgit>.
35 =head2 C<< new root => $root, git => $git >>
37 Creates a new configuration object based on the root directory C<$root> and using C<$git> as F<git> executable.
43 $class = ref $class || $class;
47 my $root = defined $args{root}
49 : defined $ENV{GIT_DIR}
52 Carp::confess("Invalid root directory") unless -d $root;
53 $root = File::Spec->canonpath(App::Rgit::Utils::abs_path($root));
59 : defined $ENV{GIT_EXEC_PATH}
61 : map File::Spec->catfile($_, 'git'), File::Spec->path
65 for my $c (@candidates) {
66 push @acc, $c, map "$c.$_", qw/exe com bat cmd/;
70 for my $c (@candidates) {
76 Carp::confess("Couldn't find a proper git executable") unless defined $git;
77 $git = File::Spec->canonpath(App::Rgit::Utils::abs_path($git));
79 my $conf = 'App::Rgit::Config::Default';
80 eval "require $conf; 1" or Carp::confess("Couldn't load $conf: $@");
82 my $r = App::Rgit::Repository->new(fake => 1);
83 return unless defined $r;
89 debug => defined $args{debug} ? int $args{debug} : WARN,
101 Notifies a message C<$msg> of the corresponding level.
108 if ($self->debug >= $level) {
115 sub info { shift->_notify(INFO, @_) }
117 sub warn { shift->_notify(WARN, @_) }
119 sub err { shift->_notify(ERR, @_) }
121 sub crit { shift->_notify(CRIT, @_) }
138 eval "sub $_ { \$_[0]->{$_} }" for qw/root git cwd_repo debug/;
147 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
149 You can contact me by mail or on C<irc.perl.org> (vincent).
153 Please report any bugs or feature requests to C<bug-rgit at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=rgit>.
154 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
158 You can find documentation for this module with the perldoc command.
160 perldoc App::Rgit::Config
162 =head1 COPYRIGHT & LICENSE
164 Copyright 2008,2009,2010 Vincent Pit, all rights reserved.
166 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
170 1; # End of App::Rgit::Config