]> git.vpit.fr Git - perl/modules/rgit.git/blob - lib/App/Rgit.pm
d2fe602f4c6b41814da2f57792d7d80e7431f7f9
[perl/modules/rgit.git] / lib / App / Rgit.pm
1 package App::Rgit;
2
3 use strict;
4 use warnings;
5
6 use Cwd qw/abs_path/;
7 use File::Spec::Functions qw/file_name_is_absolute/;
8
9 use Object::Tiny qw/config command/;
10
11 use App::Rgit::Command;
12 use App::Rgit::Config;
13 use App::Rgit::Utils qw/validate/;
14
15 =head1 NAME
16
17 App::Rgit - Backend that supports the rgit utility.
18
19 =head1 VERSION
20
21 Version 0.01
22
23 =cut
24
25 our $VERSION = '0.01';
26
27 =head1 DESCRIPTION
28
29 Backend that supports the L<rgit> utility.
30
31 This is an internal class to L<rgit>.
32
33 =head1 METHODS
34
35 =head2 C<< new root => $root, git => $git, cmd => $cmd, args => \@args >>
36
37 Creates a new L<App::Rgit> object that's bound to execute the command C<$cmd> on all the C<git> repositories inside C<$root> with C<@args> as arguments and C<$git> as C<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 $config = App::Rgit::Config->new(
48   root => $root,
49   git  => $args{git},
50  );
51  $class->SUPER::new(
52   config  => $config,
53   command => App::Rgit::Command->new(
54    cmd   => $args{cmd},
55    args  => $args{args},
56    repos => $config->repos,
57   )
58  );
59 }
60
61 =head2 C<run>
62
63 Actually run the commands.
64
65 =cut
66
67 sub run {
68  my $self = shift;
69  $self->command->run($self->config);
70 }
71
72 =head2 C<config>
73
74 =head2 C<command>
75
76 Accessors.
77
78 =head1 SEE ALSO
79
80 L<rgit>.
81
82 =head1 AUTHOR
83
84 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
85    
86 You can contact me by mail or on C<irc.perl.org> (vincent).
87
88 =head1 BUGS
89
90 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.
91
92 =head1 SUPPORT
93
94 You can find documentation for this module with the perldoc command.
95
96     perldoc App::Rgit
97
98 =head1 COPYRIGHT & LICENSE
99
100 Copyright 2008 Vincent Pit, all rights reserved.
101
102 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
103
104 =cut
105
106 1; # End of App::Rgit