line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Provision::TraitFor::UpdatingContent; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
633
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
83
|
use Class::Usul::Constants qw( EXCEPTION_CLASS OK ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
636
|
use Class::Usul::Functions qw( throw ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
1046
|
use Unexpected::Functions qw( Unspecified ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
366
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires qw( appldir loc manifest_paths next_argv output ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Private methods |
13
|
|
|
|
|
|
|
my $_get_ignore_rev_regex = sub { |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $ignore_rev = $self->appldir->catfile( '.gitignore-rev' )->chomp; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return $ignore_rev->exists ? join '|', $ignore_rev->getlines : undef; |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $_get_update_args = sub { |
22
|
|
|
|
|
|
|
return ($_[ 0 ]->next_argv, $_[ 0 ]->next_argv); |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Public methods |
26
|
|
|
|
|
|
|
sub substitute_version { |
27
|
0
|
|
|
0
|
1
|
|
my ($self, $path, $from, $to) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$path->substitute( "\Q\'${from}.%d\',\E", "\'${to}.%d\'," ); |
30
|
0
|
|
|
|
|
|
$path->substitute( "\Q v${from}.\$Rev\E", " v${to}.\$Rev" ); |
31
|
0
|
|
|
|
|
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub update_copyright_year : method { |
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; my ($from, $to) = $self->$_get_update_args; |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $prefix = $self->loc( 'Copyright (c)' ); |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
$from or throw Unspecified, [ 'from' ]; |
40
|
0
|
0
|
|
|
|
|
$to or throw Unspecified, [ 'to' ]; |
41
|
0
|
0
|
|
|
|
|
$self->quiet or $self->output( 'Updating copyright year' ); |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
for my $path (@{ $self->manifest_paths }) { |
|
0
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$path->substitute( "\Q${prefix} ${from}\E", "${prefix} ${to}" ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return OK; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub update_version : method { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; my ($from, $to) = $self->$_get_update_args; |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $ignore = $self->$_get_ignore_rev_regex; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
$self->quiet or $self->output( 'Updating version numbers' ); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
($from, $to) = $self->update_version_pre_hook( $from, $to ); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
for my $path (@{ $self->manifest_paths }) { |
|
0
|
|
|
|
|
|
|
60
|
0
|
0
|
0
|
|
|
|
$ignore and $path =~ m{ (?: $ignore ) }mx and next; |
61
|
0
|
|
|
|
|
|
$self->substitute_version( $path, $from, $to ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$self->update_version_post_hook( $from, $to ); |
65
|
0
|
|
|
|
|
|
return OK; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
0
|
1
|
|
sub update_version_post_hook { # Can be modified by applied traits |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub update_version_pre_hook { # Can be modified by applied traits |
72
|
0
|
|
|
0
|
1
|
|
my ($self, @args) = @_; |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
|
($args[ 0 ] and $args[ 1 ]) or throw 'Insufficient arguments'; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return @args; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding utf8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 Name |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Module::Provision::TraitFor::UpdatingContent - Perform search and replace on project file content |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 Synopsis |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
use Moose; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
extends 'Module::Provision::Base'; |
96
|
|
|
|
|
|
|
with 'Module::Provision::TraitFor::UpdatingContent'; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 Description |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Perform search and replace on project file content |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 Configuration and Environment |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Requires the following attributes to be defined in the consuming |
105
|
|
|
|
|
|
|
class; C<appldir> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Defines no attributes |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 Subroutines/Methods |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 substitute_version |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$self->substitute_version( $path, $from, $to ); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Substitutes the C<$to> string everywhere the C<$from> pattern occurs |
116
|
|
|
|
|
|
|
in the C<$path> file. The C<$path> argument should be of type |
117
|
|
|
|
|
|
|
L<File::DataClass::IO> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 update_copyright_year - Updates the copyright year in the POD |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$exit_code = $self->update_copyright_year; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Substitutes the existing copyright year for the new copyright year in all |
124
|
|
|
|
|
|
|
files in the F<MANIFEST> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 update_version - Updates the version numbers in all files |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$exit_code = $self->update_version; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Substitutes the existing version number for the new version number in all |
131
|
|
|
|
|
|
|
files in the F<MANIFEST> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 update_version_pre_hook |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$self->update_version_pre_hook; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns it's input args by default. Can be modified by applied traits |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 update_version_post_hook |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$self->update_version_post_hook; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Does nothing by default. Can be modified by applied traits |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 Diagnostics |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
None |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 Dependencies |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over 3 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item L<Class::Usul> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item L<Moose::Role> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 Incompatibilities |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
There are no known incompatibilities in this module |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 Bugs and Limitations |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
There are no known bugs in this module. |
166
|
|
|
|
|
|
|
Please report problems to the address below. |
167
|
|
|
|
|
|
|
Patches are welcome |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 Acknowledgements |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Larry Wall - For the Perl programming language |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 Author |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Peter Flanigan, C<< <pjfl@cpan.org> >> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 License and Copyright |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright (c) 2017 Peter Flanigan. All rights reserved |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
182
|
|
|
|
|
|
|
under the same terms as Perl itself. See L<perlartistic> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
185
|
|
|
|
|
|
|
but WITHOUT WARRANTY; without even the implied warranty of |
186
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# Local Variables: |
191
|
|
|
|
|
|
|
# mode: perl |
192
|
|
|
|
|
|
|
# tab-width: 3 |
193
|
|
|
|
|
|
|
# End: |