blib/lib/App/Asciio/String.pm

filter: Statementstmt 60.0% 27 / 45 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 55.9% 33 / 59 CC 5 SCAR 26.5
CC
5
Cov
53%
make_vertical_text
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 14.2
« blib/lib/App/Asciio/Actions/Multiwirl.pm ↑ Summary blib/lib/App/Asciio/Actions/Clipboard.pm »
1  
2 package App::Asciio::String ;
3  
4 4 require Exporter ;
5 4 @ISA = qw(Exporter) ;
6 4 @EXPORT = qw(
7 unicode_length
8 make_vertical_text
9 ) ;
10  
11 #-----------------------------------------------------------------------------
12  
13 4 ▶use strict ; use warnings ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use utf8 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 ▶use App::Asciio::Markup ;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 #-----------------------------------------------------------------------------
19  
20 4 ▶use Memoize ;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 memoize('unicode_length') ;
22  
23 sub unicode_length
24 28 ▶{
Subroutine unicode_length: called CC=1 SCAR=0.0
25 28 my ($string) = @_ ;
26  
27 28 $string = $USE_MARKUP_CLASS->delete_markup_characters($string) ;
28  
29 28 my $east_asian_double_width_chars_cnt = grep {$_ =~ /\p{EA=W}|\p{EA=F}/} split('', $string) ;
30 28 my $nonspacing_chars_cnt = grep {$_ =~ /\p{gc:Mn}/} split('', $string) ;
31  
32 28 return length($string) + $east_asian_double_width_chars_cnt - $nonspacing_chars_cnt ;
33 }
34  
35 #-----------------------------------------------------------------------------
36  
37 sub make_vertical_text
38 0 ▶{
Subroutine make_vertical_text: not called CC=5 SCAR=34.0
Pod undocumented
39 0 my ($text) = @_ ;
40  
41 0 my @lines = map{[split '', $_]} split "\n", $text ;
42  
43 0 my $vertical = '' ;
44 0 my $found_character = 1 ;
45 0 my $index = 0 ;
46  
47 0 ▶while($found_character)
Branch: 1 branch
BranchTrueFalseTotal
if ($found_character) 0 0 0
48 {
49 0 my $line ;
50 0 $found_character = 0 ;
51
52 0 for(@lines)
53 {
54 0 ▶ if(defined $_->[$index])
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_->[$index]) { } 0 0 0
55 {
56 0 $line.= $_->[$index] ;
57 0 $found_character++ ;
58 }
59 else
60 {
61 0 $line .= ' ' ;
62 }
63 }
64
65 0 $line =~ s/\s+$//;
66 0 ▶ $vertical .= "$line\n" if $found_character ;
Branch: 1 branch
BranchTrueFalseTotal
if $found_character 0 0 0
67 0 $index++ ;
68 }
69  
70 0 return $vertical ;
71 }
72  
73 #-----------------------------------------------------------------------------
74  
75 4 1 ;
« blib/lib/App/Asciio/Actions/Multiwirl.pm ↑ Summary blib/lib/App/Asciio/Actions/Clipboard.pm »