line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::string; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
105661
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use List::Util qw(all); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
8
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util qw(is_string is_value is_array_ref is_hash_ref); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
9
|
1
|
|
|
1
|
|
515
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
10
|
1
|
|
|
1
|
|
7
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
385
|
use namespace::clean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
12
|
1
|
|
|
1
|
|
785
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
15
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_fixer { |
19
|
7
|
|
|
7
|
|
60
|
my ($self) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
as_path($self->path)->updater( |
22
|
|
|
|
|
|
|
sub { |
23
|
6
|
|
|
6
|
|
8
|
my $val = $_[0]; |
24
|
6
|
100
|
100
|
|
|
51
|
if (is_string($val)) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
25
|
2
|
|
|
|
|
38
|
"${val}"; |
26
|
|
|
|
|
|
|
} |
27
|
4
|
|
|
|
|
84
|
elsif (is_array_ref($val) && all {is_value($_)} @$val) { |
28
|
1
|
|
|
|
|
31
|
join('', @$val); |
29
|
|
|
|
|
|
|
} |
30
|
4
|
|
|
|
|
13
|
elsif (is_hash_ref($val) && all {is_value($_)} values %$val) { |
31
|
1
|
|
|
|
|
4
|
join('', map {$val->{$_}} sort keys %$val); |
|
2
|
|
|
|
|
26
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
2
|
|
|
|
|
41
|
''; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
7
|
|
|
|
|
30
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Catmandu::Fix::string - convert a value to a string |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# year => 2016 |
54
|
|
|
|
|
|
|
string(year) |
55
|
|
|
|
|
|
|
# year => "2016" |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# foo => ["a", "b", "c"] |
58
|
|
|
|
|
|
|
string(foo) |
59
|
|
|
|
|
|
|
# foo => "abc" |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# foo => ["a", {b => "c"}, "d"] |
62
|
|
|
|
|
|
|
string(foo) |
63
|
|
|
|
|
|
|
# foo => "" |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# foo => {2 => "b", 1 => "a"} |
66
|
|
|
|
|
|
|
string(foo) |
67
|
|
|
|
|
|
|
# foo => "ab" |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# foo => {a => ["b"]} |
70
|
|
|
|
|
|
|
string(foo) |
71
|
|
|
|
|
|
|
# foo => "" |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<Catmandu::Fix> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |