| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ShipIt::ProjectType::Perl; |
|
2
|
2
|
|
|
2
|
|
47140
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
89
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use base 'ShipIt::ProjectType'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1163
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use File::Spec; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
42
|
|
|
5
|
2
|
|
|
2
|
|
17
|
use ShipIt::Util qw(slurp write_file); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
95
|
|
|
6
|
2
|
|
|
2
|
|
1551
|
use ShipIt::ProjectType::Perl::MakeMaker; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
71
|
|
|
7
|
2
|
|
|
2
|
|
1376
|
use ShipIt::ProjectType::Perl::ModuleBuild; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
1964
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# factory when called directly. |
|
10
|
|
|
|
|
|
|
# returns undef if not a perl project, otherwise returns |
|
11
|
|
|
|
|
|
|
# ::MakeMaker or ::ModuleBuild instance. |
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
4
|
|
|
4
|
0
|
32
|
my ($class) = @_; |
|
14
|
4
|
100
|
|
|
|
15
|
if ($class eq "ShipIt::ProjectType::Perl") { |
|
15
|
2
|
50
|
|
|
|
24
|
return ShipIt::ProjectType::Perl::ModuleBuild->new if -e "Build.PL"; |
|
16
|
2
|
50
|
|
|
|
51
|
return ShipIt::ProjectType::Perl::MakeMaker->new if -e "Makefile.PL"; |
|
17
|
0
|
|
|
|
|
0
|
return undef; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
2
|
|
|
|
|
11
|
return bless {}, $class; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# fields: |
|
23
|
|
|
|
|
|
|
# version -- if defined, cached current version |
|
24
|
|
|
|
|
|
|
# ver_from -- if Makefile.PL says so, what file our $VERSION comes from |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub current_version { |
|
27
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
28
|
0
|
0
|
|
|
|
0
|
return $self->{version} if defined $self->{version}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
0
|
if (-e "Build.PL") { |
|
31
|
0
|
|
|
|
|
0
|
return $self->{version} = $self->current_version_from_buildpl; |
|
32
|
|
|
|
|
|
|
} else { |
|
33
|
0
|
|
|
|
|
0
|
return $self->{version} = $self->current_version_from_makefilepl; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub current_version_from_makefilepl { |
|
38
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
39
|
0
|
0
|
|
|
|
0
|
open (my $fh, "Makefile.PL") or die "Can't open Makefile.PL: $!\n"; |
|
40
|
0
|
|
|
|
|
0
|
while (<$fh>) { |
|
41
|
|
|
|
|
|
|
# MakeMaker |
|
42
|
0
|
0
|
|
|
|
0
|
if (/VERSION_FROM.+([\'\"])(.+?)\1/) { |
|
43
|
0
|
|
|
|
|
0
|
$self->{ver_from} = $2; |
|
44
|
0
|
|
|
|
|
0
|
last; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
# Module::Install |
|
47
|
0
|
0
|
|
|
|
0
|
if (/(?:(?:all|version)_from|reference_module)(?:\s*\(|\s+)([\'\"])(.+?)\1/) { |
|
48
|
0
|
|
|
|
|
0
|
$self->{ver_from} = $2; |
|
49
|
0
|
|
|
|
|
0
|
last; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
0
|
0
|
|
|
|
0
|
if (/\bVERSION\b.+([\'\"])(.+?)\1/) { |
|
52
|
0
|
|
|
|
|
0
|
return $2; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
0
|
|
|
|
|
0
|
close($fh); |
|
56
|
0
|
|
|
|
|
0
|
return $self->version_from_file; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub current_version_from_buildpl { |
|
60
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
61
|
0
|
0
|
|
|
|
0
|
open (my $fh, "Build.PL") or die "Can't open Build.PL: $!\n"; |
|
62
|
0
|
|
|
|
|
0
|
while (<$fh>) { |
|
63
|
0
|
0
|
|
|
|
0
|
if (/\bdist_version_from\b.+([\'\"])(.+?)\1/) { |
|
64
|
0
|
|
|
|
|
0
|
$self->{ver_from} = $2; |
|
65
|
0
|
|
|
|
|
0
|
last; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
0
|
|
|
|
0
|
if (/\bmodule_name\b.+([\'\"])(.+?)\1/) { |
|
68
|
0
|
|
|
|
|
0
|
$self->{ver_from} = $self->_module_to_file($2); |
|
69
|
|
|
|
|
|
|
# no last since we prefer dist_version_from |
|
70
|
|
|
|
|
|
|
} |
|
71
|
0
|
0
|
|
|
|
0
|
if (/\bdist_version\b.+([\'\"])(.+?)\1/) { |
|
72
|
0
|
|
|
|
|
0
|
return $2; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
0
|
|
|
|
|
0
|
close($fh); |
|
76
|
0
|
|
|
|
|
0
|
return $self->version_from_file; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _module_to_file { |
|
80
|
0
|
|
|
0
|
|
0
|
my ($self, $mod) = @_; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
my @parts = split /::/, $mod; |
|
83
|
0
|
|
|
|
|
0
|
$parts[-1] .= q{.pm}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
0
|
unshift @parts, 'lib' if -d 'lib'; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
return File::Spec->catfile(@parts); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _versioncode_from_string { |
|
91
|
114
|
|
|
114
|
|
6759
|
my ($self, $string) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
114
|
100
|
|
|
|
552
|
if ($string =~ / |
|
94
|
|
|
|
|
|
|
( |
|
95
|
|
|
|
|
|
|
( use \s* version \s* ; \s* )? |
|
96
|
|
|
|
|
|
|
(our)? \s* \$VER SION \s* = \s* # trick PAUSE from parsing this line |
|
97
|
|
|
|
|
|
|
( |
|
98
|
|
|
|
|
|
|
['"] v?[\d\.\_]+ ['"] |
|
99
|
|
|
|
|
|
|
| q{1,2}\( \s* v?[\d\.\_]+ \s* \) |
|
100
|
|
|
|
|
|
|
| [\d\.\_]+ |
|
101
|
|
|
|
|
|
|
| qv\( \s* ['"] v? [\d\.\_]+ ['"] \s* \) |
|
102
|
|
|
|
|
|
|
) |
|
103
|
|
|
|
|
|
|
) |
|
104
|
|
|
|
|
|
|
/xms) { |
|
105
|
39
|
|
|
|
|
155
|
return $1; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
75
|
|
|
|
|
551
|
return 0; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# returns $VERSION from a file, assuming $self->{ver_from} is already set |
|
112
|
|
|
|
|
|
|
sub version_from_file { |
|
113
|
21
|
|
|
21
|
0
|
4677
|
my $self = shift; |
|
114
|
21
|
50
|
|
|
|
68
|
my $file = $self->{ver_from} or die "no ver_from set"; |
|
115
|
21
|
50
|
|
|
|
859
|
open (my $fh, $file) or die "Failed to open $file: $!\n"; |
|
116
|
21
|
|
|
|
|
323
|
while (my $line = <$fh>) { |
|
117
|
93
|
100
|
|
|
|
191
|
if (my $versionpart = $self->_versioncode_from_string($line)) { |
|
118
|
21
|
|
|
|
|
25
|
eval { |
|
119
|
|
|
|
|
|
|
package __ShipIt_Temp_Package; |
|
120
|
2
|
|
|
2
|
|
14
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
893
|
|
|
121
|
1
|
|
|
1
|
|
1235
|
eval $versionpart; |
|
|
1
|
|
|
1
|
|
2637
|
|
|
|
1
|
|
|
1
|
|
7
|
|
|
|
1
|
|
|
1
|
|
7
|
|
|
|
1
|
|
|
1
|
|
2
|
|
|
|
1
|
|
|
1
|
|
6
|
|
|
|
1
|
|
|
1
|
|
6
|
|
|
|
1
|
|
|
1
|
|
2
|
|
|
|
1
|
|
|
1
|
|
6
|
|
|
|
1
|
|
|
1
|
|
7
|
|
|
|
1
|
|
|
1
|
|
2
|
|
|
|
1
|
|
|
1
|
|
6
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
329
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
303
|
|
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
|
21
|
|
|
|
|
1671
|
|
|
122
|
|
|
|
|
|
|
}; |
|
123
|
21
|
50
|
|
|
|
255
|
next if $@; |
|
124
|
21
|
|
|
|
|
571
|
return $__ShipIt_Temp_Package::VERSION; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
} |
|
127
|
0
|
|
|
|
|
0
|
die "No \$VERSION found in file $file\nMaybe, you forgot to quote \$VERSION?"; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub update_version { |
|
131
|
7
|
|
|
7
|
1
|
2619
|
my ($self, $newver) = @_; |
|
132
|
|
|
|
|
|
|
|
|
133
|
7
|
50
|
|
|
|
26
|
if (my $file = $self->{ver_from}) { |
|
134
|
7
|
|
|
|
|
34
|
my $contents = slurp($file); |
|
135
|
|
|
|
|
|
|
|
|
136
|
7
|
|
|
|
|
25
|
my $versionpart = $self->_versioncode_from_string($contents); |
|
137
|
7
|
|
|
|
|
13
|
my $newversionpart = $versionpart; |
|
138
|
7
|
|
|
|
|
15
|
my $version_withoutv = $self->{version}; |
|
139
|
7
|
|
|
|
|
49
|
$version_withoutv =~ s/^v//; |
|
140
|
7
|
|
|
|
|
195
|
$newversionpart =~ s/ v? $version_withoutv /$newver/xms; |
|
141
|
|
|
|
|
|
|
|
|
142
|
7
|
|
|
|
|
27
|
my ($x, $y) = (quotemeta($versionpart), $newversionpart); |
|
143
|
7
|
|
|
|
|
103
|
$contents =~ s/$x/$y/; |
|
144
|
7
|
|
|
|
|
30
|
write_file($file, $contents); |
|
145
|
|
|
|
|
|
|
|
|
146
|
7
|
|
|
|
|
28
|
return 1; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
if (-e "Makefile.PL") { |
|
150
|
0
|
|
|
|
|
|
my $file = "Makefile.PL"; |
|
151
|
0
|
|
|
|
|
|
my $contents = slurp($file); |
|
152
|
0
|
0
|
|
|
|
|
$contents =~ s/(\bVERSION\b.+)([\'\"])(.+?)\2/$1$2$newver$2/ |
|
153
|
|
|
|
|
|
|
or die "Failed to replace VERSION in MakeFile.PL\n"; |
|
154
|
0
|
|
|
|
|
|
write_file($file, $contents); |
|
155
|
0
|
|
|
|
|
|
return 1; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
die "perl update not done"; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |