Dist/Zilla/PluginBundle/Author/RWSTAUNER/Minter.pm

filter: Statementstmt 100% 53 / 53 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 4 totaltotal 89.0% 73 / 82 CC 5 SCAR 3.7
CC
5
Cov
95%
__ANON__
2.5
configure
2.0
__ANON__
2.0
CRAP 1.5
« Pod/Weaver/PluginBundle/Author/RWSTAUNER.pm ↑ Summary Dist/Zilla/MintingProfile/Author/RWSTAUNER.pm »
1 # vim: set ts=2 sts=2 sw=2 expandtab smarttab:
2 #
3 # This file is part of Dist-Zilla-PluginBundle-Author-RWSTAUNER
4 #
5 # This software is copyright (c) 2010 by Randy Stauner.
6 #
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 #
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package Dist::Zilla::PluginBundle::Author::RWSTAUNER::Minter;
14 2 our $AUTHORITY = 'cpan:RWSTAUNER';
15 # ABSTRACT: RWSTAUNER's Dist::Zilla config for minting
16 2 $Dist::Zilla::PluginBundle::Author::RWSTAUNER::Minter::VERSION = '6.002';
17 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use MooseX::AttributeShortcuts;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Git::Wrapper;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Data::Section -setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 with qw(
23 Dist::Zilla::Role::PluginBundle::Easy
24 );
25  
26 has pause_id => (
27 is => 'ro',
28 1 ▶ default => sub { ((ref($_[0]) || $_[0]) =~ /Author::([A-Z]+)/)[0] },
Subroutine __ANON__: called CC=2 SCAR=9.2
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
100
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
29 2 );
30  
31 has _git => (
32 is => 'lazy',
33 1 ▶ default => sub { Git::Wrapper->new('.') },
Subroutine __ANON__: called CC=1 SCAR=0.0
34 2 );
35  
36 3 ▶sub git_config {
Subroutine git_config: called CC=1 SCAR=0.0
Pod undocumented
37 3 my ($self, $key) = @_;
38 3 return ($self->_git->config($key))[0];
39 }
40  
41 2 foreach my $attr ( qw( name email ) ){
42 has "git_$attr" => (
43 is => 'lazy',
44 2 ▶ default => sub { $_[0]->git_config("user.$attr") },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 4 );
46 }
47  
48 has github_user => (
49 is => 'lazy',
50 1 ▶ default => sub { $_[0]->git_config("github.user") },
Subroutine __ANON__: called CC=1 SCAR=0.0
51 2 );
52  
53 1 ▶around bundle_config => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
54 1 my ($orig, $self, @args) = @_;
55 1 my @plugins = $self->$orig(@args);
56  
57 # remove bundle prefix since dzil looks this one up by name
58 1 $_->[0] =~ s/.+?\/(:DefaultModuleMaker)/$1/ for @plugins;
59  
60 1 return @plugins;
61 2 };
62  
63 1 ▶sub configure {
Subroutine configure: called CC=2 SCAR=7.0
Pod undocumented
64 1 my ($self) = @_;
65  
66 1 ▶ $self->add_plugins(
Branch: 1 branch
BranchTrueFalseTotal
$self->github_user ? : 1 0 1
67 [ TemplateModule => ':DefaultModuleMaker', { template => 'Module.template' } ],
68  
69 [
70 'Git::Init' => $self->github_user ? {
71 remote => 'origin git@github.com:' . $self->github_user . '/%N.git',
72 config => [
73 'branch.master.remote origin',
74 'branch.master.merge refs/heads/master',
75 ],
76 } : {}
77 ],
78  
79 #'GitHub::Create',
80  
81 [
82 'Run::AfterMint' => {
83 run => [
84 # create the t/ directory so that it's already there
85 # when i try to create a file beneath
86 '%x -e "mkdir(shift(@ARGV))" %d%pt',
87 ],
88 },
89 ],
90 );
91  
92 1 $self->generate_files( $self->merged_section_data );
93 1 $self->generate_mailmap;
94 }
95  
96 2 ▶sub generate_files {
Subroutine generate_files: called CC=2 SCAR=6.9
Pod undocumented
97 2 my ($self, $files) = @_;
98 2 ▶ while( my ($name, $content) = each %$files ){
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 6 2 8
99 6 $content = $$content;
100 # GenerateFile will append a new line
101 6 $content =~ s/\n+\z//;
102 6 $self->add_plugins(
103 [
104 GenerateFile => "Generate-$name" => {
105 filename => $name,
106 is_template => 1,
107 content => $content,
108 }
109 ],
110 );
111 }
112 }
113  
114 1 ▶sub generate_mailmap {
Subroutine generate_mailmap: called CC=1 SCAR=0.0
Pod undocumented
115 1 my ($self) = @_;
116 1 $self->generate_files({
117 '.mailmap' => \sprintf '%s <%s@cpan.org> <%s>',
118 $self->git_name, lc($self->pause_id), $self->git_email,
119 });
120 }
121  
122 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
123 2 __PACKAGE__->meta->make_immutable;
124 2 1;
125  
126 =pod
127  
128 =encoding UTF-8
129  
130 =for :stopwords Randy Stauner ACKNOWLEDGEMENTS RWSTAUNER's PluginBundle
131  
132 =head1 NAME
133  
134 Dist::Zilla::PluginBundle::Author::RWSTAUNER::Minter - RWSTAUNER's Dist::Zilla config for minting
135  
136 =head1 VERSION
137  
138 version 6.002
139  
140 =head1 SYNOPSIS
141  
142 ; profile.ini
143  
144 [@Author::RWSTAUNER::Minter]
145  
146 =head1 DESCRIPTION
147  
148 Configure L<Dist::Zilla> to mint a new dist.
149  
150 =for Pod::Coverage configure
151 git_config
152 generate_files
153 generate_mailmap
154  
155 =head1 ROUGHLY EQUIVALENT
156  
157 This bundle is roughly equivalent to the following (generated) F<profile.ini>:
158  
159 [TemplateModule / :DefaultModuleMaker]
160 template = Module.template
161  
162 [Git::Init]
163 config = branch.master.remote origin
164 config = branch.master.merge refs/heads/master
165 remote = origin git@github.com:rwstauner/%N.git
166  
167 [Run::AfterMint]
168 run = %x -e "mkdir(shift(@ARGV))" %d%pt
169  
170 [GenerateFile / Generate-Changes]
171 content = Revision history for {{$dist->name}}
172 content = {{ '{{$NEXT}}' }}
173 content = - Initial release
174 filename = Changes
175 is_template = 1
176  
177 [GenerateFile / Generate-README.mkdn]
178 content = # NAME
179 content = {{ (my $n = $dist->name) =~ s/-/::/g; $n }} - undef
180 content = # COPYRIGHT AND LICENSE
181 content = This software is copyright (c) {{ (localtime)[5]+1900 }} by {{ $dist->copyright_holder }}.
182 content = This is free software; you can redistribute it and/or modify it under
183 content = the same terms as the Perl 5 programming language system itself.
184 filename = README.mkdn
185 is_template = 1
186  
187 [GenerateFile / Generate-.gitignore]
188 content = /{{$dist->name}}*
189 content = /.build
190 content = /cover_db/
191 content = /nytprof*
192 content = /tags
193 filename = .gitignore
194 is_template = 1
195  
196 [GenerateFile / Generate-dist.ini]
197 content = {{
198 content = $license = ref $dist->license;
199 content = if ( $license =~ /^Software::License::(.+)$/ ) {
200 content = $license = $1;
201 content = } else {
202 content = $license = "=$license";
203 content = }
204 content = $authors = join( "\n", map { "author = $_" } @{ $dist->authors } );
205 content = $copyright_year = (localtime)[5] + 1900;
206 content = '';
207 content = }}name = {{ $dist->name }}
208 content = {{ $authors }}
209 content = license = {{ $license }}
210 content = copyright_holder = {{ join( ', ', map { (/^(.+) <.+>/)[0] }@{ $dist->authors } ) }}
211 content = copyright_year = {{ $copyright_year }}
212 content = [@Author::RWSTAUNER]
213 filename = dist.ini
214 is_template = 1
215  
216 [GenerateFile / Generate-LICENSE]
217 content = This is free software; you can redistribute it and/or modify it under
218 content = the same terms as the Perl 5 programming language system itself.
219 filename = LICENSE
220 is_template = 1
221  
222 [GenerateFile / Generate-.mailmap]
223 content = Randy Stauner <rwstauner@cpan.org> <randy@magnificent-tears.com>
224 filename = .mailmap
225 is_template = 1
226  
227 =head1 SEE ALSO
228  
229 =over 4
230  
231 =item *
232  
233 L<Dist::Zilla::MintingProfile::Author::RWSTAUNER>
234  
235 =item *
236  
237 L<Dist::Zilla::Role::PluginBundle::Easy>
238  
239 =back
240  
241 =head1 AUTHOR
242  
243 Randy Stauner <rwstauner@cpan.org>
244  
245 =head1 COPYRIGHT AND LICENSE
246  
247 This software is copyright (c) 2010 by Randy Stauner.
248  
249 This is free software; you can redistribute it and/or modify it under
250 the same terms as the Perl 5 programming language system itself.
251  
252 =cut
253  
254 __DATA__
« Pod/Weaver/PluginBundle/Author/RWSTAUNER.pm ↑ Summary Dist/Zilla/MintingProfile/Author/RWSTAUNER.pm »