File Coverage

blib/lib/Module/License/Report/Object.pm
Criterion Covered Total %
statement 9 33 27.2
branch 0 2 0.0
condition n/a
subroutine 3 14 21.4
pod 11 11 100.0
total 23 60 38.3


line stmt bran cond sub pod time code
1             package Module::License::Report::Object;
2              
3 1     1   6 use strict;
  1         2  
  1         260  
4 1     1   19 use warnings;
  1         2  
  1         47  
5 1     1   6 use overload q{""} => 'name';
  1         2  
  1         10  
6              
7             our $VERSION = '0.02';
8              
9             =head1 NAME
10              
11             Module::License::Report::Object - Encapsulation of license information
12              
13             =head1 LICENSE
14              
15             Copyright 2005 Clotho Advanced Media, Inc.,
16              
17             This library is free software; you can redistribute it and/or modify it
18             under the same terms as Perl itself.
19              
20             =head1 SYNOPSIS
21              
22             use Module::License::Report::Object;
23            
24             my $license = Module::License::Report::Object->new({...});
25             print $license; # 'perl'
26             print $license->source_file(); # 'META.yml'
27             print $license->confidence(); # '100'
28             print $license->package_version(); # '0.01'
29              
30             =head1 DESCRIPTION
31              
32             This module is intended for use with Module::License::Report. You
33             likely will never need to use the C method, but the others will
34             likely be useful.
35              
36             =head1 FUNCTIONS
37              
38             =over
39              
40             =item $pkg->new({...})
41              
42             Creates a new license instance. This is intended for internal use by
43             Module::License::Report::CPANPLUSModule.
44              
45             =cut
46              
47             sub new
48             {
49 0     0 1   my $pkg = shift;
50 0           my $params_hash = shift;
51              
52 0           return bless {%$params_hash}, $pkg;
53             }
54              
55             =item $license->name()
56              
57             Returns the name of the license. This name is of the form used by Module::Build.
58             See L for the full list.
59              
60             This method is called when C<$license> is used in string context.
61              
62             =cut
63              
64             sub name
65             {
66 0     0 1   my $self = shift;
67 0           return $self->{name};
68             }
69              
70             =item $license->confidence()
71              
72             Returns a confidence in the license as a number between 100 (high) and
73             0 (low). These confidences are subjective, and reflect how direct
74             the determination of the license was, versus how many heuristics were
75             used. For example, a license specified in C has a very high
76             confidence, while a string like C
77             itself> parsed from README is given lower confidence.
78              
79             =cut
80              
81             sub confidence
82             {
83 0     0 1   my $self = shift;
84 0           return $self->{confidence};
85             }
86              
87             =item $license->source_file()
88              
89             Returns the name of the file which specified the license, relative to
90             the distribution folder. This might be C if the license came
91             from the CPAN DSLIP parameter.
92              
93             For example: C, C, C.
94              
95             =cut
96              
97             sub source_file
98             {
99 0     0 1   my $self = shift;
100 0           return $self->{source_file};
101             }
102              
103             =item $license->source_filepath()
104              
105             Like C, but returns an absolute path.
106              
107             =cut
108              
109             sub source_filepath
110             {
111 0     0 1   my $self = shift;
112 0 0         return if (!defined $self->{source_file});
113 0           return File::Spec->catfile($self->{module}->extract_dir(), $self->{source_file});
114             }
115              
116             =item $license->source_name()
117              
118             Returns a machine-readable keyword that describes the source of the
119             license. If more than one source was used, they are comma-separated.
120             The list of keywords is: C, C, C, C,
121             and C.
122              
123             =cut
124              
125             sub source_name
126             {
127 0     0 1   my $self = shift;
128 0           return $self->{source_name};
129             }
130              
131             =item $license->source_description()
132              
133             Returns a human-readable version of C.
134              
135             =cut
136              
137             sub source_description
138             {
139 0     0 1   my $self = shift;
140 0           return $self->{source_desc};
141             }
142              
143             =item $license->module_name()
144              
145             Returns the name of the module that started the license search. So,
146             if the license of package Foo-Bar is C, this value could be any
147             of C, C, C, etc.
148              
149             =cut
150              
151             sub module_name
152             {
153 0     0 1   my $self = shift;
154 0           return $self->{module}->name();
155             }
156              
157             =item $license->package_name()
158              
159             Returns the CPAN package name for the distribution. For example,
160             C.
161              
162             =cut
163              
164             sub package_name
165             {
166 0     0 1   my $self = shift;
167 0           return $self->{module}->package_name();
168             }
169              
170             =item $license->package_version()
171              
172             Returns the version number of the CPAN package that was used to determine the license. For example,
173             C<0.12.03_01>.
174              
175             =cut
176              
177             sub package_version
178             {
179 0     0 1   my $self = shift;
180 0           return $self->{module}->package_version();
181             }
182              
183             =item $license->package_dir()
184              
185             Returns the directory name of the extracted distribution. This is
186             typically a subdirectory of C<.cpanplus> somewhere.
187              
188             =cut
189              
190             sub package_dir
191             {
192 0     0 1   my $self = shift;
193 0           return $self->{module}->extract_dir();
194             }
195              
196             1;
197             __END__