blib/lib/Template/Plugin/Digest/SHA1.pm

filter: Statementstmt 100% 37 / 37 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 94.5% 52 / 55 CC 4 SCAR 3.8
CC
4
Cov
93%
_sha1
2.1
_sha1_hex
2.1
_sha1_base64
2.1
CRAP 1.5
↑ Summary
1 package Template::Plugin::Digest::SHA1;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 $VERSION = 0.05;
8  
9 6 ▶use base qw(Template::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Template::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Template::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 $Template::Stash::SCALAR_OPS->{'sha1'} = \&_sha1;
15 6 $Template::Stash::SCALAR_OPS->{'sha1_hex'} = \&_sha1_hex;
16 6 $Template::Stash::SCALAR_OPS->{'sha1_base64'} = \&_sha1_base64;
17  
18 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19 6 my ($class, $context, $options) = @_;
20  
21 # now define the filter and return the plugin
22 6 $context->define_filter('sha1', \&_sha1);
23 6 $context->define_filter('sha1_hex', \&_sha1_hex);
24 6 $context->define_filter('sha1_base64', \&_sha1_base64);
25 6 return bless {}, $class;
26 }
27  
28 4 ▶sub _sha1 {
Subroutine _sha1: called CC=2 SCAR=7.2
29 4 ▶ my $options = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 4 4
30 4 return sha1(join('', @_));
31 }
32  
33 7 ▶sub _sha1_hex {
Subroutine _sha1_hex: called CC=2 SCAR=7.2
34 7 ▶ my $options = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 7 7
35 7 return sha1_hex(join('', @_));
36 }
37  
38 3 ▶sub _sha1_base64 {
Subroutine _sha1_base64: called CC=2 SCAR=7.2
39 3 ▶ my $options = ref $_[-1] eq 'HASH' ? pop : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 3 3
40 3 return sha1_base64(join('', @_));
41 }
42  
43 6 1;
44  
45 __END__
↑ Summary