blib/lib/Dist/Zilla/Role/EnsureStash.pm

filter: Statementstmt 100% 23 / 23 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 96.5% 28 / 29 CC 2 SCAR 3.4
CC
2
Cov
96%
_build_our_stash
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
↑ Summary
1 #
2 # This file is part of Dist-Zilla-Role-EnsureStash
3 #
4 # This software is Copyright (c) 2012 by Chris Weyl.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package Dist::Zilla::Role::EnsureStash;
11 {
12 2 $Dist::Zilla::Role::EnsureStash::VERSION = '0.002';
13 }
14  
15 # ABSTRACT: Ensure your plugin has access to a certain stash
16  
17 # XXX this is probably a good candidate for MX::Role::Parameterized
18 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use MooseX::AttributeShortcuts;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 with 'Dist::Zilla::Role::RegisterStash';
23  
24  
25 # XXX this is probably a good candidate for MX::RelatedClasses
26 2 requires 'our_stash_name';
27 2 requires 'our_stash_class';
28  
29 2 has our_stash => (
30 is => 'lazy',
31 isa_role => 'Dist::Zilla::Role::Stash',
32 );
33  
34 1 ▶sub _build_our_stash {
Subroutine _build_our_stash: called CC=2 SCAR=7.0
35 1 my $self = shift @_;
36  
37 1 my $stash = $self->zilla->stash_named($self->our_stash_name);
38 1 ▶ return $stash if defined $stash;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stash 0 1 1
39  
40 1 Class::MOP::load_class($self->our_stash_class);
41 1 $stash = $self->our_stash_class->new;
42 1 $self->_register_stash($self->our_stash_name, $stash);
43  
44 1 return $stash;
45 }
46  
47 2 !!42;
48  
49 __END__
↑ Summary