line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Setup::Distribute; |
2
|
41
|
|
|
41
|
|
199
|
use strict; |
|
41
|
|
|
|
|
69
|
|
|
41
|
|
|
|
|
1161
|
|
3
|
41
|
|
|
41
|
|
169
|
use warnings; |
|
41
|
|
|
|
|
63
|
|
|
41
|
|
|
|
|
1235
|
|
4
|
|
|
|
|
|
|
|
5
|
41
|
|
|
41
|
|
184
|
use Fcntl qw( :mode ); |
|
41
|
|
|
|
|
57
|
|
|
41
|
|
|
|
|
12896
|
|
6
|
41
|
|
|
41
|
|
233
|
use YAML (); |
|
41
|
|
|
|
|
69
|
|
|
41
|
|
|
|
|
830
|
|
7
|
|
|
|
|
|
|
|
8
|
41
|
|
|
41
|
|
16126
|
use Module::Setup::Path::Dir; |
|
41
|
|
|
|
|
84
|
|
|
41
|
|
|
|
|
30692
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
50
|
|
|
50
|
0
|
275
|
my($class, $module, %args) = @_; |
12
|
|
|
|
|
|
|
|
13
|
50
|
|
|
|
|
226
|
my @pkg = split /::/, $module; |
14
|
50
|
100
|
66
|
|
|
920
|
my $target = exists $args{target} && $args{target} ? $args{target} : '.'; |
15
|
|
|
|
|
|
|
|
16
|
50
|
|
|
|
|
640
|
my $self = bless { |
17
|
|
|
|
|
|
|
module => $module, |
18
|
|
|
|
|
|
|
package => \@pkg, |
19
|
|
|
|
|
|
|
dist_name => join('-', @pkg), |
20
|
|
|
|
|
|
|
install_files => [], |
21
|
|
|
|
|
|
|
}, $class; |
22
|
|
|
|
|
|
|
|
23
|
50
|
|
|
|
|
388
|
$self->{target_path} = Module::Setup::Path::Dir->new($target); |
24
|
50
|
|
|
|
|
2419
|
$self->{base_path} = Module::Setup::Path::Dir->new($target, $self->{dist_name}); |
25
|
50
|
|
|
|
|
1764
|
$self->{dist_path} = Module::Setup::Path::Dir->new($target, $self->{dist_name}); |
26
|
50
|
|
|
|
|
1258
|
$self->{module_path} = Module::Setup::Path::Dir->new(@{ $self->{package} }); |
|
50
|
|
|
|
|
170
|
|
27
|
50
|
|
|
|
|
1796
|
$self->{additionals} = []; |
28
|
|
|
|
|
|
|
|
29
|
50
|
|
|
|
|
244
|
$self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
0
|
4
|
sub additionals { shift->{additionals} }; |
33
|
47
|
|
|
47
|
0
|
321
|
sub module { shift->{module} }; |
34
|
47
|
|
|
47
|
0
|
137
|
sub module_path { shift->{module_path} }; |
35
|
49
|
|
|
49
|
0
|
274
|
sub package { shift->{package} }; |
36
|
61
|
|
|
61
|
0
|
229
|
sub dist_name { shift->{dist_name} }; |
37
|
0
|
|
|
0
|
0
|
0
|
sub target_path { shift->{target_path} }; |
38
|
7
|
|
|
7
|
0
|
31
|
sub base_path { shift->{base_path} }; |
39
|
565
|
|
|
565
|
0
|
3400
|
sub dist_path { shift->{dist_path} }; |
40
|
448
|
|
|
448
|
0
|
53285
|
sub template_vars { shift->{template_vars} }; |
41
|
1
|
|
|
1
|
0
|
7
|
sub install_files { shift->{install_files} }; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub set_template_vars { |
44
|
47
|
|
|
47
|
0
|
96
|
my($self, $vars) = @_; |
45
|
47
|
|
|
|
|
163
|
$self->{template_vars} = $vars; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub install_template { |
49
|
439
|
|
|
439
|
0
|
761
|
my($self, $context, $path, $base_src) = @_; |
50
|
|
|
|
|
|
|
|
51
|
439
|
100
|
|
|
|
1685
|
$base_src = $context->base_dir->flavor->template unless $base_src; |
52
|
439
|
|
|
|
|
1314
|
my $src = $base_src->path_to($path); |
53
|
439
|
100
|
|
|
|
1315
|
my $template = $src->is_dir ? undef : $src->slurp; |
54
|
439
|
100
|
|
|
|
68265
|
my $options = +{ |
55
|
|
|
|
|
|
|
dist_path => ($src->is_dir ? $self->dist_path->subdir($path) : $self->dist_path->file($path)), |
56
|
|
|
|
|
|
|
template => $template, |
57
|
|
|
|
|
|
|
chmod => sprintf('%03o', S_IMODE(( stat $src )[2])), |
58
|
|
|
|
|
|
|
vars => $self->template_vars, |
59
|
|
|
|
|
|
|
content => undef, |
60
|
|
|
|
|
|
|
}; |
61
|
439
|
100
|
|
|
|
1837
|
$options->{content} = delete $options->{template} if -B $src; |
62
|
439
|
|
|
|
|
24372
|
$self->write_template($context, $options); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub write_template { |
66
|
449
|
|
|
449
|
0
|
796
|
my($self, $context, $options) = @_; |
67
|
449
|
|
|
|
|
1275
|
my $is_dir = $options->{dist_path}->is_dir; |
68
|
|
|
|
|
|
|
|
69
|
449
|
100
|
|
|
|
1505
|
unless ($is_dir) { |
70
|
441
|
|
|
|
|
1411
|
$context->call_trigger( template_process => $options ); |
71
|
441
|
100
|
|
|
|
5413
|
$options->{template} = delete $options->{content} unless $options->{template}; |
72
|
|
|
|
|
|
|
} |
73
|
449
|
100
|
|
|
|
1710
|
$options->{dist_path} =~ s/____var-(.+?)-var____/$options->{vars}->{$1} || $options->{vars}->{config}->{$1}/eg; |
|
40
|
|
|
|
|
3006
|
|
74
|
449
|
|
|
|
|
14432
|
$context->call_trigger( replace_distribute_path => $options ); |
75
|
|
|
|
|
|
|
|
76
|
449
|
100
|
|
|
|
13182
|
if ($is_dir) { |
77
|
8
|
|
|
|
|
27
|
$options->{dist_path} = Module::Setup::Path::Dir->new($options->{dist_path}); |
78
|
|
|
|
|
|
|
} else { |
79
|
441
|
|
|
|
|
2802
|
$options->{dist_path} = Module::Setup::Path::File->new($options->{dist_path}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
449
|
|
|
|
|
39857
|
push @{ $self->{install_files} }, $options->{dist_path}; |
|
449
|
|
|
|
|
1023
|
|
83
|
|
|
|
|
|
|
|
84
|
449
|
100
|
|
|
|
2051
|
$is_dir ? $options->{dist_path}->mkpath : $context->write_file($options); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |