line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
94861
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
7
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
785
|
use Catmandu::Util qw(trim); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
9
|
1
|
|
|
1
|
|
6
|
use Unicode::Normalize; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
10
|
1
|
|
|
1
|
|
515
|
use namespace::clean; |
|
1
|
|
|
|
|
1943
|
|
|
1
|
|
|
|
|
71
|
|
11
|
1
|
|
|
1
|
|
9
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
12
|
1
|
|
|
1
|
|
782
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
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
|
|
49
|
if ($self->mode eq 'whitespace') { |
21
|
7
|
|
|
|
|
9
|
$cb = sub { |
22
|
7
|
100
|
|
|
|
28
|
trim($_[0]); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
23
|
|
|
|
|
|
|
}; |
24
|
6
|
|
|
6
|
|
18
|
} |
25
|
5
|
|
|
|
|
14
|
elsif ($self->mode eq 'nonword') { |
26
|
|
|
|
|
|
|
$cb = sub { |
27
|
|
|
|
|
|
|
my $val = $_[0]; |
28
|
|
|
|
|
|
|
$val =~ s/^\W+//; |
29
|
1
|
|
|
1
|
|
3
|
$val =~ s/\W+$//; |
30
|
1
|
|
|
|
|
4
|
$val; |
31
|
1
|
|
|
|
|
6
|
}; |
32
|
1
|
|
|
|
|
15
|
} |
33
|
1
|
|
|
|
|
4
|
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
|
|
|
|
|
12
|
$val; |
39
|
1
|
|
|
1
|
|
563
|
}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
12
|
|
40
|
1
|
|
|
|
|
17
|
} |
41
|
1
|
|
|
|
|
5
|
as_path($self->path)->updater(if_string => $cb); |
42
|
|
|
|
|
|
|
} |
43
|
7
|
|
|
|
|
50
|
|
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 |