Hooks/Generic.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 59 CC 4 SCAR 22.2
CC
4
Cov
0%
GENERIC
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 9.2
1 package SVN::Hooks::Generic;
2 # ABSTRACT: Implement generic checks for all Subversion hooks.
3 $SVN::Hooks::Generic::VERSION = '1.35';
4 use strict;
5 use warnings;
6  
7 use Carp;
8 use Data::Util qw(:check);
9 use SVN::Hooks;
10  
11 use Exporter qw/import/;
12 my $HOOK = 'GENERIC';
13 our @EXPORT = ($HOOK);
14  
15  
16 sub GENERIC {
17 my (@args) = @_;
18  
19 (@args % 2) == 0
20 or croak "$HOOK: odd number of arguments.\n";
21  
22 my %args = @args;
23  
24 while (my ($hook, $functions) = each %args) {
25 $hook =~ /(?:(?:pre|post)-(?:commit|lock|revprop-change|unlock)|start-commit)/
26 or die "$HOOK: invalid hook name ($hook)";
27 if (is_code_ref($functions)) {
28 $functions = [$functions];
29 } elsif (! is_array_ref($functions)) {
30 die "$HOOK: hook '$hook' should be mapped to a CODE-ref or to an ARRAY-ref.\n";
31 }
32 foreach my $foo (@$functions) {
33 is_code_ref($foo) or die "$HOOK: hook '$hook' should be mapped to CODE-refs.\n";
34 unless (exists $SVN::Hooks::Hooks{$hook}{set}{$foo}) {
35 push @{$SVN::Hooks::Hooks{$hook}{list}},
36 ($SVN::Hooks::Hooks{$hook}{set}{$foo} = sub { $foo->(@_); });
37 }
38 }
39 }
40  
41 return 1;
42 }
43  
44 1; # End of SVN::Hooks::Generic
45  
46 __END__