line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86284
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util qw(is_string is_array_ref is_hash_ref); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
283
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
9
|
1
|
|
|
1
|
|
369
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
10
|
1
|
|
|
1
|
|
6
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
11
|
1
|
|
|
1
|
|
598
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my ($self) = @_; |
17
|
|
|
|
|
|
|
|
18
|
14
|
|
|
14
|
|
91
|
as_path($self->path)->updater( |
19
|
|
|
|
|
|
|
sub { |
20
|
|
|
|
|
|
|
my $val = $_[0]; |
21
|
|
|
|
|
|
|
if (is_string($val) and my ($num) = $val =~ /([+-]?[0-9]+)/) { |
22
|
13
|
|
|
13
|
|
18
|
$num + 0; |
23
|
13
|
100
|
66
|
|
|
67
|
} |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
6
|
|
|
|
|
98
|
elsif (is_array_ref($val)) { |
25
|
|
|
|
|
|
|
scalar(@$val); |
26
|
|
|
|
|
|
|
} |
27
|
3
|
|
|
|
|
56
|
elsif (is_hash_ref($val)) { |
28
|
|
|
|
|
|
|
scalar(keys %$val); |
29
|
|
|
|
|
|
|
} |
30
|
3
|
|
|
|
|
47
|
else { |
31
|
|
|
|
|
|
|
0; |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
|
|
15
|
} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
14
|
|
|
|
|
37
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Catmandu::Fix::int - convert a value to an integer |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# year => "2016" |
49
|
|
|
|
|
|
|
int(year) |
50
|
|
|
|
|
|
|
# year => 2016 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# foo => "bar-123baz" |
53
|
|
|
|
|
|
|
int(foo) |
54
|
|
|
|
|
|
|
# foo => -123 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# foo => "" |
57
|
|
|
|
|
|
|
int(foo) |
58
|
|
|
|
|
|
|
# foo => 0 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# foo => "abc" |
61
|
|
|
|
|
|
|
int(foo) |
62
|
|
|
|
|
|
|
# foo => 0 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# foo => [] |
65
|
|
|
|
|
|
|
int(foo) |
66
|
|
|
|
|
|
|
# foo => 0 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# foo => ["a", "b", "c"] |
69
|
|
|
|
|
|
|
int(foo) |
70
|
|
|
|
|
|
|
# foo => 3 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# foo => {a => "b", c => "d"} |
73
|
|
|
|
|
|
|
int(foo) |
74
|
|
|
|
|
|
|
# foo => 2 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SEE ALSO |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L<Catmandu::Fix> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |