| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: The result from running an Action |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Pinto::Result; |
|
4
|
|
|
|
|
|
|
|
|
5
|
56
|
|
|
56
|
|
349
|
use Moose; |
|
|
56
|
|
|
|
|
120
|
|
|
|
56
|
|
|
|
|
374
|
|
|
6
|
56
|
|
|
56
|
|
347913
|
use MooseX::StrictConstructor; |
|
|
56
|
|
|
|
|
155
|
|
|
|
56
|
|
|
|
|
512
|
|
|
7
|
56
|
|
|
56
|
|
172176
|
use MooseX::Types::Moose qw(Bool ArrayRef); |
|
|
56
|
|
|
|
|
132
|
|
|
|
56
|
|
|
|
|
602
|
|
|
8
|
56
|
|
|
56
|
|
255933
|
use MooseX::MarkAsMethods ( autoclean => 1 ); |
|
|
56
|
|
|
|
|
141
|
|
|
|
56
|
|
|
|
|
629
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
56
|
|
|
56
|
|
220130
|
use Pinto::Util qw(itis); |
|
|
56
|
|
|
|
|
173
|
|
|
|
56
|
|
|
|
|
2947
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
56
|
|
|
56
|
|
6352
|
use overload ( q{""} => 'to_string' ); |
|
|
56
|
|
|
|
|
111
|
|
|
|
56
|
|
|
|
|
564
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.14'; # VERSION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has made_changes => ( |
|
21
|
|
|
|
|
|
|
is => 'ro', |
|
22
|
|
|
|
|
|
|
isa => Bool, |
|
23
|
|
|
|
|
|
|
writer => '_set_made_changes', |
|
24
|
|
|
|
|
|
|
default => 0, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has was_successful => ( |
|
28
|
|
|
|
|
|
|
is => 'ro', |
|
29
|
|
|
|
|
|
|
isa => Bool, |
|
30
|
|
|
|
|
|
|
writer => '_set_was_successful', |
|
31
|
|
|
|
|
|
|
default => 1, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has exceptions => ( |
|
35
|
|
|
|
|
|
|
traits => [qw(Array)], |
|
36
|
|
|
|
|
|
|
handles => { exceptions => 'elements', add_exception => 'push' }, |
|
37
|
|
|
|
|
|
|
isa => ArrayRef, |
|
38
|
|
|
|
|
|
|
default => sub { [] }, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub failed { |
|
44
|
52
|
|
|
52
|
0
|
344
|
my ( $self, %args ) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
52
|
|
|
|
|
1776
|
$self->_set_was_successful(0); |
|
47
|
|
|
|
|
|
|
|
|
48
|
52
|
100
|
|
|
|
683
|
if ( my $reason = $args{because} ) { |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# HACK: Sometimes we'll get exceptions that are strings |
|
51
|
|
|
|
|
|
|
# instead of objects (like from Moose type constraint |
|
52
|
|
|
|
|
|
|
# violations). So we have to convert them ourselves. |
|
53
|
|
|
|
|
|
|
# If the message already contains a full stack trace, |
|
54
|
|
|
|
|
|
|
# then it will be really ugly. God I wish Perl had |
|
55
|
|
|
|
|
|
|
# sane native exceptions. |
|
56
|
|
|
|
|
|
|
|
|
57
|
51
|
|
|
|
|
136009
|
require Pinto::Exception; |
|
58
|
|
|
|
|
|
|
|
|
59
|
51
|
100
|
|
|
|
316
|
$reason = Pinto::Exception->new( message => "$reason" ) |
|
60
|
|
|
|
|
|
|
if not itis( $reason, 'Pinto::Exception' ); |
|
61
|
|
|
|
|
|
|
|
|
62
|
51
|
|
|
|
|
1935
|
$self->add_exception($reason); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
52
|
|
|
|
|
534
|
return $self; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub changed { |
|
71
|
297
|
|
|
297
|
0
|
840
|
my ($self) = @_; |
|
72
|
|
|
|
|
|
|
|
|
73
|
297
|
|
|
|
|
8983
|
$self->_set_made_changes(1); |
|
74
|
|
|
|
|
|
|
|
|
75
|
297
|
|
|
|
|
1216
|
return $self; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub exit_status { |
|
81
|
2
|
|
|
2
|
0
|
35
|
my ($self) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
2
|
50
|
|
|
|
66
|
return $self->was_successful ? 0 : 1; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub to_string { |
|
89
|
44
|
|
|
44
|
0
|
29681
|
my ($self) = @_; |
|
90
|
|
|
|
|
|
|
|
|
91
|
44
|
50
|
|
|
|
1345
|
return 'ok' if $self->was_successful; |
|
92
|
|
|
|
|
|
|
|
|
93
|
44
|
50
|
|
|
|
1396
|
if ( my @exceptions = $self->exceptions ) { |
|
94
|
44
|
|
|
|
|
340
|
return join "\n", @exceptions; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return 'unknown error'; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=pod |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=encoding UTF-8 |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=for :stopwords Jeffrey Ryan Thalhammer |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 NAME |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Pinto::Result - The result from running an Action |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 VERSION |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
version 0.14 |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@stratopan.com> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
132
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |