lib/Egg/Plugin/Filter/Plugin/Japanese.pm

filter: Statementstmt 20.6% 18 / 87 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 26.6% 4 / 15 Podpod n/a totaltotal 16.4% 22 / 134 CC 17 SCAR 22.6
CC
17
Cov
15%
__ANON__
20.0
__ANON__
20.0
_setup_filters
12.0
CRAP 9.5
« lib/Egg/Plugin/Tools.pm ↑ Summary lib/Egg/Helper/Build/Project.pm »
1 package Egg::Plugin::Filter::Plugin::Japanese;
2 #
3 # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4 #
5 # $Id: Japanese.pm 337 2008-05-14 12:30:09Z lushe $
6 #
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Egg::Plugin::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Jcode;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = '3.00';
13  
14 1 our($Zspace, $RZspace);
15  
16 1 my $EGG= 0;
17 1 my $VAL= 1;
18 1 my $ARG= 2;
19  
20 0 ▶sub _setup_filters {
Subroutine _setup_filters: not called CC=3 SCAR=24.8
21 0 my($class, $e)= @_;
22  
23 0 ▶ $Zspace || die q{ I want setup '$Zspace'. };
Branch: 1 branch
BranchTrueFalseTotal
$Egg::Plugin::Filter::Plugin::Japanese::Zspace or die " I want setup '\$Zspace'. " 0 0 0
24 0 ▶ $RZspace || die q{ I want setup '$RZspace'. };
Branch: 1 branch
BranchTrueFalseTotal
$Egg::Plugin::Filter::Plugin::Japanese::RZspace or die " I want setup '\$RZspace'. " 0 0 0
25  
26 0 my $filters= \%Egg::Plugin::Filter::Filters;
27  
28 0 ▶ $filters->{h2z}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
29 0 ▶ return 0 unless defined(${$_[$VAL]});
Branch: 1 branch
BranchTrueFalseTotal
unless defined ${$_[$VAL];} 0 0 0
30 0 ${$_[$VAL]}= Jcode->new($_[$VAL])->h2z;
31 0 };
32  
33 0 ▶ $filters->{a2z}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
34 0 ▶ return 0 unless defined(${$_[$VAL]});
Branch: 1 branch
BranchTrueFalseTotal
unless defined ${$_[$VAL];} 0 0 0
35 0 my $w= Jcode->new($_[$VAL])->h2z;
36 0 $w->tr('A-Z', '£Á-£Ú');
37 0 $w->tr('a-z', '£Á-£Ú');
38 0 $w->tr('0-9', '£°-£¹');
39 0 ${$_[$VAL]}= $w;
40 0 };
41  
42 0 ▶ $filters->{j_trim}= sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
43 0 ▶ return 0 unless defined(${$_[$VAL]});
Branch: 1 branch
BranchTrueFalseTotal
unless defined ${$_[$VAL];} 0 0 0
44 0 ▶ 1 while ${$_[$VAL]}=~s{^(?:\s|$Zspace)+} []sg;
Branch: 1 branch
BranchTrueFalseTotal
${$_[$VAL];} =~ s/^(?:\s|$Egg::Plugin::Filter::Plugin::Japanese::Zspace)+//gs and do { '???' } 0 0 0
45 0 ▶ 1 while ${$_[$VAL]}=~s{(?:\s|$Zspace)$} []sg;
Branch: 1 branch
BranchTrueFalseTotal
${$_[$VAL];} =~ s/(?:\s|$Egg::Plugin::Filter::Plugin::Japanese::Zspace)$//gs and do { 1 } 0 0 0
46 0 };
47  
48 0 ▶ $filters->{j_hold}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
49 0 ▶ defined(${$_[$VAL]}) and ${$_[$VAL]}=~s{(?:\s|$Zspace)+} []sg;
Branch: 1 branch
BranchTrueFalseTotal
defined ${$_[$VAL];} and ${$_[$VAL];} =~ s/(?:\s|$Egg::Plugin::Filter::Plugin::Japanese::Zspace)+//gs 0 0 0
50 0 };
51  
52 0 ▶ $filters->{j_strip}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
53 0 ▶ return 0 unless defined(${$_[$VAL]});
Branch: 1 branch
BranchTrueFalseTotal
unless defined ${$_[$VAL];} 0 0 0
54 0 ${$_[$VAL]}=~s{(?:\s|$Zspace)+} [ ]sg;
55 0 };
56  
57 0 ▶ $filters->{j_strip_j}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
58 0 ▶ return 0 unless defined(${$_[$VAL]});
Branch: 1 branch
BranchTrueFalseTotal
unless defined ${$_[$VAL];} 0 0 0
59 0 ${$_[$VAL]}=~s{(?:\s|$Zspace)+} [$RZspace]sge;
60 0 };
61  
62 0 ▶ $filters->{j_strip_blank}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
63 0 ▶ return 0 unless defined(${$_[$VAL]});
Branch: 1 branch
BranchTrueFalseTotal
unless defined ${$_[$VAL];} 0 0 0
64 0 ${$_[$VAL]}=~s{(?: |$Zspace)+} [ ]sg;
65 0 };
66  
67 0 ▶ $filters->{j_strip_blank_j}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
68 0 ▶ return 0 unless defined(${$_[$VAL]});
Branch: 1 branch
BranchTrueFalseTotal
unless defined ${$_[$VAL];} 0 0 0
69 0 ${$_[$VAL]}=~s{(?: |$Zspace)+} [$RZspace]sge;
70 0 };
71  
72 0 ▶ $filters->{j_text}= sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
73 0 my($e, $v, $a)= @_;
74 0 $filters->{h2z}->($e, $v);
75 0 $filters->{strip_tab}->($e, $v);
76 0 $filters->{j_trim}->($e, $v);
77 0 $filters->{j_strip_blank}->($e, $v);
78 0 ▶ $filters->{crlf}->($e, $v, [$a->[0] || 3]);
Condition0%0/2
$a->[0] || 3
l!l
00
MC/DC0%0/1
$a->[0] || 3
$a->[0]
Truth table0%0/2
A
A= $a->[0]
Aresult
11
00
79 0 };
80  
81 0 ▶ $filters->{j_fold}= sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
82 0 my($e, $v, $a)= @_;
83 0 ▶ my $len= $a->[0] || 72;
Condition0%0/2
$a->[0] || 72
l!l
00
MC/DC0%0/1
$a->[0] || 72
$a->[0]
Truth table0%0/2
A
A= $a->[0]
Aresult
11
00
84 0 my $text;
85 0 for (split /\n/, ${$_[$VAL]}) {
86 0 ▶ $text.= $_ ? join("\n", Jcode->new(\$_)->jfold($len)). "\n": "\n";
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 0 0 0
87 }
88 0 chomp $text;
89 0 ${$_[$VAL]}= $text;
90 0 };
91  
92 0 @_;
93 }
94  
95 1 1;
96  
97 __END__
« lib/Egg/Plugin/Tools.pm ↑ Summary lib/Egg/Helper/Build/Project.pm »