blib/lib/Dist/Zilla/Plugin/ContributorCovenant.pm

filter: Statementstmt 86.8% 33 / 38 Branchbran 25.0% 2 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 4 totaltotal 75.8% 47 / 62 CC 8 SCAR 18.8
CC
8
Cov
77%
prune_files
14.8
__ANON__
3.0
BEGIN
1.0
CRAP 6.5
↑ Summary
1 package Dist::Zilla::Plugin::ContributorCovenant;
2 1 $Dist::Zilla::Plugin::ContributorCovenant::VERSION = '2.000000';
3 =head1 NAME
4  
5 Dist::Zilla::Plugin::ContributorCovenant - Add Contributor Covenant as Code of Conduct
6  
7 =head1 DESCRIPTION
8  
9 C<Dist::Zilla::Plugin::ContributorCovenant> adds the Contributor
10 Covenant to your CPAN build as C<CODE_OF_CONDUCT.md>. It pulls
11 email address of first author from C<dist.ini>. If none found,
12 it will type "GitHub / RT" instead.
13  
14 =head1 SYNOPSIS
15  
16 Add this one line to your dist.ini.
17  
18 [ContributorCovenant]
19  
20 If you want to leave a copy of Code Of Conduct in code repository,
21 You can add following lines to your dist.ini as well.
22  
23 [CopyFilesFromBuild]
24 copy = CODE_OF_CONDUCT.md
25  
26 Note that this plugin will prune other CODE_OF_CONDUCT.md files, to
27 avoid multiple CODE_OF_CONDUCT.md preventing the build.
28  
29 The version of this module will match the version of the Contributor
30 Covenant used. For instance, version 1.004001 will use Contributor
31 Covenant version 1.4.1.
32  
33 =cut
34  
35 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use Dist::Zilla::File::InMemory;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 1 with qw/
42 Dist::Zilla::Role::Plugin
43 Dist::Zilla::Role::FileGatherer
44 Dist::Zilla::Role::FilePruner
45 Dist::Zilla::Role::TextTemplate
46 Dist::Zilla::Role::MetaProvider
47 /;
48  
49 2 ▶sub metadata {
Subroutine metadata: called CC=1 SCAR=0.0
Pod undocumented
50 2 return { 'x_contributor_covenant' => { 'version' => 0.02 } };
51 }
52  
53 1 has '+zilla' => (
54 handles => { authors => 'authors' },
55 );
56  
57 has contributor_covenant => (
58 is => 'ro',
59 lazy => 1,
60 2 ▶ default => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
61 2 my $self = shift;
62 2 my ($author, $email);
63  
64 2 $author = $self->authors->[0];
65 2 ▶ ($email) = $author =~ /<(.*)>/ if $author;
Branch: 1 branch
BranchTrueFalseTotal
if $author 2 0 2
66 2 ▶ my $contact = $email || 'GitHub / RT';
Condition100%2/2
$email || 'GitHub / RT'
l!l
11
MC/DC100%1/1
$email || 'GitHub / RT'
$email
Truth table100%2/2
A
A= $email
Aresult
11
00
67  
68 2 $self->fill_in_string(contributor_covenant_template(),{
69 contact => $contact,
70 });
71 },
72 1 );
73  
74 2 ▶sub gather_files {
Subroutine gather_files: called CC=1 SCAR=0.0
Pod undocumented
75 2 my $self = shift;
76 2 $self->add_file(
77 Dist::Zilla::File::InMemory->new({
78 content => $self->contributor_covenant,
79 name => 'CODE_OF_CONDUCT.md',
80 })
81 );
82 }
83  
84 2 ▶sub prune_files {
Subroutine prune_files: called CC=6 SCAR=26.9
Pod undocumented
85 2 my $self = shift;
86  
87 2 my @coc_files = grep {$_->name eq 'CODE_OF_CONDUCT.md'} @{$self->zilla->files};
88 2 ▶ return unless scalar @coc_files > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @coc_files > 1 2 0 2
89  
90 # We will keep COC file produced by this plugin
91 0 foreach my $file (@coc_files){
92 0 my $keep = 0;
93 0 foreach my $source ($file->added_by){
94 0 ▶ $keep = 1 if $source =~ 'Dist::Zilla::Plugin::ContributorCovenant';
Branch: 1 branch
BranchTrueFalseTotal
if $source =~ /Dist::Zilla::Plugin::ContributorCovenant/ 0 0 0
95 }
96 0 ▶ $self->zilla->prune_file($file) unless $keep;
Branch: 1 branch
BranchTrueFalseTotal
unless $keep 0 0 0
97 }
98  
99 }
100  
101 2 ▶sub contributor_covenant_template {
Subroutine contributor_covenant_template: called CC=1 SCAR=0.0
Pod undocumented
102 2 return <<'END_TEMPLATE';
103 # Contributor Covenant Code of Conduct
104  
105 ## Our Pledge
106  
107 We as members, contributors, and leaders pledge to make participation in our
108 community a harassment-free experience for everyone, regardless of age, body
109 size, visible or invisible disability, ethnicity, sex characteristics, gender
110 identity and expression, level of experience, education, socio-economic status,
111 nationality, personal appearance, race, religion, or sexual identity
112 and orientation.
113  
114 We pledge to act and interact in ways that contribute to an open, welcoming,
115 diverse, inclusive, and healthy community.
116  
117 ## Our Standards
118  
119 Examples of behavior that contributes to a positive environment for our
120 community include:
121  
122 * Demonstrating empathy and kindness toward other people
123 * Being respectful of differing opinions, viewpoints, and experiences
124 * Giving and gracefully accepting constructive feedback
125 * Accepting responsibility and apologizing to those affected by our mistakes,
126 and learning from the experience
127 * Focusing on what is best not just for us as individuals, but for the
128 overall community
129  
130 Examples of unacceptable behavior include:
131  
132 * The use of sexualized language or imagery, and sexual attention or
133 advances of any kind
134 * Trolling, insulting or derogatory comments, and personal or political attacks
135 * Public or private harassment
136 * Publishing others' private information, such as a physical or email
137 address, without their explicit permission
138 * Other conduct which could reasonably be considered inappropriate in a
139 professional setting
140  
141 ## Enforcement Responsibilities
142  
143 Community leaders are responsible for clarifying and enforcing our standards of
144 acceptable behavior and will take appropriate and fair corrective action in
145 response to any behavior that they deem inappropriate, threatening, offensive,
146 or harmful.
147  
148 Community leaders have the right and responsibility to remove, edit, or reject
149 comments, commits, code, wiki edits, issues, and other contributions that are
150 not aligned to this Code of Conduct, and will communicate reasons for moderation
151 decisions when appropriate.
152  
153 ## Scope
154  
155 This Code of Conduct applies within all community spaces, and also applies when
156 an individual is officially representing the community in public spaces.
157 Examples of representing our community include using an official e-mail address,
158 posting via an official social media account, or acting as an appointed
159 representative at an online or offline event.
160  
161 ## Enforcement
162  
163 Instances of abusive, harassing, or otherwise unacceptable behavior may be
164 reported to the community leaders responsible for enforcement at
165 {{ $contact }}.
166 All complaints will be reviewed and investigated promptly and fairly.
167  
168 All community leaders are obligated to respect the privacy and security of the
169 reporter of any incident.
170  
171 ## Enforcement Guidelines
172  
173 Community leaders will follow these Community Impact Guidelines in determining
174 the consequences for any action they deem in violation of this Code of Conduct:
175  
176 ### 1. Correction
177  
178 **Community Impact**: Use of inappropriate language or other behavior deemed
179 unprofessional or unwelcome in the community.
180  
181 **Consequence**: A private, written warning from community leaders, providing
182 clarity around the nature of the violation and an explanation of why the
183 behavior was inappropriate. A public apology may be requested.
184  
185 ### 2. Warning
186  
187 **Community Impact**: A violation through a single incident or series
188 of actions.
189  
190 **Consequence**: A warning with consequences for continued behavior. No
191 interaction with the people involved, including unsolicited interaction with
192 those enforcing the Code of Conduct, for a specified period of time. This
193 includes avoiding interactions in community spaces as well as external channels
194 like social media. Violating these terms may lead to a temporary or
195 permanent ban.
196  
197 ### 3. Temporary Ban
198  
199 **Community Impact**: A serious violation of community standards, including
200 sustained inappropriate behavior.
201  
202 **Consequence**: A temporary ban from any sort of interaction or public
203 communication with the community for a specified period of time. No public or
204 private interaction with the people involved, including unsolicited interaction
205 with those enforcing the Code of Conduct, is allowed during this period.
206 Violating these terms may lead to a permanent ban.
207  
208 ### 4. Permanent Ban
209  
210 **Community Impact**: Demonstrating a pattern of violation of community
211 standards, including sustained inappropriate behavior, harassment of an
212 individual, or aggression toward or disparagement of classes of individuals.
213  
214 **Consequence**: A permanent ban from any sort of public interaction within
215 the community.
216  
217 ## Attribution
218  
219 This Code of Conduct is adapted from the [Contributor Covenant][homepage],
220 version 2.0, available at
221 https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
222  
223 Community Impact Guidelines were inspired by [Mozilla's code of conduct
224 enforcement ladder](https://github.com/mozilla/diversity).
225  
226 [homepage]: https://www.contributor-covenant.org
227  
228 For answers to common questions about this code of conduct, see the FAQ at
229 https://www.contributor-covenant.org/faq. Translations are available at
230 https://www.contributor-covenant.org/translations.
231 END_TEMPLATE
232 }
233  
234 1 __PACKAGE__->meta->make_immutable;
235  
236 1 1;
237  
238 __END__
↑ Summary