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

filter: Statementstmt 95.8% 46 / 48 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 2 totaltotal 90.3% 56 / 62 CC 4 SCAR 5.3
CC
4
Cov
94%
__ANON__
3.0
gather_files
2.0
__ANON__
2.0
CRAP 1.7
« blib/lib/Dist/Zilla/App/Tester.pm ↑ Summary blib/lib/Dist/Zilla/File/InMemory.pm »
1 package Dist::Zilla::Plugin::DistINI 6.040;
2 # ABSTRACT: a plugin to add a dist.ini to newly-minted dists
3  
4 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 with qw(Dist::Zilla::Role::FileGatherer);
6  
7 2 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Dist::Zilla::File::FromCode;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use MooseX::Types::Moose qw(ArrayRef Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Dist::Zilla::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 #pod =head1 DESCRIPTION
17 #pod
18 #pod This plugins produces a F<dist.ini> file in a new dist, specifying the required
19 #pod core attributes from the dist being minted.
20 #pod
21 #pod This plugin is dead simple and pretty stupid, but should get better as dist
22 #pod minting facilities improve. For example, it will not specify any plugins.
23 #pod
24 #pod In the meantime, you may be happier with a F<dist.ini> template.
25 #pod
26 #pod =attr append_file
27 #pod
28 #pod This parameter may be a filename in the profile's directory to append to the
29 #pod generated F<dist.ini> with things like plugins. In other words, if your make
30 #pod this file, called F<plugins.ini>:
31 #pod
32 #pod [@Basic]
33 #pod [NextRelease]
34 #pod [@Git]
35 #pod
36 #pod ...and your F<profile.ini> includes:
37 #pod
38 #pod [DistINI]
39 #pod append_file = plugins.ini
40 #pod
41 #pod ...then the generated C<dist.ini> in a newly-minted dist will look something
42 #pod like this:
43 #pod
44 #pod name = My-New-Dist
45 #pod author = E. Xavier Ample <example@example.com>
46 #pod license = Perl_5
47 #pod copyright_holder = E. Xavier Ample
48 #pod copyright_year = 2010
49 #pod
50 #pod [@Basic]
51 #pod [NextRelease]
52 #pod [@Git]
53 #pod
54 #pod =cut
55  
56 2 ▶sub mvp_multivalue_args { qw(append_file) }
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
57  
58 has append_file => (
59 is => 'ro',
60 isa => ArrayRef[ Str ],
61 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 2 );
63  
64 1 ▶sub gather_files {
Subroutine gather_files: called CC=2 SCAR=6.9
Pod undocumented
65 1 my ($self, $arg) = @_;
66  
67 1 my $zilla = $self->zilla;
68  
69 1 my $postlude = '';
70  
71 1 for (@{ $self->append_file }) {
72 1 my $fn = $self->zilla->root->child($_);
73  
74 1 $postlude .= path($fn)->slurp_utf8;
75 }
76  
77 1 ▶ my $code = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
78 1 my @core_attrs = qw(name authors copyright_holder);
79  
80 1 my $license = ref $zilla->license;
81 1 ▶ if ($license =~ /^Software::License::(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($license =~ /^Software::License::(.+)$/u) { } 1 0 1
82 1 $license = $1;
83 } else {
84 0 $license = "=$license";
85 }
86  
87 1 my $content = '';
88 1 $content .= sprintf "name = %s\n", $zilla->name;
89 1 $content .= sprintf "author = %s\n", $_ for @{ $zilla->authors };
90 1 $content .= sprintf "license = %s\n", $license;
91 1 $content .= sprintf "copyright_holder = %s\n", $zilla->copyright_holder;
92 1 $content .= sprintf "copyright_year = %s\n", (localtime)[5] + 1900;
93 1 $content .= "\n";
94  
95 1 $content .= $postlude;
96 1 };
97  
98 1 my $file = Dist::Zilla::File::FromCode->new({
99 name => 'dist.ini',
100 code => $code,
101 });
102  
103 1 $self->add_file($file);
104 }
105  
106 2 __PACKAGE__->meta->make_immutable;
107 2 1;
108  
109 __END__
« blib/lib/Dist/Zilla/App/Tester.pm ↑ Summary blib/lib/Dist/Zilla/File/InMemory.pm »