line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FileMetadata::Miner::Ext;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.1';
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1026
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
1798
|
use XML::Simple;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new {
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $self = {};
|
11
|
|
|
|
|
|
|
bless $self, shift;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $config = shift;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Obtain the file suffix to look for from the config
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
if (exists $config->{'suffix'}) {
|
18
|
|
|
|
|
|
|
$self->{'ext'} = $config->{'suffix'};
|
19
|
|
|
|
|
|
|
} else {
|
20
|
|
|
|
|
|
|
$self->{'ext'} = '.ext';
|
21
|
|
|
|
|
|
|
}
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return $self;
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub mine {
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my ($self, $path, $meta) = @_;
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Get the file path for the XML file to examine
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$path = $path . $self->{'ext'};
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if (-f $path && -r $path) {
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $ext = XMLin ($path);
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
while (my ($key, $value) = each (%{$ext})) {
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$meta->{ref ($self) . "::$key"} = $value;
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# If file cannot be opened, we still return true
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return 1;
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1;
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__
|