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

filter: Statementstmt 50.0% 16 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 22.2% 2 / 9 Podpod 0.0% 0 / 2 totaltotal 41.8% 18 / 43 CC 2 SCAR 9.6
CC
2
Cov
50%
after_build
6.0
__ANON__
2.0
__ANON__
2.0
CRAP 2.6
↑ Summary
1 package Dist::Zilla::Plugin::InlineModule;
2 1 our $VERSION = '0.07';
3  
4 1 ▶use Inline::Module();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
8 1 with qw(Dist::Zilla::Role::AfterBuild Dist::Zilla::Role::FileGatherer);
9  
10 1 has module => (
11 is => 'ro',
12 isa => 'ArrayRef[Str]',
13 traits => ['Array'],
14 required => 1,
15 );
16  
17 1 has stub => (
18 is => 'ro',
19 lazy => 1,
20 builder => '_build_stub',
21 isa => 'ArrayRef[Str]',
22 traits => ['Array'],
23 required => 0,
24 );
25  
26 has ilsm => (
27 is => 'ro',
28 isa => 'ArrayRef[Str]',
29 traits => ['Array'],
30 required => 0,
31 0 ▶ default => sub { ['Inline::C'] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 1 );
33  
34 has bundle => (
35 is => 'ro',
36 0 ▶ default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 1 );
38  
39 0 ▶sub _build_stub {
Subroutine _build_stub: not called CC=1 SCAR=6.9
40 0 my ($self) = @_;
41 0 return [ map "${_}::Inline", @{$self->module} ];
42 }
43  
44 # Lets us pass the options more than once:
45 0 ▶sub mvp_multivalue_args { qw(module stub ilsm) }
Subroutine mvp_multivalue_args: not called CC=1 SCAR=6.9
Pod undocumented
46  
47 # Add lines to use Inline::Module to Makefile.PL
48 0 ▶around _build_header => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 return <<'...';
50  
51 use lib 'inc';
52 use Inline::Module;
53  
54 ...
55 1 };
56  
57 # Add list of modules to the postamble arguments.
58 0 ▶around _build_WriteMakefile_args => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 my $orig = shift;
60 0 my $self = shift;
61  
62 0 my $make_args = $self->$orig(@_);
63 $self->{inline_meta} =
64 $make_args->{postamble}{inline} = {
65 0 module => $self->module,
66 stub => $self->stub,
67 ilsm => $self->ilsm,
68 bundle => $self->bundle,
69 };
70  
71 0 return $make_args;
72 1 };
73  
74 0 ▶sub after_build {
Subroutine after_build: not called CC=2 SCAR=17.9
Pod undocumented
75 0 my ($self, $hash) = @_;
76  
77 0 my $meta = $self->{inline_meta};
78  
79 my $files_added = Inline::Module->add_to_distdir(
80 $hash->{build_root}->stringify,
81 $meta->{stub},
82 0 Inline::Module->included_modules($meta),
83 );
84  
85 # The following will make sure that Dist::Zilla knows about the written
86 # files so that it can add them to the tarball.
87 $self->add_file( Dist::Zilla::File::OnDisk->new( name => $_ ) )
88 0 for @$files_added;
89 }
90  
91 1 1;
↑ Summary