]> git.vpit.fr Git - perl/modules/rgit.git/blob - lib/App/Rgit/Config.pm
Move root and git checks from App::Rgit::new to App::Rgit::Config::new
[perl/modules/rgit.git] / lib / App / Rgit / Config.pm
1 package App::Rgit::Config;
2
3 use strict;
4 use warnings;
5
6 use Carp qw/croak/;
7 use Cwd qw/abs_path/;
8 use File::Spec::Functions qw/file_name_is_absolute/;
9
10 use Object::Tiny qw/root git/;
11
12 use App::Rgit::Utils qw/validate/;
13
14 =head1 NAME
15
16 App::Rgit::Config - Base class for App::Rgit configurations.
17
18 =head1 VERSION
19
20 Version 0.01
21
22 =head1 DESCRIPTION
23
24 Base class for L<App::Rgit> configurations.
25
26 This is an internal class to L<rgit>.
27
28 =head1 METHODS
29
30 =head2 C<< new root => $root, git => $git >>
31
32 Creates a new configuration object based on the root directory C<$root> and using C<$git> as F<git> executable.
33
34 =cut
35
36 sub new {
37  my ($class, %args) = &validate;
38  my $root = $args{root};
39  return unless defined $root and -d $root;
40  $root = abs_path $root unless file_name_is_absolute $root;
41  return unless defined $args{git} and -x $args{git};
42  my $conf = 'App::Rgit::Config::Default';
43  eval "require $conf; 1" or croak "Couldn't load $conf: $@";
44  $conf->SUPER::new(
45   root => $args{root},
46   git  => $args{git},
47  );
48 }
49
50 =head2 C<root>
51
52 =head2 C<git>
53
54 =head2 C<repos>
55
56 Accessors.
57
58 =head1 SEE ALSO
59
60 L<rgit>.
61
62 =head1 AUTHOR
63
64 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
65    
66 You can contact me by mail or on C<irc.perl.org> (vincent).
67
68 =head1 BUGS
69
70 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>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
71
72 =head1 SUPPORT
73
74 You can find documentation for this module with the perldoc command.
75
76     perldoc App::Rgit::Config
77
78 =head1 COPYRIGHT & LICENSE
79
80 Copyright 2008 Vincent Pit, all rights reserved.
81
82 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
83
84 =cut
85
86 1; # End of App::Rgit::Config