| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of Software-LicenseMoreUtils |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This software is copyright (c) 2018, 2022 by Dominique Dumont. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
package Software::LicenseMoreUtils::LicenseWithSummary; |
|
10
|
|
|
|
|
|
|
$Software::LicenseMoreUtils::LicenseWithSummary::VERSION = '1.009'; |
|
11
|
|
|
|
|
|
|
# ABSTRACT: Software::License with a summary |
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
69
|
|
|
14
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
84
|
|
|
15
|
3
|
|
|
3
|
|
27
|
use 5.10.1; |
|
|
3
|
|
|
|
|
9
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
1319
|
use Path::Tiny; |
|
|
3
|
|
|
|
|
18797
|
|
|
|
3
|
|
|
|
|
131
|
|
|
18
|
3
|
|
|
3
|
|
1319
|
use YAML::Tiny; |
|
|
3
|
|
|
|
|
14000
|
|
|
|
3
|
|
|
|
|
167
|
|
|
19
|
3
|
|
|
3
|
|
22
|
use List::Util qw/first/; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
208
|
|
|
20
|
3
|
|
|
3
|
|
17
|
use Carp; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
112
|
|
|
21
|
3
|
|
|
3
|
|
1785
|
use Text::Template; |
|
|
3
|
|
|
|
|
8968
|
|
|
|
3
|
|
|
|
|
1613
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# map location of distro file (like /etc/redhat_release) to distro. |
|
26
|
|
|
|
|
|
|
# must match a _summaries.yml file in the directory containing |
|
27
|
|
|
|
|
|
|
# this Perl module file |
|
28
|
|
|
|
|
|
|
my %path_to_distro = ( |
|
29
|
|
|
|
|
|
|
'/etc/debian_version' => 'debian', |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $distro_file = first { -e $_ } keys %path_to_distro; |
|
33
|
|
|
|
|
|
|
my $distro = $path_to_distro{$distro_file // ''} || 'unknown'; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
(my $module_file = __PACKAGE__.'.pm' ) =~ s!::!/!g; |
|
36
|
|
|
|
|
|
|
my $yml_file = path($INC{$module_file})->parent->child("$distro-summaries.yml") ; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $summaries = {} ; |
|
39
|
|
|
|
|
|
|
if ($yml_file->is_file) { |
|
40
|
|
|
|
|
|
|
$summaries = YAML::Tiny->read($yml_file)->[0]; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
|
44
|
52
|
|
|
52
|
0
|
110
|
my ($class, $args) = @_; |
|
45
|
|
|
|
|
|
|
my $self = { |
|
46
|
|
|
|
|
|
|
license => $args->{license}, |
|
47
|
|
|
|
|
|
|
or_later => $args->{or_later}, |
|
48
|
|
|
|
|
|
|
holder => $args->{holder}, |
|
49
|
52
|
|
|
|
|
134
|
}; |
|
50
|
|
|
|
|
|
|
|
|
51
|
52
|
|
|
|
|
111
|
return bless $self, $class; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
20
|
|
|
20
|
1
|
6852
|
sub distribution { return $distro } |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub summary { |
|
57
|
48
|
|
|
48
|
1
|
62435
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
48
|
100
|
|
|
|
114
|
my $later_text = $self->{or_later} ? ", or (at\nyour option) any later version" : ''; |
|
60
|
|
|
|
|
|
|
|
|
61
|
48
|
|
|
|
|
242
|
(my $section_name = ref( $self->{license} )) =~ s/.*:://; |
|
62
|
48
|
|
100
|
|
|
215
|
my $summary = $summaries->{$section_name} // ''; |
|
63
|
|
|
|
|
|
|
|
|
64
|
48
|
|
|
|
|
176
|
my $template = Text::Template->new( |
|
65
|
|
|
|
|
|
|
TYPE => 'STRING', |
|
66
|
|
|
|
|
|
|
DELIMITERS => [ qw({{ }}) ], |
|
67
|
|
|
|
|
|
|
SOURCE => $summary |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
|
|
70
|
48
|
|
|
|
|
4951
|
return $template->fill_in( |
|
71
|
|
|
|
|
|
|
HASH => { or_later_clause => $later_text }, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub license_class { |
|
76
|
29
|
|
|
29
|
1
|
103
|
my $self = shift; |
|
77
|
29
|
|
|
|
|
87
|
return ref($self->{license}); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub debian_text { |
|
81
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
82
|
0
|
|
|
|
|
0
|
carp "debian_text is deprecated, please use summary_or_text"; |
|
83
|
0
|
|
|
|
|
0
|
return $self->summary_or_text; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub summary_or_text { |
|
87
|
18
|
|
|
18
|
1
|
68
|
my ($self) = @_; |
|
88
|
18
|
|
|
|
|
32
|
my $text; |
|
89
|
18
|
100
|
100
|
|
|
33
|
if (length $self->summary and $self->{holder}) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
90
|
7
|
|
|
|
|
2972
|
$text = join("\n", grep { $_ } ($self->notice, $self->summary)); |
|
|
14
|
|
|
|
|
2747
|
|
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
elsif (length $self->summary) { |
|
93
|
5
|
|
|
|
|
1921
|
$text = $self->summary; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
elsif ($self->{holder}) { |
|
96
|
4
|
|
|
|
|
1277
|
$text = $self->fulltext; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
else { |
|
99
|
2
|
|
|
|
|
464
|
$text = $self->license; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
18
|
|
|
|
|
41159
|
return $text; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
105
|
66
|
|
|
66
|
|
25552
|
my ($self, @args) = @_; |
|
106
|
66
|
|
|
|
|
116
|
my $lic = $self->{license}; |
|
107
|
66
|
|
|
|
|
463
|
my ($sub) = ($AUTOLOAD =~ /(\w+)$/); |
|
108
|
66
|
100
|
66
|
|
|
354
|
if ($lic and $sub ne 'DESTROY') { |
|
109
|
14
|
|
|
|
|
63
|
return $lic->$sub(@args); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
else { |
|
112
|
52
|
|
|
|
|
395
|
return; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |