line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Pods2Site::PodCopier; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
48
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
7
|
|
|
|
|
|
|
my $version = $VERSION; |
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
9
|
use App::Pods2Site::Util qw(slashify createSpinner); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
96
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
17
|
use Cwd; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
101
|
|
13
|
2
|
|
|
2
|
|
9
|
use File::Copy; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
102
|
|
14
|
2
|
|
|
2
|
|
11
|
use File::Basename; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
96
|
|
15
|
2
|
|
|
2
|
|
9
|
use File::Path qw(make_path); |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
1007
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# CTOR |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
sub new |
20
|
|
|
|
|
|
|
{ |
21
|
3
|
|
|
3
|
0
|
9
|
my $class = shift; |
22
|
3
|
|
|
|
|
4
|
my $args = shift; |
23
|
3
|
|
|
|
|
6
|
my $podFinder = shift; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
26
|
my $cwd = getcwd(); |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
84
|
my $self = bless( { podroot => slashify("$cwd/podroot"), count => 0 }, $class); |
28
|
3
|
|
|
|
|
28
|
$self->__copyPods($args, $podFinder); |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
12
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub getCount |
34
|
|
|
|
|
|
|
{ |
35
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
105
|
return $self->{count}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub getPodRoot |
41
|
|
|
|
|
|
|
{ |
42
|
3
|
|
|
3
|
0
|
10
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
11
|
return $self->{podroot}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub getWorkGroups |
48
|
|
|
|
|
|
|
{ |
49
|
6
|
|
|
6
|
0
|
12
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
|
|
151
|
return $self->{workgroups}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# copy all found pods into a work tree, so the HTML generation |
55
|
|
|
|
|
|
|
# has a good base to work from |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
sub __copyPods |
58
|
|
|
|
|
|
|
{ |
59
|
3
|
|
|
3
|
|
8
|
my $self = shift; |
60
|
3
|
|
|
|
|
10
|
my $args = shift; |
61
|
3
|
|
|
|
|
5
|
my $podFinder = shift; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# keep running tally of groups and associated pods |
64
|
|
|
|
|
|
|
# |
65
|
3
|
|
|
|
|
5
|
my @workGroups; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# set up some progress feedback |
68
|
|
|
|
|
|
|
# |
69
|
3
|
|
|
|
|
20
|
my $spinner = createSpinner($args); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# copy pods from each group |
72
|
|
|
|
|
|
|
# |
73
|
3
|
|
|
|
|
5
|
my $count = 0; |
74
|
3
|
|
|
|
|
18
|
my $groups = $podFinder->getGroups(); |
75
|
3
|
|
|
|
|
23
|
foreach my $group (@$groups) |
76
|
|
|
|
|
|
|
{ |
77
|
6
|
|
|
|
|
18
|
my $groupName = $group->{name}; |
78
|
6
|
|
|
|
|
10
|
my $pods = $group->{pods}; |
79
|
6
|
|
|
|
|
11
|
my %podInfo; |
80
|
6
|
|
|
|
|
13
|
foreach my $pod (@$pods) |
81
|
|
|
|
|
|
|
{ |
82
|
10
|
|
|
|
|
18
|
my $podName = $pod->{name}; |
83
|
10
|
|
|
|
|
16
|
my $inFile = $pod->{path}; |
84
|
10
|
|
|
|
|
29
|
my $podFile = $self->__copy($inFile, $podName, $groupName, $args); |
85
|
10
|
|
|
|
|
56
|
$podInfo{$podName} = { podfile => $podFile, htmlfile => undef }; |
86
|
10
|
|
|
|
|
29
|
$spinner->(++$count); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
6
|
|
|
|
|
39
|
push(@workGroups, { group => $groupName, podinfo => \%podInfo }); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
3
|
|
|
|
|
23
|
$self->{workgroups} = \@workGroups; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub __copy |
96
|
|
|
|
|
|
|
{ |
97
|
10
|
|
|
10
|
|
16
|
my $self = shift; |
98
|
10
|
|
|
|
|
11
|
my $infile = shift; |
99
|
10
|
|
|
|
|
12
|
my $name = shift; |
100
|
10
|
|
|
|
|
22
|
my $group = shift; |
101
|
10
|
|
|
|
|
12
|
my $args = shift; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# copy every 'name' infile to outfile, for simplicity, always use the '.pod' extension |
104
|
|
|
|
|
|
|
# |
105
|
10
|
|
|
|
|
12
|
my $podname = $name; |
106
|
10
|
|
|
|
|
30
|
$podname =~ s#::#/#g; |
107
|
10
|
|
|
|
|
49
|
my $outfile = slashify("$self->{podroot}/$group/$podname.pod"); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# we're copying in a specific order, and it's possible |
110
|
|
|
|
|
|
|
# a pod with the same name might come from two different categories |
111
|
|
|
|
|
|
|
# if so, only copy the first, but make sure the copy retains the mtime |
112
|
|
|
|
|
|
|
# from the infile, so the HTML gen can avoid regenerating |
113
|
|
|
|
|
|
|
# |
114
|
10
|
|
|
|
|
151
|
my $mtimeInfile = (stat($infile))[9]; |
115
|
10
|
50
|
|
|
|
155
|
if (!-e $outfile) |
116
|
|
|
|
|
|
|
{ |
117
|
10
|
|
|
|
|
516
|
my $outfileDir = dirname($outfile); |
118
|
10
|
100
|
|
|
|
1321
|
(!-d $outfileDir ? make_path($outfileDir) : 1) || die ("Failed to create directory '$outfileDir': $!\n"); |
|
|
50
|
|
|
|
|
|
119
|
10
|
50
|
|
|
|
87
|
copy($infile, $outfile) || die("Failed to copy $infile => $outfile: $!\n"); |
120
|
10
|
|
|
|
|
3154
|
utime($mtimeInfile, $mtimeInfile, $outfile); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
10
|
|
|
|
|
35
|
$self->{count}++; |
124
|
|
|
|
|
|
|
|
125
|
10
|
50
|
|
|
|
46
|
print "Copied '$infile' => '$outfile'\n" if $args->isVerboseLevel(3); |
126
|
|
|
|
|
|
|
|
127
|
10
|
|
|
|
|
32
|
return $outfile; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |