| 1 | ## no critic (ControlStructures::ProhibitPostfixControls) | ||||||||||||||||||||||||||||
| 2 | package Software::Policies::License; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # ABSTRACT: Create project policy file: License | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.006'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Module::Load qw( load ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # use Software::License; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||
| 19 | 0 | return bless {}, $class; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 0 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $class = $args{'class'} // 'Perl_5'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"class"} // "Perl_5"
MC/DC0%0/1
$args{"class"} // "Perl_5"
$args{"class"}
Truth table0%0/2
A
A= $args{"class"}
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my $version = $args{'version'} // '1'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"version"} // 1
MC/DC0%0/1
$args{"version"} // 1
$args{"version"}
Truth table0%0/2
A
A= $args{"version"}
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $format = $args{'format'} // 'text'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"format"} // "text"
MC/DC0%0/1
$args{"format"} // "text"
$args{"format"}
Truth table0%0/2
A
A= $args{"format"}
| |||||||||||||||||||||||||||||
| 27 | 0 | my %attributes; | |||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $attrs = $args{'attributes'} // {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"attributes"} // {}
MC/DC0%0/1
$args{"attributes"} // {}
$args{"attributes"}
Truth table0%0/2
A
A= $args{"attributes"}
| |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $attributes{'holder'} = $attrs->{'authors'}->[0] if $attrs->{'authors'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $attributes{'year'} = $attrs->{'year'} if $attrs->{'year'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | $attributes{'perl_5_double_license'} = $attrs->{'perl_5_double_license'} | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if $attrs->{'perl_5_double_license'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | croak q{Missing attribute 'holder'} | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ( !defined $attributes{'holder'} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | my $txt; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ( $class eq 'Perl_5' && $attributes{'perl_5_double_license'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class eq "Perl_5" and $attributes{"perl_5_double_license"}
MC/DC0%0/2
$class eq "Perl_5" and $attributes{"perl_5_double_license"}
$class eq "Perl_5"
$attributes{"perl_5_double_license"}
Truth table0%0/3
A and B
A= $class eq "Perl_5"B= $attributes{"perl_5_double_license"}
| |||||||||||||||||||||||||||||
| 38 | 0 | load 'Software::License::GPL_3'; # filename: LICENSE-GPL-3 | |||||||||||||||||||||||||||
| 39 | 0 | load 'Software::License::Artistic_2_0'; # filename: LICENSE-Artistic-2.0 | |||||||||||||||||||||||||||
| 40 | return { | ||||||||||||||||||||||||||||
| 41 | 0 | policy => __PACKAGE__ =~ m/.*::([[:word:]]{1,})$/msx, | |||||||||||||||||||||||||||
| 42 | class => 'GPL', | ||||||||||||||||||||||||||||
| 43 | version => 1, | ||||||||||||||||||||||||||||
| 44 | text => Software::License::GPL_3->new( \%attributes )->license, | ||||||||||||||||||||||||||||
| 45 | filename => 'LICENSE-GPL-3', | ||||||||||||||||||||||||||||
| 46 | format => 'text', | ||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | policy => __PACKAGE__ =~ m/.*::([[:word:]]{1,})$/msx, | ||||||||||||||||||||||||||||
| 50 | class => 'Artistic', | ||||||||||||||||||||||||||||
| 51 | version => '1.0', | ||||||||||||||||||||||||||||
| 52 | text => Software::License::Artistic_2_0->new( \%attributes )->license, | ||||||||||||||||||||||||||||
| 53 | filename => 'LICENSE-Artistic-2.0', | ||||||||||||||||||||||||||||
| 54 | format => 'text', | ||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | else { | ||||||||||||||||||||||||||||
| 58 | 0 | my $module = 'Software::License::' . $class; | |||||||||||||||||||||||||||
| 59 | 0 | load $module; | |||||||||||||||||||||||||||
| 60 | 0 | $txt = $module->new( \%attributes ); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | return { | ||||||||||||||||||||||||||||
| 63 | 0 | policy => __PACKAGE__ =~ m/.*::([[:word:]]{1,})$/msx, | |||||||||||||||||||||||||||
| 64 | class => $class, | ||||||||||||||||||||||||||||
| 65 | version => $version, | ||||||||||||||||||||||||||||
| 66 | text => $txt->license, | ||||||||||||||||||||||||||||
| 67 | filename => _filename($format), | ||||||||||||||||||||||||||||
| 68 | format => $format, | ||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | ▶ | sub get_available_classes_and_versions { | ||||||||||||||||||||||||||
|
Subroutine
get_available_classes_and_versions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | return { | ||||||||||||||||||||||||||||
| 74 | 1 | 'Perl_5' => { | |||||||||||||||||||||||||||
| 75 | versions => { | ||||||||||||||||||||||||||||
| 76 | '1' => 1, | ||||||||||||||||||||||||||||
| 77 | }, | ||||||||||||||||||||||||||||
| 78 | formats => { | ||||||||||||||||||||||||||||
| 79 | 'text' => 1, | ||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||
| 81 | }, | ||||||||||||||||||||||||||||
| 82 | }; | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub _filename { | ||||||||||||||||||||||||||
|
Subroutine
_filename: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 86 | 0 | my ($format) = @_; | |||||||||||||||||||||||||||
| 87 | 0 | my %formats = ( 'text' => 'LICENSE', ); | |||||||||||||||||||||||||||
| 88 | 0 | return $formats{$format}; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 2 | 1; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||