| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Software::Policy::CodeOfConduct; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: generate a Code of Conduct policy |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
405713
|
use v5.20; |
|
|
1
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
751
|
use Moo; |
|
|
1
|
|
|
|
|
11465
|
|
|
|
1
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1997
|
use File::ShareDir qw( dist_file ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
116
|
|
|
10
|
1
|
|
|
1
|
|
10
|
use Path::Tiny 0.018 qw( cwd path ); |
|
|
1
|
|
|
|
|
26
|
|
|
|
1
|
|
|
|
|
71
|
|
|
11
|
1
|
|
|
1
|
|
837
|
use Text::Template 1.48; |
|
|
1
|
|
|
|
|
6164
|
|
|
|
1
|
|
|
|
|
72
|
|
|
12
|
1
|
|
|
1
|
|
580
|
use Text::Wrap qw( wrap $columns ); |
|
|
1
|
|
|
|
|
4876
|
|
|
|
1
|
|
|
|
|
176
|
|
|
13
|
1
|
|
|
1
|
|
571
|
use Types::Common qw( InstanceOf Maybe NonEmptyStr NonEmptySimpleStr PositiveOrZeroInt ); |
|
|
1
|
|
|
|
|
336506
|
|
|
|
1
|
|
|
|
|
11
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6167
|
use experimental qw( lexical_subs signatures ); |
|
|
1
|
|
|
|
|
5730
|
|
|
|
1
|
|
|
|
|
13
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
874
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
23711
|
|
|
|
1
|
|
|
|
|
6
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = 'v0.5.0'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has policy => ( |
|
23
|
|
|
|
|
|
|
is => 'ro', |
|
24
|
|
|
|
|
|
|
default => 'Contributor_Covenant_1.4', |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has name => ( |
|
29
|
|
|
|
|
|
|
is => 'ro', |
|
30
|
|
|
|
|
|
|
isa => Maybe [NonEmptySimpleStr], |
|
31
|
|
|
|
|
|
|
default => sub { return undef }, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has contact => ( |
|
36
|
|
|
|
|
|
|
is => 'ro', |
|
37
|
|
|
|
|
|
|
required => 1, |
|
38
|
|
|
|
|
|
|
isa => NonEmptySimpleStr, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has entity => ( |
|
43
|
|
|
|
|
|
|
is => 'ro', |
|
44
|
|
|
|
|
|
|
isa => NonEmptySimpleStr, |
|
45
|
|
|
|
|
|
|
default => 'project', |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
8
|
has Entity => ( |
|
50
|
|
|
|
|
|
|
is => 'lazy', |
|
51
|
|
|
|
|
|
|
isa => NonEmptySimpleStr, |
|
52
|
3
|
|
|
3
|
|
5194
|
builder => sub($self) { |
|
|
3
|
|
|
|
|
4
|
|
|
53
|
3
|
|
|
|
|
51
|
return ucfirst( $self->entity ); |
|
54
|
|
|
|
|
|
|
}, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
31
|
has template_path => ( |
|
59
|
|
|
|
|
|
|
is => 'lazy', |
|
60
|
|
|
|
|
|
|
isa => InstanceOf ['Path::Tiny'], |
|
61
|
|
|
|
|
|
|
coerce => \&path, |
|
62
|
3
|
|
|
3
|
|
1516
|
builder => sub($self) { |
|
|
3
|
|
|
|
|
4
|
|
|
63
|
3
|
|
|
|
|
36
|
return path( dist_file( __PACKAGE__ =~ s/::/-/gr , $self->policy . ".md.tmpl" ) ); |
|
64
|
|
|
|
|
|
|
}, |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
5
|
has _template => ( |
|
68
|
|
|
|
|
|
|
is => 'lazy', |
|
69
|
|
|
|
|
|
|
isa => InstanceOf ['Text::Template'], |
|
70
|
|
|
|
|
|
|
init_arg => undef, |
|
71
|
3
|
|
|
3
|
|
27
|
builder => sub($self) { |
|
|
3
|
|
|
|
|
5
|
|
|
72
|
3
|
|
|
|
|
43
|
return Text::Template->new( |
|
73
|
|
|
|
|
|
|
TYPE => "FILE", |
|
74
|
|
|
|
|
|
|
SOURCE => $self->template_path, |
|
75
|
|
|
|
|
|
|
); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
has text_columns => ( |
|
82
|
|
|
|
|
|
|
is => 'ro', |
|
83
|
|
|
|
|
|
|
isa => PositiveOrZeroInt, |
|
84
|
|
|
|
|
|
|
default => 78, |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
has fulltext => ( |
|
89
|
|
|
|
|
|
|
is => 'lazy', |
|
90
|
|
|
|
|
|
|
isa => NonEmptyStr, |
|
91
|
|
|
|
|
|
|
init_arg => undef, |
|
92
|
|
|
|
|
|
|
builder => sub($self) { |
|
93
|
|
|
|
|
|
|
state $c = 1; |
|
94
|
|
|
|
|
|
|
my $pkg = __PACKAGE__ . "::Run_" . $c++; |
|
95
|
0
|
|
|
|
|
0
|
my $raw = $self->_template->fill_in( |
|
96
|
|
|
|
|
|
|
PACKAGE => $pkg, |
|
97
|
|
|
|
|
|
|
STRICT => 1, |
|
98
|
0
|
|
|
0
|
|
0
|
BROKEN => sub(%args) { die $args{error} }, |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
99
|
|
|
|
|
|
|
HASH => { |
|
100
|
|
|
|
|
|
|
name => $self->name // "", |
|
101
|
|
|
|
|
|
|
contact => $self->contact, |
|
102
|
|
|
|
|
|
|
entity => $self->entity, |
|
103
|
|
|
|
|
|
|
Entity => $self->Entity, |
|
104
|
|
|
|
|
|
|
}, |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$columns = $self->text_columns; |
|
108
|
|
|
|
|
|
|
my sub _wrap($line) { |
|
109
|
|
|
|
|
|
|
return $line unless $columns; |
|
110
|
|
|
|
|
|
|
return $line if $line =~ /^[ ]{4}/; # ignore preformatted code |
|
111
|
|
|
|
|
|
|
return wrap( "", $line =~ /^[\*\-](?![\*\-]) ?/ ? " " : "", $line =~ s/[ ][ ]+/ /gr ); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my @lines = map { _wrap($_) } split /\n/, $raw; |
|
115
|
|
|
|
|
|
|
return join( "\n", @lines ); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
*text = \&fulltext; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
has filename => ( |
|
124
|
|
|
|
|
|
|
is => 'ro', |
|
125
|
|
|
|
|
|
|
isa => NonEmptySimpleStr, |
|
126
|
|
|
|
|
|
|
coerce => sub($name) { return path($name)->basename }, |
|
127
|
|
|
|
|
|
|
default => 'CODE_OF_CONDUCT.md', |
|
128
|
|
|
|
|
|
|
); |
|
129
|
|
|
|
|
|
|
|
|
130
|
3
|
|
|
3
|
1
|
7231
|
sub save($self, $dir = undef) { |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
5
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
3
|
|
33
|
|
|
15
|
my $path = path( $dir // cwd, $self->filename ); |
|
134
|
3
|
|
|
|
|
195
|
$path->spew_raw( $self->fulltext ); |
|
135
|
3
|
|
|
|
|
3700
|
return $path; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |