line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Maketext::Extract::Plugin::Base; |
2
|
|
|
|
|
|
|
$Locale::Maketext::Extract::Plugin::Base::VERSION = '1.00'; |
3
|
5
|
|
|
5
|
|
40
|
use strict; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
200
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
29
|
use File::Basename qw(fileparse); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
3354
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Base module for format parser plugins |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
48
|
|
|
48
|
1
|
97
|
my $class = shift; |
12
|
48
|
|
|
|
|
308
|
my $self = bless { entries => [], }, $class; |
13
|
|
|
|
|
|
|
|
14
|
48
|
|
|
|
|
328
|
$self->_compile_file_types(@_); |
15
|
48
|
|
|
|
|
161
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub add_entry { |
20
|
193
|
|
|
193
|
1
|
318
|
my $self = shift; |
21
|
193
|
|
|
|
|
233
|
push @{ $self->{entries} }, [@_]; |
|
193
|
|
|
|
|
1632
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#=================================== |
26
|
|
|
|
|
|
|
sub entries { |
27
|
|
|
|
|
|
|
#=================================== |
28
|
191
|
|
|
191
|
1
|
333
|
my $self = shift; |
29
|
191
|
|
|
|
|
972
|
return $self->{entries}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#=================================== |
34
|
|
|
|
|
|
|
sub clear { |
35
|
|
|
|
|
|
|
#=================================== |
36
|
187
|
|
|
187
|
1
|
363
|
my $self = shift; |
37
|
187
|
|
|
|
|
1030
|
$self->{entries} = []; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub file_types { |
42
|
0
|
|
|
0
|
1
|
0
|
die "Please override sub file_types() to return " |
43
|
|
|
|
|
|
|
. "a list of recognised file extensions, or regexes"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub extract { |
48
|
0
|
|
|
0
|
1
|
0
|
die "Please override sub extract()"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _compile_file_types { |
52
|
48
|
|
|
48
|
|
78
|
my $self = shift; |
53
|
|
|
|
|
|
|
my @file_types |
54
|
0
|
|
|
|
|
0
|
= ref $_[0] eq 'ARRAY' |
55
|
48
|
50
|
|
|
|
196
|
? @{ shift @_ } |
56
|
|
|
|
|
|
|
: @_; |
57
|
48
|
100
|
|
|
|
298
|
@file_types = $self->file_types |
58
|
|
|
|
|
|
|
unless @file_types; |
59
|
|
|
|
|
|
|
|
60
|
48
|
|
|
|
|
90
|
my @checks; |
61
|
48
|
100
|
|
|
|
96
|
if ( grep { $_ eq '*' } @file_types ) { |
|
104
|
|
|
|
|
304
|
|
62
|
18
|
|
|
0
|
|
186
|
$self->{file_checks} = [ sub {1} ]; |
|
0
|
|
|
|
|
0
|
|
63
|
18
|
|
|
|
|
60
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
30
|
|
|
|
|
74
|
foreach my $type (@file_types) { |
66
|
86
|
50
|
|
|
|
204
|
if ( ref $type eq 'CODE' ) { |
67
|
0
|
|
|
|
|
0
|
push @checks, $type; |
68
|
0
|
|
|
|
|
0
|
next; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
86
|
100
|
|
|
|
2029
|
my $regex |
72
|
|
|
|
|
|
|
= ref $type |
73
|
|
|
|
|
|
|
? $type |
74
|
|
|
|
|
|
|
: qr/^.*\.\Q$type\E$/; |
75
|
86
|
|
|
181
|
|
468
|
push @checks, sub { $_[0] =~ m/$regex/ }; |
|
181
|
|
|
|
|
943
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
30
|
|
|
|
|
253
|
$self->{file_checks} = \@checks; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub known_file_type { |
83
|
70
|
|
|
70
|
1
|
123
|
my $self = shift; |
84
|
70
|
|
|
|
|
974
|
my ( $name, $path ) = fileparse( shift @_ ); |
85
|
70
|
|
|
|
|
101
|
foreach my $check ( @{ $self->{file_checks} } ) { |
|
70
|
|
|
|
|
160
|
|
86
|
181
|
100
|
|
|
|
332
|
return 1 if $check->( $name, $path ); |
87
|
|
|
|
|
|
|
} |
88
|
56
|
|
|
|
|
283
|
return 0; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |