line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Meta::Creator; |
2
|
2
|
|
|
2
|
|
236498
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = "0.13"; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use List::Util (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
8
|
2
|
|
|
2
|
|
539
|
use Sub::Meta; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
709
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
30
|
sub _croak { require Carp; goto &Carp::croak } |
|
5
|
|
|
|
|
589
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
14
|
|
|
14
|
1
|
28171
|
my ($class, @args) = @_; |
14
|
14
|
100
|
|
|
|
99
|
my %args = @args == 1 ? %{$args[0]} : @args; |
|
1
|
|
|
|
|
4
|
|
15
|
|
|
|
|
|
|
|
16
|
14
|
100
|
|
|
|
42
|
unless (exists $args{finders}) { |
17
|
1
|
|
|
|
|
4
|
_croak 'required finders'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
13
|
100
|
100
|
|
|
69
|
unless (ref $args{finders} && ref $args{finders} eq 'ARRAY') { |
21
|
2
|
|
|
|
|
7
|
_croak 'finders must be an arrayref' |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
11
|
100
|
|
11
|
|
36
|
unless (List::Util::all { ref $_ && ref $_ eq 'CODE' } @{$args{finders}}) { |
|
11
|
100
|
|
|
|
55
|
|
|
11
|
|
|
|
|
42
|
|
25
|
2
|
|
|
|
|
5
|
_croak 'elements of finders have to be a code reference' |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
9
|
|
|
|
|
48
|
return bless \%args => $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
1
|
23
|
sub sub_meta_class { return 'Sub::Meta' } |
32
|
|
|
|
|
|
|
|
33
|
7
|
|
|
7
|
1
|
12
|
sub finders { my $self = shift; return $self->{finders} } |
|
7
|
|
|
|
|
23
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub find_materials { |
36
|
6
|
|
|
6
|
1
|
30
|
my ($self, $sub) = @_; |
37
|
6
|
|
|
|
|
12
|
for my $finder (@{$self->finders}) { |
|
6
|
|
|
|
|
13
|
|
38
|
6
|
|
|
|
|
14
|
my $materials = $finder->($sub); |
39
|
6
|
100
|
|
|
|
40
|
return $materials if defined $materials; |
40
|
|
|
|
|
|
|
} |
41
|
3
|
|
|
|
|
15
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub create { |
45
|
2
|
|
|
2
|
1
|
14
|
my ($self, $sub) = @_; |
46
|
2
|
100
|
|
|
|
6
|
if (my $materials = $self->find_materials($sub)) { |
47
|
1
|
|
|
|
|
6
|
return $self->sub_meta_class->new($materials) |
48
|
|
|
|
|
|
|
} |
49
|
1
|
|
|
|
|
5
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |