Export/MailAliases.pm

filter: Statementstmt 81.0% 30 / 37 Branchbran 45.0% 9 / 20 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 68.1% 47 / 69 CC 12 SCAR 22.3
CC
12
Cov
67%
process_record
13.5
post_processing
6.0
BEGIN
1.0
CRAP 9.3
« Export/vCard.pm ↑ Summary Export/LDIF.pm »
1 package BBDB::Export::MailAliases;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.015';
6  
7  
8 1 our @ISA = qw(BBDB::Export);
9  
10 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #
13 #_* process_record
14 #
15  
16 sub process_record
17 7 ▶{
Subroutine process_record: called CC=9 SCAR=26.0
Pod documented
18 7 my ( $self, $record ) = @_;
19  
20 7 ▶ return unless ( $record );
Branch: 1 branch
BranchTrueFalseTotal
unless $record 0 7 7
21 7 ▶ return unless ( $record->{'full'} );
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"full"} 0 7 7
22 7 ▶ return unless ( $record->{'net'} );
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"net"} 5 2 7
23  
24 2 my $email = $record->{'net'}->[0];
25 2 my $full = $record->{'full'};
26  
27 # determine nick
28 2 my $nick;
29  
30 2 ▶ if ( $record->{'nick'} )
Branch: 4 branches
BranchTrueFalseTotal
if ($record->{'nick'}) { } 0 2 2
elsif ($record->{'first'} and $record->{'last'}) { } 2 0 2
elsif ($record->{'last'}) { } 0 0 0
elsif ($record->{'first'}) { } 0 0 0
31 {
32 # use the first nick in the list
33 0 $nick = ( split( /,/, $record->{'nick'} ) )[0];
34 }
35 ▶ elsif ( $record->{'first'} && $record->{'last'} )
Condition33%1/3
$record->{"first"} and $record->{"last"}
!ll&&!rl&&r
002
MC/DC0%0/2
$record->{"first"} and $record->{"last"}
$record->{"first"} $record->{"last"}
Truth table33%1/3
A and B
A= $record->{"first"}B= $record->{"last"}
ABresult
0X0
100
111
36 {
37 # build nick of first name and first char of last name
38 2 $nick = $record->{'first'};
39 2 $nick =~ s|\s.*$||;
40 2 $nick .= substr( $record->{'last'}, 0, 1 );
41 }
42 elsif ( $record->{'last'} )
43 {
44 # use last name for nick
45 0 $nick = $record->{'last'}
46 }
47 elsif ( $record->{'first'} )
48 {
49 # use first name for nick
50 0 $nick = $record->{'first'};
51 }
52  
53 # acceptable characters
54 2 $nick =~ tr/a-zA-Z//cd;
55  
56 # lower case the nick
57 2 $nick = lc( $nick );
58  
59 2 return qq(alias $nick "$full" <$email>\n);
60 }
61  
62 #
63 #_* post_processing
64 #
65  
66 sub post_processing
67 7 ▶{
Subroutine post_processing: called CC=4 SCAR=17.9
Pod documented
68 7 my ( $self, $output ) = @_;
69  
70 7 ▶ return unless $output;
Branch: 1 branch
BranchTrueFalseTotal
unless $output 5 2 7
71  
72 2 my $outfile = $self->{'data'}->{'output_file'};
73 2 ▶ return unless $outfile;
Branch: 1 branch
BranchTrueFalseTotal
unless $outfile 2 0 2
74  
75 0 ▶ open ( my $out_fh, ">", $outfile ) or die "Unable to create $outfile";
Branch: 1 branch
BranchTrueFalseTotal
open my $out_fh, ">", $outfile or die "Unable to create $outfile" 0 0 0
76 0 print $out_fh $output;
77 0 close $out_fh;
78  
79 0 $self->info( "Exported mail_aliases data to $outfile" );
80 }
81  
82 1 1;
83  
84  
« Export/vCard.pm ↑ Summary Export/LDIF.pm »