File Coverage

blib/lib/App/GitHooks/Plugin.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 5 5 100.0
pod 2 2 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package App::GitHooks::Plugin;
2              
3 31     31   17366 use strict;
  31         43  
  31         1088  
4 31     31   126 use warnings;
  31         36  
  31         828  
5              
6             # External dependencies.
7 31     31   394 use Carp;
  31         44  
  31         6507  
8              
9              
10             =head1 NAME
11              
12             App::GitHooks::Plugin - Base class for plugins.
13              
14              
15             =head1 VERSION
16              
17             Version 1.7.3
18              
19             =cut
20              
21             our $VERSION = '1.7.3';
22              
23             our $SUPPORTED_SUBS =
24             [
25             qw(
26             applypatch_msg
27             commit_msg
28             post_applypatch
29             post_checkout
30             post_commit
31             post_merge
32             post_receive
33             post_rewrite
34             post_update
35             pre_applypatch
36             pre_auto_gc
37             pre_commit
38             pre_commit_file
39             pre_push
40             pre_rebase
41             pre_receive
42             prepare_commit_msg
43             update
44             )
45             ];
46              
47              
48             =head1 METHODS
49              
50             =head2 get_file_check_description()
51              
52             Return a description of the check performed on files by the plugin and that
53             will be displayed to the user, if applicable, along with an indication of the
54             success or failure of the plugin.
55              
56             my $description = $plugin_class->get_file_check_description();
57              
58             =cut
59              
60             sub get_file_check_description
61             {
62 1     1 1 25825 croak 'You must define a get_file_check_description() subroutine in the plugin';
63             }
64              
65              
66             =head2 get_name()
67              
68             Return the name of the plugin. For example, for C,
69             the name will be C.
70              
71             my $name = $plugin->get_name();
72              
73             =cut
74              
75             sub get_name
76             {
77 5     5 1 40065 my ( $class ) = @_;
78 5 100 100     51 croak 'You need to call this method on a class'
79             if !defined( $class ) || ( $class eq '' );;
80              
81 3         5 my $base_path = __PACKAGE__ . '::';
82 3 100       64 croak "Not a valid plugin class: >$class<"
83             if $class !~ /^\Q$base_path\E/;
84              
85 2         17 $class =~ s/^$base_path//;
86              
87 2         11 return $class;
88             }
89              
90              
91             =head1 BUGS
92              
93             Please report any bugs or feature requests through the web interface at
94             L.
95             I will be notified, and then you'll automatically be notified of progress on
96             your bug as I make changes.
97              
98              
99             =head1 SUPPORT
100              
101             You can find documentation for this module with the perldoc command.
102              
103             perldoc App::GitHooks::Plugin
104              
105              
106             You can also look for information at:
107              
108             =over
109              
110             =item * GitHub's request tracker
111              
112             L
113              
114             =item * AnnoCPAN: Annotated CPAN documentation
115              
116             L
117              
118             =item * CPAN Ratings
119              
120             L
121              
122             =item * MetaCPAN
123              
124             L
125              
126             =back
127              
128              
129             =head1 AUTHOR
130              
131             L,
132             C<< >>.
133              
134              
135             =head1 COPYRIGHT & LICENSE
136              
137             Copyright 2013-2015 Guillaume Aubert.
138              
139             This program is free software: you can redistribute it and/or modify it under
140             the terms of the GNU General Public License version 3 as published by the Free
141             Software Foundation.
142              
143             This program is distributed in the hope that it will be useful, but WITHOUT ANY
144             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
145             PARTICULAR PURPOSE. See the GNU General Public License for more details.
146              
147             You should have received a copy of the GNU General Public License along with
148             this program. If not, see http://www.gnu.org/licenses/
149              
150             =cut
151              
152             1;