blib/lib/Catmandu/Fix/replace_all.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 96.1% 25 / 26 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Catmandu/Fix/prepend.pm ↑ Summary blib/lib/Catmandu/Serializer.pm »
1 package Catmandu::Fix::replace_all;
2  
3 2 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '1.0201_02';
6  
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 has path => (fix_arg => 1);
12 2 has search => (fix_arg => 1);
13 2 has replace => (fix_arg => 1);
14  
15 2 with 'Catmandu::Fix::SimpleGetValue';
16  
17 sub emit_value {
18 3 ▶ my ($self, $var, $fixer) = @_;
Subroutine emit_value: called CC=1 SCAR=0.0
Pod undocumented
19  
20 3 "if (is_value(${var})) {"
21 . "utf8::upgrade(${var});"
22 . "${var} =~ "
23 . $fixer->emit_substitution($self->search, $self->replace) . "g;"
24 . "}";
25 }
26  
27 2 1;
28  
29 __END__
30  
31 =pod
32  
33 =head1 NAME
34  
35 Catmandu::Fix::replace_all - search and replace using regex expressions
36  
37 =head1 SYNOPSIS
38  
39 # Extract a substring out of the value of a field
40 # {author => "tom jones"}
41 replace_all(author, '([^ ]+) ([^ ]+)', '$2, $1')
42 # {author => "jones, tom"}
43  
44 =head1 SEE ALSO
45  
46 L<Catmandu::Fix>
47  
48 =cut
« blib/lib/Catmandu/Fix/prepend.pm ↑ Summary blib/lib/Catmandu/Serializer.pm »