Extended.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 5 totaltotal 91.5% 54 / 59 CC 7 SCAR 8.3
CC
7
Cov
100%
grep_print_statements
4.0
matches
2.0
_matches_engine
2.0
CRAP 2.3
↑ Summary Extended/Overview.pm »
1 package IO::Capture::Extended;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 our $VERSION = 0.14;
5 2 require Exporter;
6 2 our @ISA = qw(Exporter);
7 2 our @EXPORT_OK = qw(
8 grep_print_statements
9 statements
10 matches
11 matches_ref
12 all_screen_lines
13 );
14 2 our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
15  
16  
17 10 ▶sub grep_print_statements {
Subroutine grep_print_statements: called CC=4 SCAR=13.9
Pod undocumented
18 10 my $self = shift;
19 10 my $string = shift;
20 10 my @found_statements;
21
22 10 for my $statement (@{$self->{'IO::Capture::messages'}}) {
23 40 ▶ push @found_statements, $statement if $statement =~ /$string/;
Branch: 1 branch
BranchTrueFalseTotal
if $statement =~ /$string/ 24 16 40
24 }
25 10 ▶ return wantarray ? @found_statements : scalar(@found_statements);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 8 10
26 }
27  
28 12 ▶sub statements {
Subroutine statements: called CC=1 SCAR=0.0
Pod undocumented
29 12 my $self = shift;
30 12 return scalar(@{$self->{'IO::Capture::messages'}});
31 };
32  
33 8 ▶sub matches {
Subroutine matches: called CC=2 SCAR=6.9
Pod undocumented
34 8 my @matches = _matches_engine(@_);
35 6 ▶ return wantarray ? @matches : scalar(@matches);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 2 6
36 }
37  
38 2 ▶sub matches_ref {
Subroutine matches_ref: called CC=1 SCAR=0.0
Pod undocumented
39 2 my @matches = _matches_engine(@_);
40 2 return \@matches;
41 }
42  
43 10 ▶sub _matches_engine {
Subroutine _matches_engine: called CC=2 SCAR=6.9
44 10 my ($self, $regex) = @_;
45 10 ▶ die "Not enough arguments: $!"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $regex 2 8 10
46 if (! defined $regex);
47 8 my $str = join('', @{$self->{'IO::Capture::messages'}});
48 8 my @matches = $str =~ m/$regex/g;
49 }
50  
51 26 ▶sub all_screen_lines {
Subroutine all_screen_lines: called CC=2 SCAR=6.9
Pod undocumented
52 26 my $self = shift;
53 26 my @screen_lines;
54 26 @screen_lines = split(/\n/, join('', @{$self->{'IO::Capture::messages'}}));
55 26 ▶ return wantarray ? @screen_lines : scalar(@screen_lines);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 10 16 26
56 }
57  
58 ########## DOCUMENTATION ##########
59  
60 =head1 NAME
61  
62 IO::Capture::Extended - Extend functionality of IO::Capture
63  
64 =head1 SYNOPSIS
65  
66 All documentation is contained in IO::Capture::Extended::Overview.
67  
68 perldoc IO::Capture::Extended::Overview
69  
70 =cut
71  
72 2 1;
73  
↑ Summary Extended/Overview.pm »