line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Tasks::Provider; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# See POD at end for docs |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
135
|
|
6
|
4
|
|
|
4
|
|
21
|
use Scalar::Util (); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
84
|
|
7
|
4
|
|
|
4
|
|
21
|
use Params::Util qw{_INSTANCE _SCALAR _ARRAY}; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
217
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
28
|
use vars qw{$VERSION}; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
199
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
4
|
|
|
4
|
|
1537
|
$VERSION = '0.07'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my @COMPATIBLE_CLASSES = qw{ |
15
|
|
|
|
|
|
|
Archive::Builder::File |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
##################################################################### |
23
|
|
|
|
|
|
|
# Main Methods |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub compatible { |
27
|
8
|
|
|
8
|
1
|
31
|
my $class = shift; |
28
|
8
|
|
|
|
|
14
|
my $it = shift; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Check the basic data types |
31
|
8
|
100
|
|
|
|
33
|
return '' unless defined $it; |
32
|
6
|
100
|
|
|
|
21
|
return !! length $it unless ref $it; |
33
|
4
|
50
|
|
|
|
9
|
return 1 unless ref $it; |
34
|
4
|
100
|
|
|
|
19
|
return 1 if _SCALAR($it); |
35
|
3
|
100
|
|
|
|
15
|
return 1 if _ARRAY($it); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# We don't handle any other data types |
38
|
1
|
|
|
|
|
5
|
my $its_class = Scalar::Util::blessed $it; |
39
|
1
|
50
|
|
|
|
12
|
return '' unless $its_class; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Check for an allowed object class |
42
|
0
|
|
|
|
|
0
|
foreach ( @COMPATIBLE_CLASSES ) { |
43
|
0
|
0
|
|
|
|
0
|
return 1 if _INSTANCE($its_class, $_); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
''; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub content { |
50
|
4
|
|
|
4
|
1
|
10
|
my $either = shift; |
51
|
4
|
50
|
|
|
|
14
|
my $it = defined $_[0] ? shift : return undef; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Handle the basic data types |
54
|
4
|
100
|
|
|
|
16
|
return \$it unless ref $it; |
55
|
3
|
100
|
|
|
|
14
|
return $it if _SCALAR($it); |
56
|
2
|
50
|
|
|
|
7
|
if ( _ARRAY($it) ) { |
57
|
2
|
|
|
|
|
6
|
$it = ($it->[0] =~ /\n$/) |
58
|
|
|
|
|
|
|
? join('', @$it) |
59
|
2
|
100
|
|
|
|
10
|
: join('', map { "$_\n" } @$it); |
60
|
2
|
|
|
|
|
10
|
return \$it; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Handle the various compatible object classes |
64
|
0
|
0
|
|
|
|
|
if ( _INSTANCE($it, 'Archive::Builder::File') ) { |
65
|
0
|
|
|
|
|
|
return $it->content; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
undef; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |