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