line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Maketext::Extract::Plugin::YAML; |
2
|
|
|
|
|
|
|
$Locale::Maketext::Extract::Plugin::YAML::VERSION = '1.00'; |
3
|
4
|
|
|
4
|
|
27
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
163
|
|
4
|
4
|
|
|
4
|
|
21
|
use base qw(Locale::Maketext::Extract::Plugin::Base); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
849
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: YAML format parser |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub file_types { |
10
|
18
|
|
|
18
|
1
|
64
|
return qw( yaml yml conf ); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub extract { |
14
|
13
|
|
|
13
|
1
|
19
|
my $self = shift; |
15
|
13
|
|
|
|
|
27
|
my $data = shift; |
16
|
|
|
|
|
|
|
|
17
|
13
|
|
|
|
|
135
|
my $y = Locale::Maketext::Extract::Plugin::YAML::Extractor->new(); |
18
|
13
|
|
|
|
|
58
|
$y->load($data); |
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
|
|
186
|
foreach my $entry ( @{ $y->found } ) { |
|
10
|
|
|
|
|
26
|
|
21
|
21
|
|
|
|
|
78
|
$self->add_entry(@$entry); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Locale::Maketext::Extract::Plugin::YAML::Extractor; |
27
|
|
|
|
|
|
|
$Locale::Maketext::Extract::Plugin::YAML::Extractor::VERSION = '1.00'; |
28
|
4
|
|
|
4
|
|
26
|
use base qw(YAML::Loader); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2946
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#=================================== |
31
|
|
|
|
|
|
|
sub new { |
32
|
|
|
|
|
|
|
#=================================== |
33
|
13
|
|
|
13
|
|
21
|
my $class = shift; |
34
|
13
|
|
|
|
|
86
|
my $self = $class->SUPER::new(@_); |
35
|
13
|
|
|
|
|
169
|
$self->{found} = []; |
36
|
13
|
|
|
|
|
26
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#=================================== |
40
|
|
|
|
|
|
|
sub check_scalar { |
41
|
|
|
|
|
|
|
#=================================== |
42
|
38
|
|
|
38
|
|
54
|
my $self = shift; |
43
|
38
|
|
|
|
|
48
|
my $node = $_[0]; |
44
|
38
|
100
|
66
|
|
|
356
|
if ( defined $node && !ref $node && $node =~ /^__?(["'])(.+)\1$/s ) { |
|
|
|
100
|
|
|
|
|
45
|
21
|
|
|
|
|
48
|
my $string = $2; |
46
|
21
|
|
|
|
|
28
|
my $line = $_[1]; |
47
|
21
|
|
|
|
|
27
|
push @{ $self->{found} }, [ $string, $line ]; |
|
21
|
|
|
|
|
76
|
|
48
|
|
|
|
|
|
|
} |
49
|
38
|
|
|
|
|
140
|
return $node; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _parse_node { |
53
|
30
|
|
|
30
|
|
5601
|
my $self = shift; |
54
|
30
|
50
|
66
|
|
|
110
|
my $line = $self->{_start_line} |
55
|
|
|
|
|
|
|
||= length( $self->preface ) ? $self->line - 1 : $self->line; |
56
|
30
|
|
|
|
|
229
|
my $node = $self->SUPER::_parse_node(@_); |
57
|
30
|
|
|
|
|
3235
|
$self->{start_line} = 0; |
58
|
30
|
|
|
|
|
73
|
return $self->check_scalar( $node, $line ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _parse_inline_seq { |
62
|
2
|
|
|
2
|
|
221
|
my $self = shift; |
63
|
2
|
|
33
|
|
|
11
|
my $line = $self->{_start_line} ||= $self->line; |
64
|
2
|
|
|
|
|
15
|
my $node = $self->SUPER::_parse_inline_seq(@_); |
65
|
2
|
|
|
|
|
536
|
foreach (@$node) { |
66
|
5
|
|
|
|
|
9
|
$self->check_scalar( $_, $line ); |
67
|
|
|
|
|
|
|
} |
68
|
2
|
|
|
|
|
5
|
$self->{start_line} = 0; |
69
|
2
|
|
|
|
|
6
|
return $node; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _parse_inline_mapping { |
73
|
1
|
|
|
1
|
|
103
|
my $self = shift; |
74
|
1
|
|
33
|
|
|
7
|
my $line = $self->{_start_line} ||= $self->line; |
75
|
1
|
|
|
|
|
13
|
my $node = $self->SUPER::_parse_inline_mapping(@_); |
76
|
1
|
|
|
|
|
561
|
foreach ( values %$node ) { |
77
|
3
|
|
|
|
|
8
|
$self->check_scalar( $_, $line ); |
78
|
|
|
|
|
|
|
} |
79
|
1
|
|
|
|
|
4
|
$self->{start_line} = 0; |
80
|
1
|
|
|
|
|
4
|
return $node; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#=================================== |
84
|
|
|
|
|
|
|
sub _parse_next_line { |
85
|
|
|
|
|
|
|
#=================================== |
86
|
39
|
|
|
39
|
|
5489
|
my $self = shift; |
87
|
39
|
100
|
|
|
|
141
|
$self->{_start_line} = $self->line |
88
|
|
|
|
|
|
|
if $_[0] == YAML::Loader::COLLECTION; |
89
|
39
|
|
|
|
|
430
|
$self->SUPER::_parse_next_line(@_); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub found { |
93
|
10
|
|
|
10
|
|
21
|
my $self = shift; |
94
|
10
|
|
|
|
|
37
|
return $self->{found}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |