line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Card::Face; |
4
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
119
|
|
5
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
113
|
|
6
|
4
|
|
|
4
|
|
18
|
no warnings qw( once void ); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
521
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
9
|
|
|
|
|
|
|
our $MITE_SHIM = "Acme::Mitey::Cards::Mite"; |
10
|
|
|
|
|
|
|
our $MITE_VERSION = "0.011000"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Mite keywords |
13
|
|
|
|
|
|
|
BEGIN { |
14
|
4
|
|
|
4
|
|
20
|
my ( $SHIM, $CALLER ) = |
15
|
|
|
|
|
|
|
( "Acme::Mitey::Cards::Mite", "Acme::Mitey::Cards::Card::Face" ); |
16
|
|
|
|
|
|
|
( |
17
|
|
|
|
|
|
|
*after, *around, *before, *extends, *field, |
18
|
|
|
|
|
|
|
*has, *param, *signature_for, *with |
19
|
|
|
|
|
|
|
) |
20
|
4
|
|
|
|
|
8
|
= do { |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
23
|
4
|
|
|
4
|
|
37
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
912
|
|
24
|
|
|
|
|
|
|
( |
25
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
26
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
27
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
28
|
|
|
|
4
|
|
|
sub { }, |
29
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
30
|
8
|
|
|
8
|
|
38
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
31
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
32
|
8
|
|
|
8
|
|
64
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
33
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
34
|
4
|
|
|
|
|
739
|
); |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Mite imports |
39
|
|
|
|
|
|
|
BEGIN { |
40
|
4
|
|
|
4
|
|
30
|
require Scalar::Util; |
41
|
4
|
|
|
|
|
13
|
*STRICT = \&Acme::Mitey::Cards::Mite::STRICT; |
42
|
4
|
|
|
|
|
10
|
*bare = \&Acme::Mitey::Cards::Mite::bare; |
43
|
4
|
|
|
|
|
8
|
*blessed = \&Scalar::Util::blessed; |
44
|
4
|
|
|
|
|
8
|
*carp = \&Acme::Mitey::Cards::Mite::carp; |
45
|
4
|
|
|
|
|
9
|
*confess = \&Acme::Mitey::Cards::Mite::confess; |
46
|
4
|
|
|
|
|
7
|
*croak = \&Acme::Mitey::Cards::Mite::croak; |
47
|
4
|
|
|
|
|
8
|
*false = \&Acme::Mitey::Cards::Mite::false; |
48
|
4
|
|
|
|
|
9
|
*guard = \&Acme::Mitey::Cards::Mite::guard; |
49
|
4
|
|
|
|
|
8
|
*lazy = \&Acme::Mitey::Cards::Mite::lazy; |
50
|
4
|
|
|
|
|
8
|
*lock = \&Acme::Mitey::Cards::Mite::lock; |
51
|
4
|
|
|
|
|
8
|
*ro = \&Acme::Mitey::Cards::Mite::ro; |
52
|
4
|
|
|
|
|
8
|
*rw = \&Acme::Mitey::Cards::Mite::rw; |
53
|
4
|
|
|
|
|
20
|
*rwp = \&Acme::Mitey::Cards::Mite::rwp; |
54
|
4
|
|
|
|
|
11
|
*true = \&Acme::Mitey::Cards::Mite::true; |
55
|
4
|
|
|
|
|
177
|
*unlock = \&Acme::Mitey::Cards::Mite::unlock; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
BEGIN { |
59
|
4
|
|
|
4
|
|
630
|
require Acme::Mitey::Cards::Card; |
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
4
|
|
26
|
use mro 'c3'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
24
|
|
62
|
4
|
|
|
|
|
26
|
our @ISA; |
63
|
4
|
|
|
|
|
1251
|
push @ISA, "Acme::Mitey::Cards::Card"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
67
|
|
|
|
|
|
|
sub new { |
68
|
15
|
50
|
|
15
|
0
|
128
|
my $class = ref( $_[0] ) ? ref(shift) : shift; |
69
|
15
|
|
66
|
|
|
57
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
70
|
15
|
|
|
|
|
35
|
my $self = bless {}, $class; |
71
|
|
|
|
|
|
|
my $args = |
72
|
|
|
|
|
|
|
$meta->{HAS_BUILDARGS} |
73
|
|
|
|
|
|
|
? $class->BUILDARGS(@_) |
74
|
15
|
50
|
|
|
|
63
|
: { ( @_ == 1 ) ? %{ $_[0] } : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
75
|
15
|
|
|
|
|
29
|
my $no_build = delete $args->{__no_BUILD__}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Attribute deck (type: Deck) |
78
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card.pm, line 9 |
79
|
15
|
100
|
|
|
|
32
|
if ( exists $args->{"deck"} ) { |
80
|
|
|
|
|
|
|
blessed( $args->{"deck"} ) |
81
|
12
|
50
|
33
|
|
|
100
|
&& $args->{"deck"}->isa("Acme::Mitey::Cards::Deck") |
82
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
83
|
|
|
|
|
|
|
"deck", "Deck"; |
84
|
12
|
|
|
|
|
45
|
$self->{"deck"} = $args->{"deck"}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
require Scalar::Util && Scalar::Util::weaken( $self->{"deck"} ) |
87
|
15
|
100
|
33
|
|
|
94
|
if ref $self->{"deck"}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Attribute reverse (type: Str) |
90
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card.pm, line 19 |
91
|
15
|
100
|
|
|
|
38
|
if ( exists $args->{"reverse"} ) { |
92
|
1
|
50
|
|
|
|
2
|
do { |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
95
|
1
|
50
|
|
|
|
4
|
defined( $args->{"reverse"} ) and do { |
96
|
|
|
|
|
|
|
ref( \$args->{"reverse"} ) eq 'SCALAR' |
97
|
1
|
50
|
|
|
|
7
|
or ref( \( my $val = $args->{"reverse"} ) ) eq 'SCALAR'; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
101
|
|
|
|
|
|
|
"reverse", "Str"; |
102
|
1
|
|
|
|
|
2
|
$self->{"reverse"} = $args->{"reverse"}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Attribute suit (type: Suit) |
106
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Face.pm, line 13 |
107
|
15
|
50
|
|
|
|
33
|
croak "Missing key in constructor: suit" unless exists $args->{"suit"}; |
108
|
15
|
|
|
|
|
24
|
do { |
109
|
15
|
|
|
|
|
20
|
my $coerced_value = do { |
110
|
15
|
|
|
|
|
25
|
my $to_coerce = $args->{"suit"}; |
111
|
|
|
|
|
|
|
( |
112
|
|
|
|
|
|
|
( |
113
|
|
|
|
|
|
|
do { |
114
|
4
|
|
|
4
|
|
32
|
use Scalar::Util (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
3753
|
|
115
|
15
|
100
|
|
|
|
98
|
Scalar::Util::blessed($to_coerce) |
116
|
|
|
|
|
|
|
and $to_coerce->isa(q[Acme::Mitey::Cards::Suit]); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
) |
119
|
|
|
|
|
|
|
) ? $to_coerce : ( |
120
|
|
|
|
|
|
|
do { |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
123
|
1
|
50
|
|
|
|
5
|
defined($to_coerce) and do { |
124
|
1
|
50
|
|
|
|
7
|
ref( \$to_coerce ) eq 'SCALAR' |
125
|
|
|
|
|
|
|
or ref( \( my $val = $to_coerce ) ) eq 'SCALAR'; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
) |
129
|
|
|
|
|
|
|
? scalar( |
130
|
15
|
50
|
|
|
|
22
|
do { |
|
|
100
|
|
|
|
|
|
131
|
1
|
|
|
|
|
4
|
local $_ = $to_coerce; |
132
|
1
|
|
|
|
|
2
|
do { |
133
|
1
|
|
|
|
|
2
|
my $method = lc($_); |
134
|
1
|
|
|
|
|
30
|
'Acme::Mitey::Cards::Suit'->$method; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
) |
138
|
|
|
|
|
|
|
: $to_coerce; |
139
|
|
|
|
|
|
|
}; |
140
|
15
|
50
|
33
|
|
|
88
|
blessed($coerced_value) |
141
|
|
|
|
|
|
|
&& $coerced_value->isa("Acme::Mitey::Cards::Suit") |
142
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
143
|
|
|
|
|
|
|
"suit", "Suit"; |
144
|
15
|
|
|
|
|
37
|
$self->{"suit"} = $coerced_value; |
145
|
|
|
|
|
|
|
}; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Attribute face (type: Character) |
148
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Face.pm, line 20 |
149
|
15
|
50
|
|
|
|
35
|
croak "Missing key in constructor: face" unless exists $args->{"face"}; |
150
|
15
|
100
|
|
|
|
25
|
do { |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
153
|
|
|
|
|
|
|
( defined( $args->{"face"} ) |
154
|
|
|
|
|
|
|
and !ref( $args->{"face"} ) |
155
|
15
|
50
|
33
|
|
|
130
|
and $args->{"face"} =~ m{\A(?:(?:Jack|King|Queen))\z} ); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", "face", |
158
|
|
|
|
|
|
|
"Character"; |
159
|
14
|
|
|
|
|
36
|
$self->{"face"} = $args->{"face"}; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Call BUILD methods |
162
|
14
|
50
|
33
|
|
|
31
|
$self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } ); |
|
14
|
50
|
|
|
|
49
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# Unrecognized parameters |
165
|
14
|
|
|
|
|
27
|
my @unknown = grep not(/\A(?:deck|face|reverse|suit)\z/), keys %{$args}; |
|
14
|
|
|
|
|
92
|
|
166
|
|
|
|
|
|
|
@unknown |
167
|
14
|
50
|
|
|
|
37
|
and croak( |
168
|
|
|
|
|
|
|
"Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
169
|
|
|
|
|
|
|
|
170
|
14
|
|
|
|
|
55
|
return $self; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
my $__XS = !$ENV{PERL_ONLY} |
174
|
|
|
|
|
|
|
&& eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# Accessors for face |
177
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Face.pm, line 20 |
178
|
|
|
|
|
|
|
if ($__XS) { |
179
|
|
|
|
|
|
|
Class::XSAccessor->import( |
180
|
|
|
|
|
|
|
chained => 1, |
181
|
|
|
|
|
|
|
"getters" => { "face" => "face" }, |
182
|
|
|
|
|
|
|
); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
else { |
185
|
|
|
|
|
|
|
*face = sub { |
186
|
|
|
|
|
|
|
@_ == 1 or croak('Reader "face" usage: $self->face()'); |
187
|
|
|
|
|
|
|
$_[0]{"face"}; |
188
|
|
|
|
|
|
|
}; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# Accessors for suit |
192
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Face.pm, line 13 |
193
|
|
|
|
|
|
|
if ($__XS) { |
194
|
|
|
|
|
|
|
Class::XSAccessor->import( |
195
|
|
|
|
|
|
|
chained => 1, |
196
|
|
|
|
|
|
|
"getters" => { "suit" => "suit" }, |
197
|
|
|
|
|
|
|
); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
else { |
200
|
|
|
|
|
|
|
*suit = sub { |
201
|
|
|
|
|
|
|
@_ == 1 or croak('Reader "suit" usage: $self->suit()'); |
202
|
|
|
|
|
|
|
$_[0]{"suit"}; |
203
|
|
|
|
|
|
|
}; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# See UNIVERSAL |
207
|
|
|
|
|
|
|
sub DOES { |
208
|
0
|
|
|
0
|
0
|
|
my ( $self, $role ) = @_; |
209
|
0
|
|
|
|
|
|
our %DOES; |
210
|
0
|
0
|
|
|
|
|
return $DOES{$role} if exists $DOES{$role}; |
211
|
0
|
0
|
|
|
|
|
return 1 if $role eq __PACKAGE__; |
212
|
0
|
0
|
0
|
|
|
|
if ( $INC{'Moose/Util.pm'} |
|
|
|
0
|
|
|
|
|
213
|
|
|
|
|
|
|
and my $meta = Moose::Util::find_meta( ref $self or $self ) ) |
214
|
|
|
|
|
|
|
{ |
215
|
0
|
0
|
0
|
|
|
|
$meta->can('does_role') and $meta->does_role($role) and return 1; |
216
|
|
|
|
|
|
|
} |
217
|
0
|
|
|
|
|
|
return $self->SUPER::DOES($role); |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
221
|
|
|
|
|
|
|
sub does { |
222
|
0
|
|
|
0
|
0
|
|
shift->DOES(@_); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# Method signatures |
226
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
$SIGNATURE_FOR{"face_abbreviation"} = sub { |
229
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
@_ == 1 |
234
|
|
|
|
|
|
|
or |
235
|
|
|
|
|
|
|
croak( "Wrong number of parameters in signature for %s: got %d, %s", |
236
|
|
|
|
|
|
|
"face_abbreviation", scalar(@_), "expected exactly 1 parameters" ); |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
241
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
242
|
|
|
|
|
|
|
or croak( |
243
|
|
|
|
|
|
|
"Type check failed in signature for face_abbreviation: %s should be %s", |
244
|
|
|
|
|
|
|
"\$_[0]", "Defined" |
245
|
|
|
|
|
|
|
); |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
do { @_ = ( @head, @_ ); goto $__NEXT__ }; |
248
|
|
|
|
|
|
|
}; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
$SIGNATURE_FOR{"to_string"} = |
251
|
|
|
|
|
|
|
$Acme::Mitey::Cards::Card::SIGNATURE_FOR{"to_string"}; |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
1; |
254
|
|
|
|
|
|
|
} |