blib/lib/App/GitHooks/Plugin/Test/PrintSTDERR.pm

filter: Statementstmt 100% 33 / 33 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 93.8% 46 / 49 CC 3 SCAR 4.4
CC
3
Cov
95%
__ANON__
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« _build/lib/MyModuleBuilder.pm ↑ Summary blib/lib/App/GitHooks/Constants.pm »
1 package App::GitHooks::Plugin::Test::PrintSTDERR;
2  
3 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 23 ▶use base 'App::GitHooks::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # External dependencies.
9 23 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Internal dependencies.
12 23 ▶use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 =head1 NAME
16  
17 App::GitHooks::Plugin::Test::PrintSTDERR - A test plugin that allows printing a specific string to STDERR.
18  
19  
20 =head1 DESCRIPTION
21  
22  
23 =head1 SYNOPSIS
24  
25 use App::GitHooks::Plugin::Test::PrintSTDERR;
26  
27 # In .githooksrc.
28 # [Test::PrintSTDERR]
29 # pre-commit = Triggered a pre-commit plugin!
30 # prepare-commit-msg = Triggered a prepare-commit-msg plugin!
31  
32 # Run hooks calling the plugin.
33  
34  
35 =head1 VERSION
36  
37 Version 1.7.3
38  
39 =cut
40  
41 23 our $VERSION = '1.7.3';
42  
43 23 our $HOOK_REPLIES;
44  
45  
46 =head1 METHODS
47  
48 =head2 get_file_pattern()
49  
50 Return a pattern to filter the files this plugin should analyze.
51  
52 my $file_pattern = App::GitHooks::Plugin::Test::PrintSTDERR->get_file_pattern(
53 app => $app,
54 );
55  
56 =cut
57  
58 sub get_file_pattern
59 {
60 1 ▶ return qr//x;
Subroutine get_file_pattern: called CC=1 SCAR=0.0
Pod documented
61 }
62  
63  
64 =head2 get_file_check_description()
65  
66 Return a description of the check performed on files by the plugin and that
67 will be displayed to the user, if applicable, along with an indication of the
68 success or failure of the plugin.
69  
70 my $description = App::GitHooks::Plugin::Test::PrintSTDERR->get_file_check_description();
71  
72 =cut
73  
74 sub get_file_check_description
75 {
76 1 ▶ return 'Test plugin - print on STDERR.';
Subroutine get_file_check_description: called CC=1 SCAR=0.0
Pod documented
77 }
78  
79  
80 =head1 SUPPORTED HOOKS
81  
82 This plugin supports all the hooks defined in C<App::GitHooks::Hook::*>,
83 including file-level checks for the appropriate hooks.
84  
85 =over 4
86  
87 =item run_applypatch_msg
88  
89 =item run_commit_msg
90  
91 =item run_post_applypatch
92  
93 =item run_post_checkout
94  
95 =item run_post_commit
96  
97 =item run_post_merge
98  
99 =item run_post_receive
100  
101 =item run_post_rewrite
102  
103 =item run_post_update
104  
105 =item run_pre_applypatch
106  
107 =item run_pre_auto_gc
108  
109 =item run_pre_commit
110  
111 =item run_pre_commit_file
112  
113 =item run_pre_push
114  
115 =item run_pre_rebase
116  
117 =item run_pre_receive
118  
119 =item run_prepare_commit_msg
120  
121 =item run_update
122  
123 =back
124  
125 =cut
126  
127 23 foreach my $hook ( @$App::GitHooks::Plugin::SUPPORTED_SUBS )
128 {
129 23 ▶ no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict)
Subroutine BEGIN: called CC=1 SCAR=0.0
130 414 my $sub = 'run_' . $hook;
131 *$sub = sub
132 {
133 2 ▶ my ( $class, %args ) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.2
134 2 my $app = delete( $args{'app'} );
135 2 my $config = $app->get_config();
136  
137 2 ▶ my $return = $config->get( 'Test::PrintSTDERR', $hook ) // '';
Condition50%1/2
$config->get("Test::PrintSTDERR", $hook) // ""
l!l
20
MC/DC0%0/1
$config->get("Test::PrintSTDERR", $hook) // ""
$config->get("Test::PrintSTDERR", $hook)
Truth table50%1/2
A
A= $config->get("Test::PrintSTDERR", $hook)
Aresult
11
00
138 2 ▶ croak "No test to print on STDERR specified for >$hook<."
Branch: 1 branch
BranchTrueFalseTotal
unless $return =~ /\w/ 0 2 2
139 if $return !~ /\w/;
140 2 print STDERR "$return\n";
141  
142 2 return $PLUGIN_RETURN_PASSED;
143 414 };
144 }
145  
146  
147 =head1 BUGS
148  
149 Please report any bugs or feature requests through the web interface at
150 L<https://github.com/guillaumeaubert/App-GitHooks/issues/new>.
151 I will be notified, and then you'll automatically be notified of progress on
152 your bug as I make changes.
153  
154  
155 =head1 SUPPORT
156  
157 You can find documentation for this module with the perldoc command.
158  
159 perldoc App::GitHooks::Plugin::Test::PrintSTDERR
160  
161  
162 You can also look for information at:
163  
164 =over
165  
166 =item * GitHub's request tracker
167  
168 L<https://github.com/guillaumeaubert/App-GitHooks/issues>
169  
170 =item * AnnoCPAN: Annotated CPAN documentation
171  
172 L<http://annocpan.org/dist/app-githooks>
173  
174 =item * CPAN Ratings
175  
176 L<http://cpanratings.perl.org/d/app-githooks>
177  
178 =item * MetaCPAN
179  
180 L<https://metacpan.org/release/App-GitHooks>
181  
182 =back
183  
184  
185 =head1 AUTHOR
186  
187 L<Guillaume Aubert|https://metacpan.org/author/AUBERTG>,
188 C<< <aubertg at cpan.org> >>.
189  
190  
191 =head1 COPYRIGHT & LICENSE
192  
193 Copyright 2013-2015 Guillaume Aubert.
194  
195 This program is free software: you can redistribute it and/or modify it under
196 the terms of the GNU General Public License version 3 as published by the Free
197 Software Foundation.
198  
199 This program is distributed in the hope that it will be useful, but WITHOUT ANY
200 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
201 PARTICULAR PURPOSE. See the GNU General Public License for more details.
202  
203 You should have received a copy of the GNU General Public License along with
204 this program. If not, see http://www.gnu.org/licenses/
205  
206 =cut
207  
208 23 1;
« _build/lib/MyModuleBuilder.pm ↑ Summary blib/lib/App/GitHooks/Constants.pm »