blib/lib/MIME/Lite/TT/Japanese.pm

filter: Statementstmt 85.3% 35 / 41 Branchbran 25.0% 1 / 4 Conditioncond 18.1% 2 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 4 totaltotal 61.0% 47 / 77 CC 7 SCAR 18.5
CC
7
Cov
68%
guess_encoding
20.0
encode_body
3.4
encode_header
2.1
CRAP 6.3
↑ Summary
1 package MIME::Lite::TT::Japanese;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 $VERSION = '0.08';
5  
6 2 ▶use base qw(MIME::Lite::TT);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Jcode;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use DateTime::Format::Mail;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶sub _after_process {
Subroutine _after_process: called CC=1 SCAR=0.0
11 1 my $class = shift;
12 1 my %options = (
13 Type => 'text/plain; charset=iso-2022-jp',
14 Encoding => '7bit',
15 Datestamp => 0,
16 Date => DateTime::Format::Mail->format_datetime( DateTime->now->set_time_zone('Asia/Tokyo') ),
17 @_,
18 );
19 1 $options{Subject} = encode_header( $options{Subject}, $options{Icode});
20 1 $options{From} = encode_header( $options{From}, $options{Icode});
21 1 $options{Data} = encode_body( $options{Data}, $options{Icode}, $options{LineWidth} );
22 1 delete $options{LineWidth};
23 1 return %options;
24 }
25  
26 2 ▶sub encode_header {
Subroutine encode_header: called CC=2 SCAR=7.6
Pod undocumented
27 2 my ($str, $icode) = @_;
28 2 $str = remove_utf8_flag($str);
29 2 ▶ return Jcode->new($str, $icode || guess_encoding($str) )->mime_encode;
Condition33%1/3
$icode || guess_encoding($str)
l!l&&r!l&&!r
200
MC/DC0%0/2
$icode || guess_encoding($str)
$icode guess_encoding($str)
Truth table33%1/3
A || B
A= $icodeB= guess_encoding($str)
ABresult
1X1
011
000
30 }
31  
32 1 ▶sub encode_body {
Subroutine encode_body: called CC=3 SCAR=12.3
Pod undocumented
33 1 my ($str, $icode, $line_width) = @_;
34 1 $str = remove_utf8_flag($str);
35 1 $str =~ s/\x0D\x0A/\n/g;
36 1 $str =~ tr/\r/\n/;
37 1 ▶ my $encoding = $icode || guess_encoding($str);
Condition33%1/3
$icode || guess_encoding($str)
l!l&&r!l&&!r
100
MC/DC0%0/2
$icode || guess_encoding($str)
$icode guess_encoding($str)
Truth table33%1/3
A || B
A= $icodeB= guess_encoding($str)
ABresult
1X1
011
000
38 1 ▶ unless ( $line_width eq '0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($line_width eq '0') { } 1 0 1
39 return join "\n", map {
40 0 Jcode->new($_, $encoding)->jfold($line_width)->jis
41 } split /\n/, $str;
42 } else {
43 1 return Jcode->new($str, $encoding )->jis;
44 }
45 }
46  
47 0 ▶sub guess_encoding {
Subroutine guess_encoding: not called CC=4 SCAR=30.0
Pod undocumented
48 0 my ($str) = @_;
49 0 ▶ my $enc = Jcode::getcode($str) || 'euc';
Condition0%0/2
Jcode::getcode($str) || 'euc'
l!l
00
MC/DC0%0/1
Jcode::getcode($str) || 'euc'
Jcode::getcode($str)
Truth table0%0/2
A
A= Jcode::getcode($str)
Aresult
11
00
50 0 ▶ $enc = 'euc' if $enc eq 'ascii' || $enc eq 'binary';
Branch: 1 branch
BranchTrueFalseTotal
if $enc eq "ascii" or $enc eq "binary" 0 0 0
Condition0%0/3
$enc eq "ascii" or $enc eq "binary"
l!l&&r!l&&!r
000
MC/DC0%0/2
$enc eq "ascii" or $enc eq "binary"
$enc eq "ascii" $enc eq "binary"
Truth table0%0/3
A or B
A= $enc eq "ascii"B= $enc eq "binary"
ABresult
1X1
011
000
51 0 return $enc;
52 }
53  
54 3 ▶sub remove_utf8_flag { pack 'C0A*', $_[0] }
Subroutine remove_utf8_flag: called CC=1 SCAR=0.0
Pod undocumented
55  
56 2 1;
57 __END__
↑ Summary