blib/lib/Pinto/Action/New.pm

filter: Statementstmt 100% 32 / 32 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 95.4% 42 / 44 CC 4 SCAR 8.6
CC
4
Cov
95%
execute
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« blib/lib/Pinto/PackageExtractor.pm ↑ Summary blib/lib/Pinto/Action/Default.pm »
1 # ABSTRACT: Create a new empty stack
2  
3 package Pinto::Action::New;
4  
5 52 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 52 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 52 ▶use MooseX::Types::Moose qw(Bool Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 52 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 52 ▶use Pinto::Types qw(StackName PerlVersion);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #------------------------------------------------------------------------------
13  
14 52 our $VERSION = '0.14'; # VERSION
15  
16 #------------------------------------------------------------------------------
17  
18 52 extends qw( Pinto::Action );
19  
20 #------------------------------------------------------------------------------
21  
22 52 with qw( Pinto::Role::Transactional );
23  
24 #------------------------------------------------------------------------------
25  
26 52 has stack => (
27 is => 'ro',
28 isa => StackName,
29 required => 1,
30 );
31  
32 52 has default => (
33 is => 'ro',
34 isa => Bool,
35 default => 0,
36 );
37  
38 52 has description => (
39 is => 'ro',
40 isa => Str,
41 predicate => 'has_description',
42 );
43  
44 52 has target_perl_version => (
45 is => 'ro',
46 isa => PerlVersion,
47 predicate => 'has_target_perl_version',
48 coerce => 1,
49 );
50  
51 #------------------------------------------------------------------------------
52  
53 84 ▶sub execute {
Subroutine execute: called CC=4 SCAR=14.0
54 84 my ($self) = @_;
55  
56 84 my %attrs = ( name => $self->stack );
57 84 my $stack = $self->repo->create_stack(%attrs);
58  
59 84 $stack->set_properties( $stack->default_properties );
60  
61 84 ▶ $stack->set_property( description => $self->description )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_description 0 84 84
62 if $self->has_description;
63  
64 84 ▶ $stack->set_property( target_perl_version => $self->target_perl_version )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_target_perl_version 0 84 84
65 if $self->has_target_perl_version;
66  
67 84 ▶ $stack->mark_as_default
Branch: 1 branch
BranchTrueFalseTotal
if $self->default 68 16 84
68 if $self->default;
69  
70 84 return $self->result->changed;
71 }
72  
73 #------------------------------------------------------------------------------
74  
75 52 __PACKAGE__->meta->make_immutable;
76  
77 #------------------------------------------------------------------------------
78  
79 52 1;
80  
81 __END__
« blib/lib/Pinto/PackageExtractor.pm ↑ Summary blib/lib/Pinto/Action/Default.pm »