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

filter: Statementstmt 86.1% 31 / 36 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 81.2% 39 / 48 CC 5 SCAR 15.1
CC
5
Cov
80%
_set_regex
12.0
process
3.0
BEGIN
1.0
CRAP 4.5
« blib/lib/Tail/Tool/RegexList.pm ↑ Summary Build »
1 package Tail::Tool::Plugin::Replace;
2  
3 # Created on: 2010-11-10 09:10:52
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=3 SCAR=11.0
Pod documented
22 2 my $matches;
23  
24 2 for my $match ( @{ $self->regex } ) {
25 2 $matches += $match->enabled;
26 2 ▶ if ( $match->enabled ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match->enabled) 2 0 2
27 2 my $reg = $match->regex;
28 2 my $rep = $match->replace;
29 2 eval { $line =~ s/$reg/eval qq{"$rep"}/e };
30 }
31 }
32  
33 # return empty array if there were enabled matches else return the line
34 2 return ($line);
35 }
36  
37 sub _set_regex {
38 0 ▶ my ( $self, $regexs, $old_regexs ) = @_;
Subroutine _set_regex: not called CC=3 SCAR=24.8
39  
40 0 for my $regex ( @{ $regexs } ) {
41 0 ▶ $regex->replace('') if !$regex->has_replace;
Branch: 1 branch
BranchTrueFalseTotal
unless $regex->has_replace 0 0 0
42 }
43  
44 0 return;
45 }
46  
47 2 1;
48  
49 __END__
50  
51 =head1 NAME
52  
53 Tail::Tool::Plugin::Replace - <One-line description of module's purpose>
54  
55 =head1 VERSION
56  
57 This documentation refers to Tail::Tool::Plugin::Replace version 0.4.6.
58  
59  
60 =head1 SYNOPSIS
61  
62 use Tail::Tool::Plugin::Replace;
63  
64 # Brief but working code example(s) here showing the most common usage(s)
65 # This section will be as far as many users bother reading, so make it as
66 # educational and exemplary as possible.
67  
68  
69 =head1 DESCRIPTION
70  
71 A full description of the module and its features.
72  
73 May include numerous subsections (i.e., =head2, =head3, etc.).
74  
75  
76 =head1 SUBROUTINES/METHODS
77  
78 =head2 C<process ($line)>
79  
80 Param: C<$line> -The line to process
81  
82 Performs any changes to the line that have been specified.
83  
84 =head1 DIAGNOSTICS
85  
86 A list of every error and warning message that the module can generate (even
87 the ones that will "never happen"), with a full explanation of each problem,
88 one or more likely causes, and any suggested remedies.
89  
90 =head1 CONFIGURATION AND ENVIRONMENT
91  
92 A full explanation of any configuration system(s) used by the module, including
93 the names and locations of any configuration files, and the meaning of any
94 environment variables or properties that can be set. These descriptions must
95 also include details of any configuration language used.
96  
97 =head1 DEPENDENCIES
98  
99 A list of all of the other modules that this module relies upon, including any
100 restrictions on versions, and an indication of whether these required modules
101 are part of the standard Perl distribution, part of the module's distribution,
102 or must be installed separately.
103  
104 =head1 INCOMPATIBILITIES
105  
106 A list of any modules that this module cannot be used in conjunction with.
107 This may be due to name conflicts in the interface, or competition for system
108 or program resources, or due to internal limitations of Perl (for example, many
109 modules that use source code filters are mutually incompatible).
110  
111 =head1 BUGS AND LIMITATIONS
112  
113 A list of known problems with the module, together with some indication of
114 whether they are likely to be fixed in an upcoming release.
115  
116 Also, a list of restrictions on the features the module does provide: data types
117 that cannot be handled, performance issues and the circumstances in which they
118 may arise, practical limitations on the size of data sets, special cases that
119 are not (yet) handled, etc.
120  
121 The initial template usually just has:
122  
123 There are no known bugs in this module.
124  
125 Please report problems to Ivan Wills (ivan.wills@gmail.com).
126  
127 Patches are welcome.
128  
129 =head1 AUTHOR
130  
131 Ivan Wills - (ivan.wills@gmail.com)
132  
133 =head1 LICENSE AND COPYRIGHT
134  
135 Copyright (c) 2010 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW, Australia).
136 All rights reserved.
137  
138 This module is free software; you can redistribute it and/or modify it under
139 the same terms as Perl itself. See L<perlartistic>. This program is
140 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
141 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
142 PARTICULAR PURPOSE.
143  
144 =cut
« blib/lib/Tail/Tool/RegexList.pm ↑ Summary Build »