blib/lib/Tail/Tool/Plugin/Match.pm

filter: Statementstmt 100% 28 / 28 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 93.1% 41 / 44 CC 5 SCAR 11.1
CC
5
Cov
94%
process
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« blib/lib/Tail/Tool/Regex.pm ↑ Summary blib/lib/Tail/Tool/Plugin/Spacing.pm »
1 package Tail::Tool::Plugin::Match;
2  
3 # Created on: 2010-10-06 14:16:02
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 extends 'Tail::Tool::PreProcess';
16 2 with 'Tail::Tool::RegexList';
17  
18 2 our $VERSION = version->new('0.4.6');
19  
20 sub process {
21 2 ▶ my ($self, $line) = @_;
Subroutine process: called CC=5 SCAR=16.2
Pod documented
22 2 my $matches;
23  
24 2 for my $match ( @{ $self->regex } ) {
25 2 $matches += $match->enabled;
26 2 my $reg = $match->regex;
27 2 ▶ if ( $match->enabled && $line =~ /$reg/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match->enabled and $line =~ /$reg/) 1 1 2
Condition66%2/3
$match->enabled and $line =~ /$reg/
!ll&&!rl&&r
011
MC/DC50%1/2
$match->enabled and $line =~ /$reg/
$match->enabled $line =~ /$reg/
Truth table66%2/3
A and B
A= $match->enabledB= $line =~ /$reg/
ABresult
0X0
100
111
28 # return the line if it matches
29 1 return ($line);
30 }
31 }
32  
33 # return empty array if there were enabled matches else return the line
34 1 ▶ return $matches ? () : ($line);
Branch: 1 branch
BranchTrueFalseTotal
$matches ? : 1 0 1
35 }
36  
37 2 1;
38  
39 __END__
40  
41 =head1 NAME
42  
43 Tail::Tool::Plugin::Match - Checks that each line passed matches a regex
44  
45 =head1 VERSION
46  
47 This documentation refers to Tail::Tool::Plugin::Match version 0.4.6.
48  
49  
50 =head1 SYNOPSIS
51  
52 use Tail::Tool::Plugin::Match;
53  
54 # Brief but working code example(s) here showing the most common usage(s)
55 # This section will be as far as many users bother reading, so make it as
56 # educational and exemplary as possible.
57  
58  
59 =head1 DESCRIPTION
60  
61 =head1 SUBROUTINES/METHODS
62  
63 =head2 C<new (%params)>
64  
65 Param: regex - ArrayRef - List of regular expressions that lines must match
66  
67 =head2 C<process ($line)>
68  
69 Description: Check the the C<$line> passed matches at least one enabled regular
70 expression. The line will be returned if it matches or if there are no enabled
71 regular expressions, otherwise no line is returned.
72  
73 =head1 DIAGNOSTICS
74  
75 A list of every error and warning message that the module can generate (even
76 the ones that will "never happen"), with a full explanation of each problem,
77 one or more likely causes, and any suggested remedies.
78  
79 =head1 CONFIGURATION AND ENVIRONMENT
80  
81 A full explanation of any configuration system(s) used by the module, including
82 the names and locations of any configuration files, and the meaning of any
83 environment variables or properties that can be set. These descriptions must
84 also include details of any configuration language used.
85  
86 =head1 DEPENDENCIES
87  
88 A list of all of the other modules that this module relies upon, including any
89 restrictions on versions, and an indication of whether these required modules
90 are part of the standard Perl distribution, part of the module's distribution,
91 or must be installed separately.
92  
93 =head1 INCOMPATIBILITIES
94  
95 A list of any modules that this module cannot be used in conjunction with.
96 This may be due to name conflicts in the interface, or competition for system
97 or program resources, or due to internal limitations of Perl (for example, many
98 modules that use source code filters are mutually incompatible).
99  
100 =head1 BUGS AND LIMITATIONS
101  
102 A list of known problems with the module, together with some indication of
103 whether they are likely to be fixed in an upcoming release.
104  
105 Also, a list of restrictions on the features the module does provide: data types
106 that cannot be handled, performance issues and the circumstances in which they
107 may arise, practical limitations on the size of data sets, special cases that
108 are not (yet) handled, etc.
109  
110 The initial template usually just has:
111  
112 There are no known bugs in this module.
113  
114 Please report problems to Ivan Wills (ivan.wills@gamil.com).
115  
116 Patches are welcome.
117  
118 =head1 AUTHOR
119  
120 Ivan Wills - (ivan.wills@gamil.com)
121 <Author name(s)> (<contact address>)
122  
123 =head1 LICENSE AND COPYRIGHT
124  
125 Copyright (c) 2010 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW, Australia, 2077).
126 All rights reserved.
127  
128 This module is free software; you can redistribute it and/or modify it under
129 the same terms as Perl itself. See L<perlartistic>. This program is
130 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
131 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
132 PARTICULAR PURPOSE.
133  
134 =cut
« blib/lib/Tail/Tool/Regex.pm ↑ Summary blib/lib/Tail/Tool/Plugin/Spacing.pm »