File Coverage

blib/lib/Dist/Zilla/PluginBundle/BerryGenomics.pm
Criterion Covered Total %
statement 9 24 37.5
branch 0 2 0.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 12 31 38.7


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::BerryGenomics;
2 2     2   3579 use Moose;
  2         979885  
  2         14  
3 2     2   14023 use Sub::Install;
  2         5  
  2         18  
4 2     2   2008 use namespace::autoclean;
  2         17072  
  2         10  
5              
6             our $VERSION = '0.3.2'; # VERSION
7             # ABSTRACT: Dist::Zilla::PluginBundle for BerryGenomics Bioinformatics Department
8              
9              
10             with 'Dist::Zilla::Role::PluginBundle::Easy';
11             has installer => (
12             is => 'ro',
13             isa => 'Str',
14             lazy => 1,
15             default => sub { $_[0]->payload->{installer} || 'ModuleBuild' },
16             );
17              
18             has exclude_message => (
19             is => 'ro',
20             isa => 'Str',
21             lazy => 1,
22             default =>
23             sub { $_[0]->payload->{exclude_message} || '^(Auto|Merge|forgot|typo)' }
24             );
25              
26             has max_age => (
27             is => 'ro',
28             isa => 'Int',
29             lazy => 1,
30             default => sub {
31             $_[0]->payload->{max_age} || 60;
32             }
33             );
34              
35             has changelog_filename => (
36             is => 'ro',
37             isa => 'Str',
38             lazy => 1,
39             default => sub {
40             $_[0]->payload->{changelog_filename} || 'Changes';
41             }
42             );
43              
44             has allow_dirty => (
45             is => 'ro',
46             isa => 'ArrayRef',
47             lazy => 1,
48             default => sub {
49             my $payload = $_[0]->payload->{allow_dirty};
50             if (! $payload) {
51             []
52             } elsif (ref $payload eq 'ARRAY') {
53             $payload
54             } else {
55             [ $payload ]
56             }
57             }
58             );
59              
60             has commit_msg => (
61             is => 'ro',
62             isa => 'Str',
63             lazy => 1,
64             default => sub {
65             $_[0]->payload->{commit_msg} || 'Auto commited by dzil with version %v at %d%n%n%c%n';
66             }
67             );
68              
69             has first_version => (
70             is => 'ro',
71             isa => 'Str',
72             lazy => 1,
73             default => sub {
74             $_[0]->payload->{first_version} || '0.1.0';
75             }
76             );
77              
78             has release_branch => (
79             is => 'ro',
80             isa => 'Str',
81             lazy => 1,
82             default => sub {
83             $_[0]->payload->{release_branch} || 'release/%b';
84             }
85             );
86              
87             has release_message => (
88             is => 'ro',
89             isa => 'Str',
90             lazy => 1,
91             default => sub {
92             $_[0]->payload->{release_message} || 'Release %v of %h (on %b)';
93             }
94             );
95              
96             has version_regexp => (
97             is => 'ro',
98             isa => 'Str',
99             lazy => 1,
100             default => sub {
101             $_[0]->payload->{version_regexp} || '^v?(\d+\.\d+\.\d+)';
102             }
103             );
104              
105             has changelog_wrap => (
106             is => 'ro',
107             isa => 'Int',
108             lazy => 1,
109             default => sub {
110             $_[0]->payload->{changelog_wrap} || '120';
111             }
112             );
113              
114             has skipped_release_count => (
115             is => 'ro',
116             isa => 'Int',
117             default => sub {
118             $_[0]->payload->{skipped_release_count} || 2;
119             }
120             );
121              
122             has debug => (
123             is => 'ro',
124             isa => 'Int',
125             lazy => 1,
126             default => sub {
127             $_[0]->payload->{debug} || 0;
128             }
129             );
130              
131              
132             sub configure {
133 0     0 0   my $self = shift;
134              
135             # Firstly, import plugins from @Basic bundle;
136 0           $self->add_plugins(
137             qw(MetaJSON MetaYAML License ExtraTests ExecDir ShareDir Manifest ManifestSkip)
138             );
139              
140             # Secondly, plugin FakeRelease;
141 0           $self->add_plugins(qw(TestRelease FakeRelease));
142              
143             # 3. add installer prereqs
144 0           my @installer_accepts =
145             qw( MakeMaker MakeMaker::IncShareDir ModuleBuild ModuleBuildTiny );
146 0           my %accepts = map { $_ => 1 } @installer_accepts;
  0            
147 0 0         unless ($accepts{$self->installer}) {
148 0           die sprintf(
149             "Unknown installer: '%s'. "
150             . "Acceptable values are MakeMaker, ModuleBuild and ModuleBuildTiny\n",
151             $self->installer
152             );
153             }
154 0           $self->add_plugins($self->installer);
155              
156             # 4. some helper plugins
157 0           $self->add_plugins(qw(InstallGuide OurPkgVersion PodWeaver));
158 0           $self->add_plugins(
159              
160             # 5. Readme.md
161             [ 'ReadmeAnyFromPod',
162             {type => 'markdown', filename => 'README.md', location => 'build'}
163             ],
164             [ 'ReadmeAnyFromPod',
165             'MarkdownInRoot',
166             { type => 'markdown',
167             filename => 'README.md',
168             location => 'root',
169             phase => 'release'
170             }
171             ],
172             ['CopyFilesFromBuild', {copy => ['LICENSE', $self->changelog_filename]}],
173             ['MetaNoIndex', {directory => [qw(t xt inc share)]}],
174             );
175              
176 0           my @dirty_files = ('Changes', 'README.md', 'LICENSE', @{$self->allow_dirty});
  0            
177              
178             # 6. Git
179 0           $self->add_plugins(
180             [ 'Git::GatherDir',
181             {exclude_filename => \@dirty_files, include_dotfiles => 1}
182             ],
183             ['Git::Check', {allow_dirty => \@dirty_files, untracked_files => 'warn'}],
184             [ 'Git::Commit',
185             { allow_dirty => \@dirty_files,
186             commit_msg => $self->commit_msg
187             }
188             ],
189             [ 'Git::CommitBuild',
190             { release_branch => $self->release_branch,
191             release_message => $self->release_message,
192             }
193             ],
194             [ 'Git::Tag',
195             {tag_format => '%v', tag_message => 'Release %v'}
196             ],
197             ['Git::Push', {remotes_must_exist => 0}],
198             [ 'Git::NextVersion',
199             { first_version => $self->first_version,
200             version_by_branch => 1,
201             version_regexp => $self->version_regexp,
202             }
203             ],
204             [ 'ChangelogFromGit',
205             { tag_regexp => $self->version_regexp,
206             max_age => $self->max_age,
207             exclude_message => $self->exclude_message,
208             debug => $self->debug,
209             skipped_release_count => $self->skipped_release_count,
210             wrap_column => $self->changelog_wrap,
211             file_name => $self->changelog_filename,
212             }
213             ],
214             );
215 0           $self->add_plugins(['AutoPrereqs']);
216             }
217             __PACKAGE__->meta->make_immutable;
218              
219             1;
220              
221             __END__
222              
223             =pod
224              
225             =encoding UTF-8
226              
227             =head1 NAME
228              
229             Dist::Zilla::PluginBundle::BerryGenomics - Dist::Zilla::PluginBundle for BerryGenomics Bioinformatics Department
230              
231             =head1 VERSION
232              
233             version 0.3.2
234              
235             =head1 SYNOPSIS
236              
237             in your I<dist.ini>:
238              
239             [@BerryGenomics]
240              
241             Details configration:
242              
243             [@BerryGenomics]
244             installer = MakeMaker ; default is ModuleBuild
245             ; valid installers: MakeMaker MakeMaker::IncShareDir ModuleBuild ModuleBuildTiny
246              
247             ; ChangelogFromGit
248             changelog_filename = Changes ; file_name in ChangelogFromGit
249             changelog_wrap = 74 ; wrap_column in ChangelogFromGit, default 120
250             exclude_message = ^(Auto|Merge|Forgot)
251             version_regexp = ^v?(\d+\.\d+\.\d+)
252             skipped_release_count = 2
253             max_age = 365 ; default 60
254             debug = 0
255              
256             ; Git
257             allow_dirty = 'FIle1'
258             allow_dirty = 'File2'
259             commit_msg =
260             release_branch =
261             release_message =
262              
263             =head1 DESCRIPTION
264              
265             This is plugin bundle is for BerryGenomics.
266             It is equivalent to:
267              
268             ; Basic
269             [MetaJSON]
270             [MetaYAML]
271             [License]
272             [ExtraTests]
273             [ExecDir]
274             [ShareDir]
275             [Manifest]
276             [ManifestSkip]
277              
278             [TestRelease]
279             [FakeRelease]
280              
281             ; installer
282             [ModuleBuild] ; by default
283              
284             ; extra
285             [InstallGuide]
286             [OurPkgVersion]
287             [PodWeaver]
288             [ReadmeFromPod]
289             [PodSyntaxTests]
290              
291             ; with params
292             [ReadmeAnyFromPod /MarkdownInRoot]
293             filename = Readme.md
294             [CopyFilesFromBuild]
295             copy = LICENSE
296             [MetaNoIndex]
297             directory = t
298             directory = xt
299             directory = inc
300             directory = share
301             directory = eg
302             directory = examples
303              
304             ; Git
305             [Git::GatherDir]
306             exclude_filename = dist.ini
307             exclude_filename = Changes
308             exclude_filename = README.md
309             exclude_filename = LICENSE
310             include_dotfiles = 1
311             [Git::Check]
312             allow_dirty = dist.ini
313             allow_dirty = Changes
314             allow_dirty = README.md
315             allow_dirty = LICENSE
316             untracked_files = warn
317             [Git::Commit]
318             allow_dirty = dist.ini
319             allow_dirty = Changes
320             allow_dirty = README.md
321             allow_dirty = LICENSE
322             commit_msg = Auto commited by dzil with version %v at %d%n%n%c%n
323             [Git::CommitBuild]
324             release_branch = %v
325             release_message = Release %v of %h (on %b)
326             [Git::Tag]
327             tag_format = %v
328             tag_message = Auto tagged by dzil release(%v)
329             [Git::Push]
330             remotes_must_exist = 0
331             [Git::NextVersion]
332             first_version = 0.0.1
333             version_by_branch = 1
334             version_regexp = ^v?(\d+(\.\d+){0,2})$
335             [ChangelogFromGit::CPAN::Changes]
336             tag_regexp = semantic
337             group_by_author = 1
338              
339             ; run
340             [Run::BeforeBuild]
341             run = git checkout Changes
342             [Run::BeforeRelease]
343             run = mkdir -p release 2>/dev/null; cp %n-%v.tar.gz release/ -f
344              
345             [AutoPrereqs]
346              
347             =head1 AUTHOR
348              
349             Huo Linhe <huolinhe@berrygenomics.com>
350              
351             =head1 COPYRIGHT AND LICENSE
352              
353             This software is copyright (c) 2015 by Berry Genomics.
354              
355             This is free software; you can redistribute it and/or modify it under
356             the same terms as the Perl 5 programming language system itself.
357              
358             =cut