line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin; |
2
|
|
|
|
|
|
|
|
3
|
60
|
|
|
319
|
|
196703
|
use strict; |
|
60
|
|
|
|
|
121
|
|
|
60
|
|
|
|
|
1483
|
|
4
|
60
|
|
|
60
|
|
255
|
use warnings; |
|
60
|
|
|
|
|
108
|
|
|
60
|
|
|
|
|
1161
|
|
5
|
60
|
|
|
60
|
|
798
|
use 5.008004; |
|
60
|
|
|
|
|
179
|
|
6
|
60
|
|
|
60
|
|
30872
|
use Data::Dumper (); |
|
60
|
|
|
|
|
324832
|
|
|
60
|
|
|
|
|
1552
|
|
7
|
60
|
|
|
60
|
|
475
|
use Carp (); |
|
60
|
|
|
|
|
112
|
|
|
60
|
|
|
|
|
752
|
|
8
|
60
|
|
|
60
|
|
28396
|
use Digest::SHA (); |
|
60
|
|
|
|
|
153657
|
|
|
60
|
|
|
|
|
17433
|
|
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.47'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new |
17
|
|
|
|
|
|
|
{ |
18
|
2947
|
|
|
2947
|
1
|
248254
|
my $class = shift; |
19
|
2947
|
100
|
|
|
|
7436
|
my %args = @_ == 1 ? ($class->meta->default => $_[0]) : @_; |
20
|
|
|
|
|
|
|
|
21
|
2947
|
|
|
|
|
12756
|
my $instance_id = Digest::SHA::sha1_hex(Data::Dumper->new([$class, \%args])->Sortkeys(1)->Dump); |
22
|
2947
|
|
|
|
|
152731
|
my $self = bless { instance_id => $instance_id }, $class; |
23
|
|
|
|
|
|
|
|
24
|
2947
|
|
|
|
|
7622
|
my $prop = $self->meta->prop; |
25
|
2947
|
|
|
|
|
7277
|
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
|
|
|
|
3654
|
: $prop->{$name}; |
|
|
100
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
2947
|
|
|
|
|
5825
|
foreach my $name (keys %args) |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
|
|
0
|
Carp::carp "$class has no $name property"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
2947
|
|
|
|
|
7290
|
$self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
62
|
|
|
62
|
1
|
292
|
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
|
|
3585
|
my($class) = @_; |
55
|
|
|
|
|
|
|
|
56
|
614
|
100
|
|
|
|
16189
|
return if $class ne __PACKAGE__; |
57
|
|
|
|
|
|
|
|
58
|
531
|
|
|
|
|
1136
|
my $caller = caller; |
59
|
60
|
|
|
60
|
|
561
|
{ no strict 'refs'; @{ "${caller}::ISA" } = __PACKAGE__ } |
|
60
|
|
|
|
|
140
|
|
|
60
|
|
|
|
|
6373
|
|
|
531
|
|
|
|
|
764
|
|
|
531
|
|
|
|
|
722
|
|
|
531
|
|
|
|
|
9803
|
|
60
|
|
|
|
|
|
|
|
61
|
531
|
|
|
|
|
4874
|
my $meta = $caller->meta; |
62
|
|
|
|
|
|
|
my $has = sub { |
63
|
448
|
|
|
448
|
|
6301
|
my($name, $default) = @_; |
64
|
448
|
|
|
|
|
1036
|
$meta->add_property($name, $default); |
65
|
531
|
|
|
|
|
2803
|
}; |
66
|
|
|
|
|
|
|
|
67
|
60
|
|
|
60
|
|
458
|
{ no strict 'refs'; *{ "${caller}::has" } = $has } |
|
60
|
|
|
|
|
172
|
|
|
60
|
|
|
|
|
24749
|
|
|
531
|
|
|
|
|
945
|
|
|
531
|
|
|
|
|
688
|
|
|
531
|
|
|
|
|
54459
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub subplugin |
72
|
|
|
|
|
|
|
{ |
73
|
1
|
|
|
1
|
1
|
26
|
my(undef, $name, %args) = @_; |
74
|
1
|
|
|
|
|
188
|
Carp::carp("subplugin method is deprecated"); |
75
|
1
|
|
|
|
|
72
|
my $class = "Alien::Build::Plugin::$name"; |
76
|
1
|
|
|
|
|
4
|
my $pm = "$class.pm"; |
77
|
1
|
|
|
|
|
5
|
$pm =~ s/::/\//g; |
78
|
1
|
50
|
|
|
|
2
|
require $pm unless eval { $class->can('new') }; |
|
1
|
|
|
|
|
12
|
|
79
|
1
|
|
|
|
|
4
|
delete $args{$_} for grep { ! defined $args{$_} } keys %args; |
|
2
|
|
|
|
|
8
|
|
80
|
1
|
|
|
|
|
4
|
$class->new(%args); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my %meta; |
85
|
|
|
|
|
|
|
sub meta |
86
|
|
|
|
|
|
|
{ |
87
|
3514
|
|
|
3514
|
1
|
5742
|
my($class) = @_; |
88
|
3514
|
100
|
|
|
|
7978
|
$class = ref $class if ref $class; |
89
|
3514
|
|
66
|
|
|
12970
|
$meta{$class} ||= Alien::Build::PluginMeta->new( class => $class ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
package Alien::Build::PluginMeta; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub new |
95
|
|
|
|
|
|
|
{ |
96
|
532
|
|
|
532
|
|
1656
|
my($class, %args) = @_; |
97
|
532
|
|
|
|
|
4398
|
my $self = bless { |
98
|
|
|
|
|
|
|
prop => {}, |
99
|
|
|
|
|
|
|
%args, |
100
|
|
|
|
|
|
|
}, $class; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub default |
104
|
|
|
|
|
|
|
{ |
105
|
35
|
|
|
35
|
|
84
|
my($self) = @_; |
106
|
35
|
50
|
|
|
|
180
|
$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
|
|
746
|
my($self, $name, $default) = @_; |
114
|
448
|
|
|
|
|
1162
|
my $single = $name =~ s{^(\+)}{}; |
115
|
448
|
100
|
|
|
|
1007
|
$self->{default} = $name if $single; |
116
|
448
|
|
|
|
|
835
|
$self->{prop}->{$name} = $default; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $accessor = sub { |
119
|
1557
|
|
|
1557
|
|
4307
|
my($self, $new) = @_; |
120
|
1557
|
100
|
|
|
|
2475
|
$self->{$name} = $new if defined $new; |
121
|
1557
|
|
|
|
|
6140
|
$self->{$name}; |
122
|
448
|
|
|
|
|
1437
|
}; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# add the accessor |
125
|
60
|
|
|
60
|
|
475
|
{ no strict 'refs'; *{ $self->{class} . '::' . $name} = $accessor } |
|
60
|
|
|
|
|
144
|
|
|
60
|
|
|
|
|
5458
|
|
|
448
|
|
|
|
|
629
|
|
|
448
|
|
|
|
|
545
|
|
|
448
|
|
|
|
|
2088
|
|
126
|
|
|
|
|
|
|
|
127
|
448
|
|
|
|
|
1024
|
$self; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub prop |
131
|
|
|
|
|
|
|
{ |
132
|
2947
|
|
|
2952
|
|
5846
|
shift->{prop}; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |