blib/lib/Encode/Arabic/Parkinson.pm

filter: Statementstmt 100% 79 / 79 Branchbran 50.0% 30 / 60 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 15 / 15 Podpod 33.3% 2 / 6 totaltotal 76.9% 127 / 165 SCAR 37.8
CC
32
Cov
77%
enmode
16.7
demode
16.7
import
4.4
CRAP 43.7
« blib/lib/Encode/Arabic/Habash.pm ↑ Summary blib/lib/Encode/Arabic/ArabTeX/ZDMG/RE.pm »
1 # ###################################################################### Otakar Smrz, 2003/01/23
2 #
3 # Encoding of Arabic: Dil Parkinson's Notation ###################################### 2006/02/03
4  
5 package Encode::Arabic::Parkinson;
6  
7 1 our $VERSION = '14.1';
8  
9 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use Encode::Encoding;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use base 'Encode::Encoding';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 __PACKAGE__->Define('Parkinson', 'Dil');
20  
21  
22 1 our $enmode;
23 1 our $demode;
24  
25 1 our $optxml;
26  
27 1 our %modemap = (
28  
29 'default' => 0,
30 'undef' => 0,
31  
32 'fullvocalize' => 0,
33 'full' => 0,
34  
35 'nowasla' => 4,
36  
37 'vocalize' => 3,
38 'nosukuun' => 3,
39  
40 'novocalize' => 2,
41 'novowels' => 2,
42 'none' => 2,
43  
44 'noshadda' => 1,
45 'noneplus' => 1,
46 );
47  
48  
49 # use subs 'encoder', 'decoder'; # ignores later prototypes
50  
51 sub encoder ($); # respect prototypes
52 sub decoder ($); # respect prototypes
53  
54  
55 sub import { # perform import as if Encode were used one level before this module
56  
57 1 ▶ $optxml = defined $_[1] && $_[1] eq ':xml' ? 1 : 0;
Subroutine import: called CC=4 SCAR=14.8
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] && $_[1] eq ':xml' ? : 0 1 1
Condition33%1/3
defined $_[1] and $_[1] eq ":xml"
!ll&&!rl&&r
100
MC/DC0%0/2
defined $_[1] and $_[1] eq ":xml"
defined $_[1] $_[1] eq ":xml"
Truth table33%1/3
A and B
A= defined $_[1]B= $_[1] eq ":xml"
ABresult
0X0
100
111
58  
59 1 __PACKAGE__->enmode('full');
60 1 __PACKAGE__->demode('full');
61  
62 1 splice @_, 1, 1;
63  
64 1 require Encode;
65  
66 1 ▶ push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level');
Branch: 1 branch
BranchTrueFalseTotal
unless "Encode"->can("export_to_level") 1 0 1
67  
68 1 Encode->export_to_level(1, @_);
69 }
70  
71  
72 sub encode ($$;$) {
73 2 ▶ my (undef, $text, $check) = @_;
Subroutine encode: called CC=3 SCAR=11.3
Pod documented
74  
75 2 ▶ $_[1] = '' if $check; # needed by in-place edit
Branch: 1 branch
BranchTrueFalseTotal
if $check 0 2 2
76  
77 2 $text = encoder $text;
78  
79 2 ▶ $text = Encode::encode "utf8", $text if Encode::is_utf8($text);
Branch: 1 branch
BranchTrueFalseTotal
if &Encode::is_utf8($text) 2 0 2
80  
81 2 return $text;
82 }
83  
84  
85 sub decode ($$;$) {
86 2 ▶ my (undef, $text, $check) = @_;
Subroutine decode: called CC=3 SCAR=11.3
Pod documented
87  
88 2 ▶ $_[1] = '' if $check; # needed by in-place edit
Branch: 1 branch
BranchTrueFalseTotal
if $check 0 2 2
89  
90 2 ▶ $text = Encode::decode "utf8", $text unless Encode::is_utf8($text);
Branch: 1 branch
BranchTrueFalseTotal
unless &Encode::is_utf8($text) 2 0 2
91  
92 2 $text = decoder $text;
93  
94 2 return $text;
95 }
96  
97  
98 sub enmode ($$;$$) {
99 1 ▶ my ($cls, $mode, $xml, $kshd) = @_;
Subroutine enmode: called CC=13 SCAR=28.1
Pod undocumented
100  
101 1 ▶ $cls = blessed $cls if ref $cls;
Branch: 1 branch
BranchTrueFalseTotal
if ref $cls 0 1 1
102 1 ▶ $xml = $optxml unless defined $xml;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xml 1 0 1
103  
104 1 ▶ $mode = 'undef' unless defined $mode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mode 0 1 1
105 1 ▶ $mode = $modemap{$mode} if exists $modemap{$mode};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Encode::Arabic::Parkinson::modemap{$mode} 1 0 1
106  
107 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
108  
109 1 my $return = ${ $cls . '::enmode' };
110  
111 1 ▶ if (defined $mode) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mode) 1 0 1
112  
113 1 ${ $cls . '::enmode' } = $mode;
114  
115 1 ▶ my @set = (
Branch: 7 branches
BranchTrueFalseTotal
$kshd ? : 0 1 1
$kshd ? : 0 1 1
$kshd ? : 0 1 1
$mode == 0 ? : 1 0 1
$mode == 1 ? : 0 1 1
$mode == 2 ? : 0 1 1
$mode == 3 ? : 0 1 1
116  
117 ( $kshd
118 ? ''
119 : q [\x{0640}] ) .
120 q [\x{0623}\x{0624}\x{0625}] .
121 q [\x{060C}\x{061B}\x{061F}] .
122 q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] .
123 q [\x{0660}-\x{0669}] .
124 q [\x{0671}] .
125 q [\x{0651}] .
126 q [\x{064B}-\x{0650}\x{0670}] .
127 q [\x{0652}] .
128 ( $kshd
129 ? q [\x{0640}]
130 : '' )
131  
132 ,
133  
134 ( $kshd
135 ? ''
136 : q [_] ) .
137 q [LWE] .
138 q [,;?] .
139 q [CMYAbQtVjHxdvrzspSDTZcgfqklmnhwey] .
140 q [0-9] .
141 ( $mode == 0
142 ? q [O]
143 : q [A] ) .
144 ( $mode == 1
145 ? ''
146 : q [~] . ( $mode == 2
147 ? ''
148 : q [NUIauiR] . ( $mode == 3
149 ? ''
150 : q [o] ) ) )
151  
152 );
153  
154  
155 1 undef &encoder;
156  
157 1 ▶ eval q /
Subroutine encoder: called CC=1 SCAR=0.0
Pod undocumented
158  
159 sub encoder ($) {
160  
161 $_[0] =~ tr[/ . $set[0] . q /]
162 [/ . $set[1] . q /]d;
163  
164 return $_[0];
165 }
166 /;
167 }
168  
169 1 return $return;
170 }
171  
172  
173 sub demode ($$;$$) {
174 1 ▶ my ($cls, $mode, $xml, $kshd) = @_;
Subroutine demode: called CC=13 SCAR=28.1
Pod undocumented
175  
176 1 ▶ $cls = blessed $cls if ref $cls;
Branch: 1 branch
BranchTrueFalseTotal
if ref $cls 0 1 1
177 1 ▶ $xml = $optxml unless defined $xml;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xml 1 0 1
178  
179 1 ▶ $mode = 'undef' unless defined $mode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mode 0 1 1
180 1 ▶ $mode = $modemap{$mode} if exists $modemap{$mode};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Encode::Arabic::Parkinson::modemap{$mode} 1 0 1
181  
182 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
183  
184 1 my $return = ${ $cls . '::demode' };
185  
186 1 ▶ if (defined $mode) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mode) 1 0 1
187  
188 1 ${ $cls . '::demode' } = $mode;
189  
190 1 ▶ my @set = (
Branch: 7 branches
BranchTrueFalseTotal
$kshd ? : 0 1 1
$kshd ? : 0 1 1
$kshd ? : 0 1 1
$mode == 0 ? : 1 0 1
$mode == 1 ? : 0 1 1
$mode == 2 ? : 0 1 1
$mode == 3 ? : 0 1 1
191  
192 ( $kshd
193 ? ''
194 : q [_] ) .
195 q [LWE] .
196 q [,;?] .
197 q [CMYAbQtVjHxdvrzspSDTZcgfqklmnhwey] .
198 q [0-9] .
199 q [O] .
200 q [~] .
201 q [NUIauiR] .
202 q [o] .
203 ( $kshd
204 ? q [_]
205 : '' )
206  
207 ,
208  
209 ( $kshd
210 ? ''
211 : q [\x{0640}] ) .
212 q [\x{0623}\x{0624}\x{0625}] .
213 q [\x{060C}\x{061B}\x{061F}] .
214 q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] .
215 q [\x{0660}-\x{0669}] .
216 ( $mode == 0
217 ? q [\x{0671}]
218 : q [\x{0627}] ) .
219 ( $mode == 1
220 ? ''
221 : q [\x{0651}] . ( $mode == 2
222 ? ''
223 : q [\x{064B}-\x{0650}\x{0670}] . ( $mode == 3
224 ? ''
225 : q [\x{0652}] ) ) )
226  
227 );
228  
229  
230 1 undef &decoder;
231  
232 1 ▶ eval q /
Subroutine decoder: called CC=1 SCAR=0.0
Pod undocumented
233  
234 sub decoder ($) {
235  
236 $_[0] =~ tr[/ . $set[0] . q /]
237 [/ . $set[1] . q /]d;
238  
239 return $_[0];
240 }
241 /;
242 }
243  
244 1 return $return;
245 }
246  
247  
248 1 1;
249  
250 __END__
« blib/lib/Encode/Arabic/Habash.pm ↑ Summary blib/lib/Encode/Arabic/ArabTeX/ZDMG/RE.pm »