line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
89683
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
721
|
use Catmandu::Util qw(trim); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
9
|
1
|
|
|
1
|
|
6
|
use Unicode::Normalize; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
10
|
1
|
|
|
1
|
|
467
|
use namespace::clean; |
|
1
|
|
|
|
|
1972
|
|
|
1
|
|
|
|
|
55
|
|
11
|
1
|
|
|
1
|
|
7
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
12
|
1
|
|
|
1
|
|
683
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
13
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
16
|
|
|
|
|
|
|
has mode => (fix_arg => 1, default => sub {'whitespace'}); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
my $cb; |
20
|
7
|
|
|
7
|
|
48
|
if ($self->mode eq 'whitespace') { |
21
|
7
|
|
|
|
|
8
|
$cb = sub { |
22
|
7
|
100
|
|
|
|
28
|
trim($_[0]); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
23
|
|
|
|
|
|
|
}; |
24
|
6
|
|
|
6
|
|
16
|
} |
25
|
5
|
|
|
|
|
13
|
elsif ($self->mode eq 'nonword') { |
26
|
|
|
|
|
|
|
$cb = sub { |
27
|
|
|
|
|
|
|
my $val = $_[0]; |
28
|
|
|
|
|
|
|
$val =~ s/^\W+//; |
29
|
1
|
|
|
1
|
|
2
|
$val =~ s/\W+$//; |
30
|
1
|
|
|
|
|
4
|
$val; |
31
|
1
|
|
|
|
|
6
|
}; |
32
|
1
|
|
|
|
|
15
|
} |
33
|
1
|
|
|
|
|
5
|
elsif ($self->mode eq 'diacritics') { |
34
|
|
|
|
|
|
|
$cb = sub { |
35
|
|
|
|
|
|
|
my $val = $_[0]; |
36
|
|
|
|
|
|
|
$val = Unicode::Normalize::NFKD($val); |
37
|
1
|
|
|
1
|
|
2
|
$val =~ s/\p{NonspacingMark}//g; |
38
|
1
|
|
|
|
|
11
|
$val; |
39
|
1
|
|
|
1
|
|
546
|
}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
|
1
|
|
|
|
|
12
|
|
40
|
1
|
|
|
|
|
17
|
} |
41
|
1
|
|
|
|
|
4
|
as_path($self->path)->updater(if_string => $cb); |
42
|
|
|
|
|
|
|
} |
43
|
7
|
|
|
|
|
52
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=encoding utf-8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Catmandu::Fix::trim - trim leading and ending junk from the value of a field |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# the default mode trims whitespace |
58
|
|
|
|
|
|
|
# e.g. foo => ' abc '; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
trim(foo) # foo => 'abc'; |
61
|
|
|
|
|
|
|
trim(foo, whitespace) # foo => 'abc'; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# trim non-word characters |
64
|
|
|
|
|
|
|
# e.g. foo => ' abc / : .'; |
65
|
|
|
|
|
|
|
trim(foo, nonword) # foo => 'abc'; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# trim accents |
68
|
|
|
|
|
|
|
# e.g. foo => 'français' ; |
69
|
|
|
|
|
|
|
trim(foo,diacritics) # foo => 'francais' |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L<Catmandu::Fix> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |