line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim: set ts=2 sts=2 sw=2 expandtab smarttab: |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This file is part of Dist-Metadata |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This software is copyright (c) 2011 by Randy Stauner. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
9
|
|
|
|
|
|
|
# |
10
|
7
|
|
|
7
|
|
3409
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
414
|
|
11
|
7
|
|
|
7
|
|
39
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
438
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Dist::Metadata::Struct; |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
$Dist::Metadata::Struct::VERSION = '0.925'; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
BEGIN { |
18
|
7
|
|
|
7
|
|
164
|
$Dist::Metadata::Struct::AUTHORITY = 'cpan:RWSTAUNER'; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
# ABSTRACT: Enable Dist::Metadata for a data structure |
21
|
|
|
|
|
|
|
|
22
|
7
|
|
|
7
|
|
39
|
use Carp qw(croak carp); # core |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
462
|
|
23
|
7
|
|
|
7
|
|
3980
|
use parent 'Dist::Metadata::Dist'; |
|
7
|
|
|
|
|
1141
|
|
|
7
|
|
|
|
|
47
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
push(@Dist::Metadata::CARP_NOT, __PACKAGE__); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
47
|
|
|
47
|
1
|
139
|
sub required_attribute { 'files' } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
17
|
|
|
17
|
1
|
580
|
sub default_file_spec { 'Unix' } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub file_content { |
35
|
47
|
|
|
47
|
1
|
1404
|
my ($self, $file) = @_; |
36
|
|
|
|
|
|
|
# TODO: should we croak if not found? would be consistent with Dir |
37
|
47
|
|
|
|
|
430
|
my $content = $self->{files}{ $self->full_path($file) }; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# 5.10: given(ref($content)) |
40
|
|
|
|
|
|
|
|
41
|
47
|
100
|
|
|
|
4465
|
if( my $ref = ref $content ){ |
42
|
3
|
|
|
|
|
12
|
local $/; # do this here because of perl bug prior to perl 5.15 (7c2d9d0) |
43
|
3
|
100
|
|
|
|
44
|
return $ref eq 'SCALAR' |
44
|
|
|
|
|
|
|
# allow a scalar ref |
45
|
|
|
|
|
|
|
? $$content |
46
|
|
|
|
|
|
|
# or an IO-like object |
47
|
|
|
|
|
|
|
: $content->getline; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
# else a simple string |
50
|
44
|
|
|
|
|
650
|
return $content; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub find_files { |
55
|
31
|
|
|
31
|
1
|
54
|
my ($self) = @_; |
56
|
|
|
|
|
|
|
|
57
|
31
|
|
|
|
|
38
|
return keys %{ $self->{files} }; |
|
31
|
|
|
|
|
275
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |