File Coverage

blib/lib/Software/Policies/Security/Individual.pm
Criterion Covered Total %
statement 14 40 35.0
branch 0 26 0.0
condition 0 6 0.0
subroutine 5 9 55.5
pod 2 3 66.6
total 21 84 25.0


line stmt bran cond sub pod time code
1             ## no critic (ControlStructures::ProhibitPostfixControls)
2             package Software::Policies::Security::Individual;
3              
4 1     1   3140 use strict;
  1         3  
  1         44  
5 1     1   6 use warnings;
  1         2  
  1         60  
6 1     1   17 use 5.010;
  1         4  
7              
8             # ABSTRACT: Create project policy file: Security / Individual
9              
10             our $VERSION = '0.002';
11              
12 1     1   7 use Carp;
  1         2  
  1         84  
13              
14 1     1   755 use Software::Security::Policy::Individual 0.11;
  1         33962  
  1         643  
15              
16             sub new {
17 0     0 1   my ($class) = @_;
18 0           return bless {}, $class;
19             }
20              
21             sub create {
22 0     0 1   my ( $self, %args ) = @_;
23 0   0       my $version = $args{'version'} // '1';
24 0   0       my $format = $args{'format'} // 'markdown';
25              
26 0           my %attributes;
27 0   0       my $attrs = $args{'attributes'} // {};
28 0 0         $attributes{'maintainer'} = $attrs->{'authors'}->[0] if $attrs->{'authors'};
29 0 0         $attributes{'timeframe'} = $attrs->{'timeframe'} if $attrs->{'timeframe'};
30 0 0         $attributes{'timeframe_quantity'} = $attrs->{'timeframe_quantity'} if $attrs->{'timeframe_quantity'};
31 0 0         $attributes{'timeframe_units'} = $attrs->{'timeframe_units'} if $attrs->{'timeframe_units'};
32 0 0         $attributes{'url'} = $attrs->{'url'} if $attrs->{'url'};
33 0 0         $attributes{'git_url'} = $attrs->{'git_url'} if $attrs->{'git_url'};
34 0 0         $attributes{'report_url'} = $attrs->{'report_url'} if $attrs->{'report_url'};
35 0 0         $attributes{'perl_support_years'} = $attrs->{'perl_support_years'} if $attrs->{'perl_support_years'};
36 0 0         $attributes{'program'} = $attrs->{'name'} if $attrs->{'name'};
37 0 0         $attributes{'program'} = $attrs->{'program'} if $attrs->{'program'};
38 0 0         $attributes{'Program'} = $attrs->{'Program'} if $attrs->{'Program'};
39 0 0         $attributes{'minimum_perl_version'} = $attrs->{'minimum_perl_version'} if $attrs->{'minimum_perl_version'};
40             croak q{Missing option 'maintainer'}
41 0 0         if ( !defined $attributes{'maintainer'} );
42 0           my $p = Software::Security::Policy::Individual->new( \%attributes );
43             return (
44 0           policy => 'Contributing',
45             class => 'PerlDistZilla',
46             version => $version,
47             text => $p->fulltext,
48             filename => _filename($format),
49             format => $format,
50             );
51             }
52              
53             sub get_available_classes_and_versions {
54             return {
55 0     0 0   'Individual' => {
56             versions => {
57             '1' => 1,
58             },
59             formats => {
60             'markdown' => 1,
61             'text' => 1,
62             },
63             },
64             };
65             }
66              
67             sub _filename {
68 0     0     my ($format) = @_;
69 0           my %formats = ( 'markdown' => 'SECURITY.md', );
70 0           return $formats{$format};
71             }
72              
73             1;
74              
75             __END__