lib/Text/FIGlet/Control.pm

filter: Statementstmt 100% 61 / 61 Branchbran 92.3% 24 / 26 Conditioncond 63.6% 7 / 11 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 91.1% 103 / 113 CC 20 SCAR 26.6
CC
20
Cov
94%
new
19.1
tr
2.3
BEGIN
1.0
CRAP 14.3
« lib/Text/FIGlet/Ransom.pm ↑ Summary lib/Text/FIGlet/Illuminated.pm »
1 package Text::FIGlet::Control;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 $VERSION = 2.15;
6  
7 #'import' core support functions from parent with circular dependency
8 4 foreach( qw/_canonical _no/){
9 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 *$_ = *{'Text::FIGlet::'.$_};
11 }
12  
13 2 ▶sub new{
Subroutine new: called CC=19 SCAR=29.5
Pod documented
14 2 my $proto = shift;
15 2 my $self = {-C=>[]};
16 2 local($_, *FLC);
17  
18 2 my $code = '';
19 2 my(@t_pre, @t_post);
20 2 ▶ while( @_ ){
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 2 5
21 3 my $s = shift;
22 3 ▶ if( $s eq '-C' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($s eq '-C') { } 2 1 3
23 2 push(@{$self->{-C}}, shift); }
24 else{
25 1 $self->{$s} = shift; }
26 }
27 2 ▶ $self->{-d} ||= $ENV{FIGLIB} || '/usr/games/lib/figlet/';
Condition60%3/5
$self->{"-d"} ||= $ENV{"FIGLIB"} || "/usr/games/lib/figlet/"
l!l&&r!l&&!r
110
$ENV{'FIGLIB'} || '/usr/games/lib/figlet/'
l!l
10
MC/DC0%0/2
$self->{"-d"} ||= $ENV{"FIGLIB"} || "/usr/games/lib/figlet/"
$self->{"-d"} $ENV{'FIGLIB'}
Truth table66%2/3
A ||= B
A= $self->{"-d"}B= $ENV{'FIGLIB'}
ABresult
1X1
011
000
28 2 ▶ $self->{"_\\"} = 1 if $^O =~ /MSWin32|DOS/i;
Branch: 1 branch
BranchTrueFalseTotal
if $^O =~ /MSWin32|DOS/i 0 2 2
29  
30  
31 # my $no = qr/0x[\da-fA-F]+|\d+/;
32  
33 2 foreach my $flc ( @{$self->{-C}} ){
34 $self->{'_file'} = _canonical($self->{-d},
35 $flc,
36 qr/\.flc/,
37 2 $self->{"_\\"});
38 2 ▶ open(FLC, $self->{'_file'}) || croak("$!: $flc [$self->{_file}]");
Branch: 1 branch
BranchTrueFalseTotal
open FLC, $self->{"_file"} or croak(qq[$!: $flc [$self->{"_file"}]]) 2 0 2
39 2 ▶ while(<FLC>){
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline FLC)) 195 2 197
40 195 ▶ next if /^flc2a|\s*#|^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^flc2a|\s*#|^\s*$/ 38 157 195
41  
42 #XXX Is this adequate?
43 157 ▶ $code .= 'use utf8;' if /^\s*u/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*u/ 1 156 157
44  
45 157 ▶ if( /^\s*$Text::FIGlet::RE{no}\s+$Text::FIGlet::RE{no}\s*/ ){
Branch: 3 branches
BranchTrueFalseTotal
if (/^\s*$Text::FIGlet::RE{'no'}\s+$Text::FIGlet::RE{'no'}\s*/) { } 1 156 157
elsif (/^\s*t\s+\\?$Text::FIGlet::RE{'no'}(?:-\\$Text::FIGlet::RE{'no'})?\s+\\?$Text::FIGlet::RE{'no'}(?:-\\$Text::FIGlet::RE{'no'})?\s*/) { } 4 152 156
elsif (/^\s*t\s+([^\s](?:-[^\s])?)\s+([^\s](?:-[^\s])?)\s*/) { } 1 151 152
46 #Only needed for decimals?!
47  
48 1 push @t_pre, sprintf('\\x{%x}', _no($1, $2, $3));
49 1 push @t_post, sprintf('\\x{%x}', _no($4, $5, $6));
50 }
51 elsif( /^\s*t\s+\\?$Text::FIGlet::RE{no}(?:-\\$Text::FIGlet::RE{no})?\s+\\?$Text::FIGlet::RE{no}(?:-\\$Text::FIGlet::RE{no})?\s*/ ){
52 4 push @t_pre, sprintf( '\\x{%x}', _no( $1, $2, $3));
53 4 push @t_post, sprintf( '\\x{%x}', _no( $7, $8, $9));
54 4 ▶ $t_pre[-1] .= sprintf('-\\x{%x}', _no( $4, $5, $6)) if$5;
Branch: 1 branch
BranchTrueFalseTotal
if $5 3 1 4
55 4 ▶ $t_post[-1].= sprintf('-\\x{%x}', _no($10,$11,$12))if$11;
Branch: 1 branch
BranchTrueFalseTotal
if $11 3 1 4
56 }
57 elsif( /^\s*t\s+([^\s](?:-[^\s])?)\s+([^\s](?:-[^\s])?)\s*/ ){
58 1 push @t_pre, $1;
59 1 push @t_post, $2;
60 }
61 157 ▶ if( /^\s*f/ || eof(FLC) ){
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*f/ or eof FLC) 3 154 157
Condition100%3/3
/^\s*f/ or eof FLC
l!l&&r!l&&!r
12154
MC/DC100%2/2
/^\s*f/ or eof FLC
/^\s*f/ eof FLC
Truth table100%3/3
A or B
A= /^\s*f/B= eof FLC
ABresult
1X1
011
000
62 3 @{$_} = map { s%/%\\/%g, $_ } @{$_} for( \@t_pre, \@t_post );
63 3 $code .= 'tr/' . join('', @t_pre) . '/' . join('', @t_post) . '/;';
64 3 @t_pre = @t_post = ();
65 }
66 }
67 2 close(FLC);
68 }
69 2 ▶ $self->{_sub} = eval "sub { local \$_ = shift; $code; return \$_ }";
Subroutine BEGIN: called CC=1 SCAR=0.0
70 2 bless($self);
71 }
72  
73 2 ▶sub tr($){
Subroutine tr: called CC=2 SCAR=8.1
Pod documented
74 2 my $self = shift;
75 2 ▶ $self->{_sub}->( shift || $_ );
Condition33%1/3
shift() || $_
l!l&&r!l&&!r
200
MC/DC0%0/2
shift() || $_
shift() $_
Truth table33%1/3
A || B
A= shift()B= $_
ABresult
1X1
011
000
76 }
77 4 1;
78 __END__
« lib/Text/FIGlet/Ransom.pm ↑ Summary lib/Text/FIGlet/Illuminated.pm »