File Coverage

lib/Module/New/License.pm
Criterion Covered Total %
statement 30 30 100.0
branch 6 10 60.0
condition 5 9 55.5
subroutine 9 9 100.0
pod n/a
total 50 58 86.2


line stmt bran cond sub pod time code
1             package Module::New::License;
2            
3 7     7   14364 use strict;
  7         10  
  7         237  
4 7     7   27 use warnings;
  7         10  
  7         157  
5 7     7   23 use Carp;
  7         7  
  7         372  
6 7     7   421 use Sub::Install 'reinstall_sub';
  7         1125  
  7         37  
7 7     7   3220 use Module::Find;
  7         6079  
  7         933  
8            
9             my %LICENSES;
10            
11             sub _install_dsl {
12 7     7   11 my $class = shift;
13            
14 7 50       20 return if $class eq 'main';
15 7 50       18 return if $class =~ /^Test::/;
16            
17             reinstall_sub({
18             as => 'object',
19             into => $class,
20             code => sub {
21 22     22   2181 my ($self, $type, $args) = @_;
22            
23 22 100       260 croak "unknown license type: $type" unless $LICENSES{$type};
24 21         173 $LICENSES{$type}->new($args);
25             }
26 7         47 });
27             }
28            
29 7     7   20 BEGIN { _install_dsl(__PACKAGE__); }
30            
31             sub import {
32 16     16   40 my ($class, $flag) = @_;
33            
34 16 50 33     63 _install_dsl(caller) if $flag && $flag eq 'base';
35            
36 16         57 for my $module (sort {$b cmp $a} usesub 'Software::License') {
  1616         336425  
37 448 50       3055 next unless $module->can('meta_name');
38 448   66     1091 $LICENSES{$module->meta_name} ||= $module;
39 448   66     1892 $LICENSES{$module->meta2_name} ||= $module;
40             }
41             }
42            
43             1;
44            
45             __END__