blib/lib/Pinto/Action/Copy.pm

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