File Coverage

blib/lib/Software/Policies/CodeOfConduct/ContributorCovenant.pm
Criterion Covered Total %
statement 14 32 43.7
branch 0 8 0.0
condition 0 6 0.0
subroutine 5 9 55.5
pod 3 3 100.0
total 22 58 37.9


line stmt bran cond sub pod time code
1             ## no critic (ControlStructures::ProhibitPostfixControls)
2             package Software::Policies::CodeOfConduct::ContributorCovenant;
3              
4 1     1   3354 use strict;
  1         3  
  1         45  
5 1     1   7 use warnings;
  1         2  
  1         64  
6 1     1   20 use 5.010;
  1         38  
7              
8             # ABSTRACT: Create a policy file: Code of Conduct / Contributor Covenant
9              
10             our $VERSION = '0.002';
11              
12 1     1   8 use Carp;
  1         1  
  1         122  
13 1     1   696 use Software::Policy::CodeOfConduct;
  1         567271  
  1         545  
14              
15             sub new {
16 0     0 1   my ($class) = @_;
17 0           return bless {}, $class;
18             }
19              
20             sub create {
21 0     0 1   my ( $self, %args ) = @_;
22 0   0       my $version = $args{'version'} // '1.4';
23 0   0       my $format = $args{'format'} // 'markdown';
24 0           my %attributes;
25 0   0       my $attrs = $args{'attributes'} // {};
26 0           $attributes{'policy'} = 'Contributor_Covenant_' . $version;
27 0 0         $attributes{'name'} = $attrs->{'name'} if $attrs->{'name'};
28 0 0         $attributes{'contact'} = $attrs->{'authors'}->[0] if $attrs->{'authors'};
29 0 0         croak q{Missing attribute 'name'} if ( !defined $attributes{'name'} );
30 0 0         croak q{Missing attribute 'contact'} if ( !defined $attributes{'contact'} );
31              
32 0           my $p = Software::Policy::CodeOfConduct->new(
33              
34             # policy => 'Contributor_Covenant_1.4',
35             # name => 'Foo',
36             # contact => 'team-foo@example.com',
37             # filename => 'CODE_OF_CONDUCT.md',
38             %attributes,
39             );
40              
41             return (
42 0           policy => 'CodeOfConduct',
43             class => 'ContributorCovenant',
44             version => $version,
45             text => $p->fulltext . "\n",
46             filename => _filename($format),
47             format => $format,
48             );
49             }
50              
51             sub get_available_classes_and_versions {
52             return {
53 0     0 1   'ContributorCovenant' => {
54             versions => {
55             '1.4' => 1,
56             '2.0' => 1,
57             '2.1' => 1,
58             },
59             formats => {
60             'markdown' => 1,
61             },
62             },
63             };
64             }
65              
66             sub _filename {
67 0     0     my ($format) = @_;
68 0           my %formats = ( 'markdown' => 'CODE_OF_CONDUCT.md', );
69 0           return $formats{$format};
70             }
71             1;
72              
73             __END__