1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
Description: Add debian_text method
This method returns the license summary (if available)
or the full license text.
Author: dod
--- a/lib/Software/License.pm
+++ b/lib/Software/License.pm
@@ -87,6 +87,18 @@
$self->_fill_in(uc($distro).'-SUMMARY');
}
+sub debian_text {
+ my ($self,$distro) = @_;
+ $distro ||= 'debian' ;
+
+ my $summary_tag = uc($distro).'-SUMMARY';
+ my $fill_in_tag
+ = $self->section_data($summary_tag) ? $summary_tag
+ : 'LICENSE' ;
+
+ $self->_fill_in($fill_in_tag);
+}
+
#pod =method license
#pod
#pod This method returns the full text of the license.
@@ -284,6 +296,11 @@
containing the whole license will be in C</usr/share/common-licenses/>
directory. (Available only on Debian)
+=head2 debian_text
+
+This method returns a summary of the license (if available) or the full text
+of the license (Available only on Debian)
+
=head2 license
This method returns the full text of the license.
--- /dev/null
+++ b/t/debian-text.t
@@ -0,0 +1,29 @@
+#!perl
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+# try LGP2 license
+
+my $class = 'Software::LicenseUtils';
+require_ok($class);
+
+{
+ my $license = $class->new_from_short_name({
+ short_name => 'LGPL-2',
+ holder => 'X. Ample'
+ });
+
+ like($license->debian_text, qr/common-licenses/i, 'summary found');
+
+}
+{
+ my $license = $class->new_from_short_name({
+ short_name => 'Expat',
+ holder => 'X. Ample'
+ });
+
+ like($license->debian_text, qr/substantial/i, 'license text found');
+
+}
|