line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin; |
2
|
|
|
|
|
|
|
|
3
|
60
|
|
|
301
|
|
243308
|
use strict; |
|
60
|
|
|
|
|
139
|
|
|
60
|
|
|
|
|
1853
|
|
4
|
60
|
|
|
60
|
|
303
|
use warnings; |
|
60
|
|
|
|
|
129
|
|
|
60
|
|
|
|
|
1460
|
|
5
|
60
|
|
|
60
|
|
956
|
use 5.008004; |
|
60
|
|
|
|
|
211
|
|
6
|
60
|
|
|
60
|
|
38491
|
use Data::Dumper (); |
|
60
|
|
|
|
|
390596
|
|
|
60
|
|
|
|
|
1815
|
|
7
|
60
|
|
|
60
|
|
524
|
use Carp (); |
|
60
|
|
|
|
|
143
|
|
|
60
|
|
|
|
|
896
|
|
8
|
60
|
|
|
60
|
|
34111
|
use Digest::SHA (); |
|
60
|
|
|
|
|
185013
|
|
|
60
|
|
|
|
|
21262
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @CARP_NOT = qw( alienfile Alien::Build Alien::Build::Meta ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Plugin base class for Alien::Build |
13
|
|
|
|
|
|
|
our $VERSION = '2.46'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new |
17
|
|
|
|
|
|
|
{ |
18
|
2947
|
|
|
2947
|
1
|
288250
|
my $class = shift; |
19
|
2947
|
100
|
|
|
|
8611
|
my %args = @_ == 1 ? ($class->meta->default => $_[0]) : @_; |
20
|
|
|
|
|
|
|
|
21
|
2947
|
|
|
|
|
14373
|
my $instance_id = Digest::SHA::sha1_hex(Data::Dumper->new([$class, \%args])->Sortkeys(1)->Dump); |
22
|
2947
|
|
|
|
|
173885
|
my $self = bless { instance_id => $instance_id }, $class; |
23
|
|
|
|
|
|
|
|
24
|
2947
|
|
|
|
|
8400
|
my $prop = $self->meta->prop; |
25
|
2947
|
|
|
|
|
8530
|
foreach my $name (keys %$prop) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
$self->{$name} = defined $args{$name} |
28
|
|
|
|
|
|
|
? delete $args{$name} |
29
|
|
|
|
|
|
|
: ref($prop->{$name}) eq 'CODE' |
30
|
|
|
|
|
|
|
? $prop->{$name}->() |
31
|
1043
|
100
|
|
|
|
4931
|
: $prop->{$name}; |
|
|
100
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
2947
|
|
|
|
|
5609
|
foreach my $name (keys %args) |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
|
|
0
|
Carp::carp "$class has no $name property"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
2947
|
|
|
|
|
7862
|
$self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
62
|
|
|
62
|
1
|
297
|
sub instance_id { shift->{instance_id} } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub init |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
1
|
0
|
my($self) = @_; |
49
|
0
|
|
|
|
|
0
|
$self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub import |
53
|
|
|
|
|
|
|
{ |
54
|
614
|
|
|
614
|
|
4354
|
my($class) = @_; |
55
|
|
|
|
|
|
|
|
56
|
614
|
100
|
|
|
|
22701
|
return if $class ne __PACKAGE__; |
57
|
|
|
|
|
|
|
|
58
|
531
|
|
|
|
|
1302
|
my $caller = caller; |
59
|
60
|
|
|
60
|
|
595
|
{ no strict 'refs'; @{ "${caller}::ISA" } = __PACKAGE__ } |
|
60
|
|
|
|
|
168
|
|
|
60
|
|
|
|
|
9244
|
|
|
531
|
|
|
|
|
890
|
|
|
531
|
|
|
|
|
829
|
|
|
531
|
|
|
|
|
11698
|
|
60
|
|
|
|
|
|
|
|
61
|
531
|
|
|
|
|
5653
|
my $meta = $caller->meta; |
62
|
|
|
|
|
|
|
my $has = sub { |
63
|
448
|
|
|
448
|
|
7843
|
my($name, $default) = @_; |
64
|
448
|
|
|
|
|
1095
|
$meta->add_property($name, $default); |
65
|
531
|
|
|
|
|
3260
|
}; |
66
|
|
|
|
|
|
|
|
67
|
60
|
|
|
60
|
|
479
|
{ no strict 'refs'; *{ "${caller}::has" } = $has } |
|
60
|
|
|
|
|
591
|
|
|
60
|
|
|
|
|
34464
|
|
|
531
|
|
|
|
|
1150
|
|
|
531
|
|
|
|
|
788
|
|
|
531
|
|
|
|
|
62404
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub subplugin |
72
|
|
|
|
|
|
|
{ |
73
|
1
|
|
|
1
|
1
|
32
|
my(undef, $name, %args) = @_; |
74
|
1
|
|
|
|
|
214
|
Carp::carp("subplugin method is deprecated"); |
75
|
1
|
|
|
|
|
80
|
my $class = "Alien::Build::Plugin::$name"; |
76
|
1
|
|
|
|
|
3
|
my $pm = "$class.pm"; |
77
|
1
|
|
|
|
|
7
|
$pm =~ s/::/\//g; |
78
|
1
|
50
|
|
|
|
4
|
require $pm unless eval { $class->can('new') }; |
|
1
|
|
|
|
|
19
|
|
79
|
1
|
|
|
|
|
5
|
delete $args{$_} for grep { ! defined $args{$_} } keys %args; |
|
2
|
|
|
|
|
9
|
|
80
|
1
|
|
|
|
|
5
|
$class->new(%args); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my %meta; |
85
|
|
|
|
|
|
|
sub meta |
86
|
|
|
|
|
|
|
{ |
87
|
3514
|
|
|
3514
|
1
|
6982
|
my($class) = @_; |
88
|
3514
|
100
|
|
|
|
9476
|
$class = ref $class if ref $class; |
89
|
3514
|
|
66
|
|
|
14372
|
$meta{$class} ||= Alien::Build::PluginMeta->new( class => $class ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
package Alien::Build::PluginMeta; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub new |
95
|
|
|
|
|
|
|
{ |
96
|
532
|
|
|
532
|
|
1803
|
my($class, %args) = @_; |
97
|
532
|
|
|
|
|
5082
|
my $self = bless { |
98
|
|
|
|
|
|
|
prop => {}, |
99
|
|
|
|
|
|
|
%args, |
100
|
|
|
|
|
|
|
}, $class; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub default |
104
|
|
|
|
|
|
|
{ |
105
|
35
|
|
|
35
|
|
89
|
my($self) = @_; |
106
|
35
|
50
|
|
|
|
206
|
$self->{default} || do { |
107
|
0
|
|
|
|
|
0
|
Carp::croak "No default for @{[ $self->{class} ]}"; |
|
0
|
|
|
|
|
0
|
|
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub add_property |
112
|
|
|
|
|
|
|
{ |
113
|
448
|
|
|
448
|
|
874
|
my($self, $name, $default) = @_; |
114
|
448
|
|
|
|
|
1285
|
my $single = $name =~ s{^(\+)}{}; |
115
|
448
|
100
|
|
|
|
1203
|
$self->{default} = $name if $single; |
116
|
448
|
|
|
|
|
965
|
$self->{prop}->{$name} = $default; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $accessor = sub { |
119
|
1557
|
|
|
1557
|
|
5157
|
my($self, $new) = @_; |
120
|
1557
|
100
|
|
|
|
2999
|
$self->{$name} = $new if defined $new; |
121
|
1557
|
|
|
|
|
6564
|
$self->{$name}; |
122
|
448
|
|
|
|
|
1665
|
}; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# add the accessor |
125
|
60
|
|
|
60
|
|
596
|
{ no strict 'refs'; *{ $self->{class} . '::' . $name} = $accessor } |
|
60
|
|
|
|
|
185
|
|
|
60
|
|
|
|
|
6848
|
|
|
448
|
|
|
|
|
750
|
|
|
448
|
|
|
|
|
637
|
|
|
448
|
|
|
|
|
2394
|
|
126
|
|
|
|
|
|
|
|
127
|
448
|
|
|
|
|
1145
|
$self; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub prop |
131
|
|
|
|
|
|
|
{ |
132
|
2947
|
|
|
2947
|
|
6144
|
shift->{prop}; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |