lib/TUI/Editors/Util.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 16 / 16 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 97.4% 76 / 78 CC 10 SCAR 10.6
CC
10
Cov
98%
countLines
4.0
iScan
4.0
scan
4.0
CRAP 2.9
« lib/TUI/Objects/NSCollection.pm ↑ Summary lib/TUI/Drivers/ScreenCharacter.pm »
1 package TUI::Editors::Util;
2 # ABSTRACT: Utility functions for editor buffers
3
4 15 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 15 our $VERSION = '2.000003';
9 15 $VERSION =~ tr/_//d;
10 15 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 15 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 our @EXPORT_OK = qw(
14 countLines
15 iScan
16 scan
17 );
18 15 our %EXPORT_TAGS = (
19 all => \@EXPORT_OK,
20 );
21
22 15 ▶use TUI::toolkit qw( signature );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 15 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
24 Maybe
25 PositiveOrZeroInt
26 Str
27 15 );
28
29 15 ▶use TUI::Editors::Const qw( sfSearchFailed );
Subroutine BEGIN: called CC=1 SCAR=0.0
30
31 4 ▶sub countLines { # $count ($buf, |$count)
Subroutine countLines: called CC=4 SCAR=13.9
Pod documented
32 4 state $sig = signature(
33 pos => [
34 Str,
35 PositiveOrZeroInt, { optional => 1 },
36 ],
37 );
38 4 my ( $buf, $count ) = $sig->( @_ );
39
40 4 ▶ return 0 unless length $buf;
Branch: 1 branch
BranchTrueFalseTotal
unless length $buf 1 3 4
41
42 3 ▶ $buf = substr( $buf, 0, $count )
Branch: 1 branch
BranchTrueFalseTotal
if defined $count and $count < length $buf 1 2 3
Condition66%2/3
defined $count and $count < length $buf
!ll&&!rl&&r
201
MC/DC50%1/2
defined $count and $count < length $buf
defined $count $count < length $buf
Truth table66%2/3
A and B
A= defined $countB= $count < length $buf
ABresult
0X0
100
111
43 if defined $count && $count < length $buf;
44
45 3 my $lines = () = $buf =~ /\R/g;
46 3 return $lines;
47 }
48
49 6 ▶sub iScan { # $pos ($block, $size, $str)
Subroutine iScan: called CC=4 SCAR=13.9
Pod documented
50 6 state $sig = signature(
51 pos => [
52 Str,
53 PositiveOrZeroInt,
54 Str,
55 ],
56 );
57 6 my ( $block, $size, $str ) = $sig->( @_ );
58
59 6 ▶ return sfSearchFailed unless length $str;
Branch: 1 branch
BranchTrueFalseTotal
unless length $str 1 5 6
60
61 5 ▶ $block = substr( $block, 0, $size )
Branch: 1 branch
BranchTrueFalseTotal
if $size < length $block 1 4 5
62 if $size < length $block;
63
64 5 ▶ return $-[0] if $block =~ /\Q$str\E/i;
Branch: 1 branch
BranchTrueFalseTotal
if $block =~ /\Q$str\E/i 4 1 5
65 1 return sfSearchFailed;
66 }
67
68 5 ▶sub scan { # $pos ($block, $size, $str)
Subroutine scan: called CC=4 SCAR=13.9
Pod documented
69 5 state $sig = signature(
70 pos => [
71 Str,
72 PositiveOrZeroInt,
73 Str,
74 ],
75 );
76 5 my ( $block, $size, $str ) = $sig->( @_ );
77
78 5 ▶ return sfSearchFailed unless length $str;
Branch: 1 branch
BranchTrueFalseTotal
unless length $str 1 4 5
79
80 4 ▶ $block = substr( $block, 0, $size )
Branch: 1 branch
BranchTrueFalseTotal
if $size < length $block 1 3 4
81 if $size < length $block;
82
83 4 my $pos = index( $block, $str );
84 4 ▶ return $pos >= 0 ? $pos : sfSearchFailed;
Branch: 1 branch
BranchTrueFalseTotal
$pos >= 0 ? : 2 2 4
85 }
86
87 15 1
88
89 __END__
« lib/TUI/Objects/NSCollection.pm ↑ Summary lib/TUI/Drivers/ScreenCharacter.pm »