File Coverage

blib/lib/Mail/DKIM/Canonicalization/Base.pm
Criterion Covered Total %
statement 31 37 83.7
branch 8 18 44.4
condition 5 9 55.5
subroutine 8 8 100.0
pod 2 4 50.0
total 54 76 71.0


line stmt bran cond sub pod time code
1             package Mail::DKIM::Canonicalization::Base;
2 15     15   131 use strict;
  15         33  
  15         564  
3 15     15   123 use warnings;
  15         30  
  15         1132  
4             our $VERSION = '1.20240923'; # VERSION
5             # ABSTRACT: base class for canonicalization methods
6              
7             # Copyright 2005-2007 Messiah College. All rights reserved.
8             # Jason Long
9              
10             # Copyright (c) 2004 Anthony D. Urso. All rights reserved.
11             # This program is free software; you can redistribute it and/or
12             # modify it under the same terms as Perl itself.
13              
14 15     15   122 use base 'Mail::DKIM::MessageParser';
  15         30  
  15         8405  
15 15     15   113 use Carp;
  15         29  
  15         7283  
16              
17             sub new {
18 946     946 0 2401 my $class = shift;
19 946         3092 return $class->new_object(@_);
20             }
21              
22             sub init {
23 946     946 0 1686 my $self = shift;
24 946         3457 $self->SUPER::init;
25              
26 946 50 33     7896 unless ( $self->{output}
      66        
      66        
27             || $self->{output_fh}
28             || $self->{output_digest}
29             || $self->{buffer} )
30             {
31 1         4 $self->{result} = '';
32 1         4 $self->{buffer} = \$self->{result};
33             }
34             }
35              
36             sub output {
37 2785     2785 1 4717 my $self = shift;
38              
39             # my ($output) = @_; # optimized away for speed
40              
41 2785         5656 my $out_fh = $self->{output_fh};
42 2785 50       6282 if ($out_fh) {
43 0         0 print $out_fh @_;
44             }
45 2785 100       9426 if ( my $digest = $self->{output_digest} ) {
46 2779         17622 $digest->add(@_);
47             }
48 2785 50       7012 if ( my $out_obj = $self->{output} ) {
49 0         0 $out_obj->PRINT(@_);
50             }
51 2785 100       7181 if ( my $buffer = $self->{buffer} ) {
52 6         11 ${ $self->{buffer} } .= $_[0];
  6         17  
53             }
54              
55             # this supports Debug_Canonicalization
56 2785 50       10938 if ( my $debug = $self->{Debug_Canonicalization} ) {
57 0 0       0 if ( UNIVERSAL::isa( $debug, 'SCALAR' ) ) {
    0          
    0          
58 0         0 $$debug .= $_[0];
59             }
60             elsif ( UNIVERSAL::isa( $debug, 'GLOB' ) ) {
61 0         0 print $debug @_;
62             }
63             elsif ( UNIVERSAL::isa( $debug, 'IO::Handle' ) ) {
64 0         0 $debug->print(@_);
65             }
66             }
67             }
68              
69             sub result {
70 1     1 1 464 my $self = shift;
71 1         7 return $self->{result};
72             }
73              
74             1;
75              
76             __END__