line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jenkins::i18n::License; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
99726
|
use 5.014004; |
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
11
|
use Carp qw(confess); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
7
|
1
|
|
|
1
|
|
6
|
use File::Path qw(make_path); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
8
|
1
|
|
|
1
|
|
524
|
use DateTime::Tiny; |
|
1
|
|
|
|
|
1123
|
|
|
1
|
|
|
|
|
29
|
|
9
|
1
|
|
|
1
|
|
535
|
use Hash::Util qw(lock_keys); |
|
1
|
|
|
|
|
3002
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=pod |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Jenkins::i18n::License |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Jenkins::i18n::License; |
20
|
|
|
|
|
|
|
my $license = Jenkins::i18n::License->new; |
21
|
|
|
|
|
|
|
$license->print_license($some_file); |
22
|
|
|
|
|
|
|
my $data_ref = $license->read_license; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This class handles all license requirements for new translation files created. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
It is intended to be used to provide the license text on new properties files. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Creates a new instance of the class and return it. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Doesn't expect any parameter. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
45
|
1
|
|
|
1
|
1
|
120
|
my $class = shift; |
46
|
1
|
|
|
|
|
12
|
my $now = DateTime::Tiny->now; |
47
|
1
|
|
|
|
|
88
|
my $self = { |
48
|
|
|
|
|
|
|
current_year => $now->year, |
49
|
|
|
|
|
|
|
content => undef |
50
|
|
|
|
|
|
|
}; |
51
|
1
|
|
|
|
|
42
|
bless $self, $class; |
52
|
1
|
|
|
|
|
2
|
lock_keys( %{$self} ); |
|
1
|
|
|
|
|
7
|
|
53
|
1
|
|
|
|
|
23
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 print |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Print the license text to a file. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Expects as parameters: |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item 1 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
the complete path to the file |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=back |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub print { |
73
|
2
|
|
|
2
|
1
|
3888
|
my ( $self, $file ) = @_; |
74
|
2
|
100
|
|
|
|
24
|
confess 'The complete path to the file parameter is required' |
75
|
|
|
|
|
|
|
unless ($file); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# only dirs part is desired |
78
|
1
|
|
|
|
|
21
|
my $dirs = ( File::Spec->splitpath($file) )[1]; |
79
|
1
|
50
|
|
|
|
447
|
make_path($dirs) unless ( -d $dirs ); |
80
|
1
|
50
|
|
|
|
88
|
open( my $out, '>', $file ) or confess "Cannot write to $file: $!\n"; |
81
|
1
|
|
|
|
|
6
|
my $data_ref = $self->read; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
3
|
foreach my $line ( @{$data_ref} ) { |
|
1
|
|
|
|
|
3
|
|
84
|
22
|
|
|
|
|
53
|
print $out "#$line"; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
64
|
close($out); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 read |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the license, as an array reference. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The license itself will include a line referencing the translators, which will |
95
|
|
|
|
|
|
|
include the current year. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub read { |
100
|
2
|
|
|
2
|
1
|
9
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
2
|
100
|
|
|
|
7
|
unless ( $self->{content} ) { |
103
|
1
|
|
|
|
|
24
|
my @license = ; |
104
|
1
|
|
|
|
|
4
|
my $additional_license_index = 4; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# right after the copyright line |
107
|
1
|
50
|
|
|
|
5
|
confess |
108
|
|
|
|
|
|
|
"Unexpected license content, expected only a new line at 4 index" |
109
|
|
|
|
|
|
|
unless ( $license[$additional_license_index] eq "\n" ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$license[$additional_license_index] |
112
|
|
|
|
|
|
|
= ' Copyright (c) ' # a space in the beginning is required |
113
|
1
|
|
|
|
|
6
|
. $self->{current_year} . "- Jenkins contributors.\n"; |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
4
|
$self->{content} = \@license; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
18
|
return $self->{content}; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, Earfreitas@cpan.orgE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This software is copyright (c) 2022 of Alceu Rodrigues de Freitas Junior, |
128
|
|
|
|
|
|
|
Earfreitas@cpan.orgE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This file is part of Jenkins Translation Tool project. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Jenkins Translation Tool is free software: you can redistribute it and/or |
133
|
|
|
|
|
|
|
modify it under the terms of the GNU General Public License as published by the |
134
|
|
|
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your option) |
135
|
|
|
|
|
|
|
any later version. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Jenkins Translation Tool is distributed in the hope that it will be useful, but |
138
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
139
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
140
|
|
|
|
|
|
|
details. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
143
|
|
|
|
|
|
|
Jenkins Translation Tool. If not, see (http://www.gnu.org/licenses/). |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
The original C script was licensed through the MIT |
146
|
|
|
|
|
|
|
License, copyright (c) 2004, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a |
147
|
|
|
|
|
|
|
number of other of contributors. Translations files generated by the Jenkins |
148
|
|
|
|
|
|
|
Translation Tool CLI are distributed with the same MIT License. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__DATA__ |