line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Setup::Distribute; |
2
|
47
|
|
|
47
|
|
394
|
use strict; |
|
47
|
|
|
|
|
106
|
|
|
47
|
|
|
|
|
2216
|
|
3
|
47
|
|
|
47
|
|
260
|
use warnings; |
|
47
|
|
|
|
|
10392
|
|
|
47
|
|
|
|
|
1655
|
|
4
|
|
|
|
|
|
|
|
5
|
47
|
|
|
47
|
|
358
|
use Fcntl qw( :mode ); |
|
47
|
|
|
|
|
101
|
|
|
47
|
|
|
|
|
20325
|
|
6
|
47
|
|
|
47
|
|
329
|
use YAML (); |
|
47
|
|
|
|
|
111
|
|
|
47
|
|
|
|
|
997
|
|
7
|
|
|
|
|
|
|
|
8
|
47
|
|
|
47
|
|
31228
|
use Module::Setup::Path::Dir; |
|
47
|
|
|
|
|
161
|
|
|
47
|
|
|
|
|
41031
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
56
|
|
|
56
|
0
|
399
|
my($class, $module, %args) = @_; |
12
|
|
|
|
|
|
|
|
13
|
56
|
|
|
|
|
296
|
my @pkg = split /::/, $module; |
14
|
56
|
100
|
100
|
|
|
685
|
my $target = exists $args{target} && $args{target} ? $args{target} : '.'; |
15
|
|
|
|
|
|
|
|
16
|
56
|
|
|
|
|
1196
|
my $self = bless { |
17
|
|
|
|
|
|
|
module => $module, |
18
|
|
|
|
|
|
|
package => \@pkg, |
19
|
|
|
|
|
|
|
dist_name => join('-', @pkg), |
20
|
|
|
|
|
|
|
install_files => [], |
21
|
|
|
|
|
|
|
}, $class; |
22
|
|
|
|
|
|
|
|
23
|
56
|
|
|
|
|
649
|
$self->{target_path} = Module::Setup::Path::Dir->new($target); |
24
|
56
|
|
|
|
|
3632
|
$self->{base_path} = Module::Setup::Path::Dir->new($target, $self->{dist_name}); |
25
|
56
|
|
|
|
|
3549
|
$self->{dist_path} = Module::Setup::Path::Dir->new($target, $self->{dist_name}); |
26
|
56
|
|
|
|
|
1632
|
$self->{module_path} = Module::Setup::Path::Dir->new(@{ $self->{package} }); |
|
56
|
|
|
|
|
281
|
|
27
|
56
|
|
|
|
|
3741
|
$self->{additionals} = []; |
28
|
|
|
|
|
|
|
|
29
|
56
|
|
|
|
|
385
|
$self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
0
|
5
|
sub additionals { shift->{additionals} }; |
33
|
54
|
|
|
54
|
0
|
316
|
sub module { shift->{module} }; |
34
|
53
|
|
|
53
|
0
|
197
|
sub module_path { shift->{module_path} }; |
35
|
161
|
|
|
161
|
0
|
1600
|
sub package { shift->{package} }; |
36
|
68
|
|
|
68
|
0
|
352
|
sub dist_name { shift->{dist_name} }; |
37
|
0
|
|
|
0
|
0
|
0
|
sub target_path { shift->{target_path} }; |
38
|
7
|
|
|
7
|
0
|
56
|
sub base_path { shift->{base_path} }; |
39
|
618
|
|
|
618
|
0
|
6667
|
sub dist_path { shift->{dist_path} }; |
40
|
485
|
|
|
485
|
0
|
3674
|
sub template_vars { shift->{template_vars} }; |
41
|
1
|
|
|
1
|
0
|
11
|
sub install_files { shift->{install_files} }; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub set_template_vars { |
44
|
53
|
|
|
53
|
0
|
137
|
my($self, $vars) = @_; |
45
|
53
|
|
|
|
|
197
|
$self->{template_vars} = $vars; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub install_template { |
49
|
475
|
|
|
475
|
0
|
1236
|
my($self, $context, $path, $base_src) = @_; |
50
|
|
|
|
|
|
|
|
51
|
475
|
100
|
|
|
|
3004
|
$base_src = $context->base_dir->flavor->template unless $base_src; |
52
|
475
|
|
|
|
|
3855
|
my $src = $base_src->path_to($path); |
53
|
475
|
100
|
|
|
|
2579
|
my $template = $src->is_dir ? undef : $src->slurp; |
54
|
475
|
100
|
|
|
|
32805
|
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
|
475
|
100
|
|
|
|
2566
|
$options->{content} = delete $options->{template} if -B $src; |
62
|
475
|
|
|
|
|
2006
|
$self->write_template($context, $options); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub write_template { |
66
|
486
|
|
|
486
|
0
|
1290
|
my($self, $context, $options) = @_; |
67
|
486
|
|
|
|
|
2232
|
my $is_dir = $options->{dist_path}->is_dir; |
68
|
|
|
|
|
|
|
|
69
|
486
|
100
|
|
|
|
2719
|
unless ($is_dir) { |
70
|
478
|
|
|
|
|
5785
|
$context->call_trigger( template_process => $options ); |
71
|
478
|
100
|
|
|
|
10270
|
$options->{template} = delete $options->{content} unless $options->{template}; |
72
|
|
|
|
|
|
|
} |
73
|
486
|
100
|
|
|
|
2861
|
$options->{dist_path} =~ s/____var-(.+?)-var____/$options->{vars}->{$1} || $options->{vars}->{config}->{$1}/eg; |
|
44
|
|
|
|
|
5276
|
|
74
|
486
|
|
|
|
|
33916
|
$context->call_trigger( replace_distribute_path => $options ); |
75
|
|
|
|
|
|
|
|
76
|
486
|
100
|
|
|
|
32534
|
if ($is_dir) { |
77
|
8
|
|
|
|
|
41
|
$options->{dist_path} = Module::Setup::Path::Dir->new($options->{dist_path}); |
78
|
|
|
|
|
|
|
} else { |
79
|
478
|
|
|
|
|
14159
|
$options->{dist_path} = Module::Setup::Path::File->new($options->{dist_path}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
486
|
|
|
|
|
65550
|
push @{ $self->{install_files} }, $options->{dist_path}; |
|
486
|
|
|
|
|
1776
|
|
83
|
|
|
|
|
|
|
|
84
|
486
|
100
|
|
|
|
3027
|
$is_dir ? $options->{dist_path}->mkpath : $context->write_file($options); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |