line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hades::Realm::Exporter; |
2
|
6
|
|
|
6
|
|
2099736
|
use strict; |
|
6
|
|
|
|
|
64
|
|
|
6
|
|
|
|
|
189
|
|
3
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
203
|
|
4
|
6
|
|
|
6
|
|
33
|
use base qw/Hades/; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
22821
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.04; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
31
|
100
|
|
31
|
1
|
66322
|
my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ ); |
|
29
|
|
|
|
|
135
|
|
9
|
31
|
|
|
|
|
156
|
my $self = $cls->SUPER::new(%args); |
10
|
31
|
|
|
|
|
406
|
my %accessors = ( export => { default => {}, }, ); |
11
|
31
|
|
|
|
|
105
|
for my $accessor ( keys %accessors ) { |
12
|
|
|
|
|
|
|
my $param |
13
|
|
|
|
|
|
|
= defined $args{$accessor} |
14
|
|
|
|
|
|
|
? $args{$accessor} |
15
|
31
|
100
|
|
|
|
94
|
: $accessors{$accessor}->{default}; |
16
|
|
|
|
|
|
|
my $value |
17
|
|
|
|
|
|
|
= $self->$accessor( $accessors{$accessor}->{builder} |
18
|
31
|
50
|
|
|
|
128
|
? $accessors{$accessor}->{builder}->( $self, $param ) |
19
|
|
|
|
|
|
|
: $param ); |
20
|
29
|
50
|
33
|
|
|
147
|
unless ( !$accessors{$accessor}->{required} || defined $value ) { |
21
|
0
|
|
|
|
|
0
|
die "$accessor accessor is required"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
29
|
|
|
|
|
186
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub export { |
28
|
48
|
|
|
48
|
1
|
1515
|
my ( $self, $value ) = @_; |
29
|
48
|
100
|
|
|
|
134
|
if ( defined $value ) { |
30
|
34
|
100
|
100
|
|
|
144
|
if ( ( ref($value) || "" ) ne "HASH" ) { |
31
|
4
|
|
|
|
|
51
|
die qq{HashRef: invalid value $value for accessor export}; |
32
|
|
|
|
|
|
|
} |
33
|
30
|
|
|
|
|
126
|
$self->{export} = $value; |
34
|
|
|
|
|
|
|
} |
35
|
44
|
|
|
|
|
120
|
return $self->{export}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub build_self { |
39
|
12
|
|
|
12
|
1
|
1322
|
my ( $self, $name ) = @_; |
40
|
12
|
50
|
|
|
|
40
|
if ( defined $name ) { |
41
|
12
|
100
|
|
|
|
35
|
if ( ref $name ) { |
42
|
2
|
|
|
|
|
21
|
die |
43
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $name for variable \$name in method build_self}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
10
|
|
|
|
|
50
|
return qq|$name|; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub default_export_hash { |
52
|
11
|
|
|
11
|
1
|
3601
|
my ( $self, $mg, $class, $export ) = @_; |
53
|
11
|
100
|
100
|
|
|
120
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
54
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
55
|
2
|
|
|
|
|
19
|
die |
56
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method default_export_hash}; |
57
|
|
|
|
|
|
|
} |
58
|
9
|
100
|
100
|
|
|
50
|
if ( ( ref($class) || "" ) ne "HASH" ) { |
59
|
2
|
50
|
|
|
|
7
|
$class = defined $class ? $class : 'undef'; |
60
|
2
|
|
|
|
|
18
|
die |
61
|
|
|
|
|
|
|
qq{HashRef: invalid value $class for variable \$class in method default_export_hash}; |
62
|
|
|
|
|
|
|
} |
63
|
7
|
100
|
|
|
|
32
|
$export = defined $export ? $export : {}; |
64
|
7
|
100
|
100
|
|
|
38
|
if ( ( ref($export) || "" ) ne "HASH" ) { |
65
|
2
|
50
|
|
|
|
6
|
$export = defined $export ? $export : 'undef'; |
66
|
2
|
|
|
|
|
18
|
die |
67
|
|
|
|
|
|
|
qq{HashRef: invalid value $export for variable \$export in method default_export_hash}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
5
|
100
|
66
|
|
|
37
|
if ( $class->{CURRENT}->{BASE} || $class->{CURRENT}->{PARENT} ) { |
71
|
1
|
|
|
|
|
3
|
for my $cls ( |
72
|
1
|
50
|
|
|
|
5
|
@{ $class->{CURRENT}->{BASE} || [] }, |
73
|
1
|
50
|
|
|
|
7
|
@{ $class->{CURRENT}->{PARENT} || [] } |
74
|
|
|
|
|
|
|
) |
75
|
|
|
|
|
|
|
{ |
76
|
1
|
50
|
|
|
|
5
|
if ( $self->export->{$cls} ) { |
77
|
1
|
|
|
|
|
3
|
my %unique; |
78
|
1
|
|
|
|
|
2
|
for ( keys %{ $self->export->{$cls} } ) { |
|
1
|
|
|
|
|
4
|
|
79
|
5
|
|
|
|
|
12
|
push @{ $export->{$_} }, |
80
|
39
|
|
|
|
|
56
|
map { $unique{$_}++; $_; } |
|
39
|
|
|
|
|
72
|
|
81
|
5
|
|
|
|
|
8
|
@{ $self->export->{$cls}->{$_} }; |
|
5
|
|
|
|
|
11
|
|
82
|
|
|
|
|
|
|
} |
83
|
1
|
|
|
|
|
6
|
for ( keys %unique ) { |
84
|
13
|
|
|
|
|
42
|
$self->build_sub_no_arguments( $mg, |
85
|
|
|
|
|
|
|
[ $_, "return ${cls}::$_(\@_)" ], {} ); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
else { } |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
5
|
|
|
|
|
65
|
return $export; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub build_new { |
96
|
9
|
|
|
9
|
1
|
2463
|
my ( $self, $mg, $meta, $our ) = @_; |
97
|
9
|
100
|
100
|
|
|
84
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
98
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
99
|
2
|
|
|
|
|
20
|
die |
100
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method build_new}; |
101
|
|
|
|
|
|
|
} |
102
|
7
|
100
|
100
|
|
|
44
|
if ( ( ref($meta) || "" ) ne "HASH" ) { |
103
|
2
|
50
|
|
|
|
6
|
$meta = defined $meta ? $meta : 'undef'; |
104
|
2
|
|
|
|
|
19
|
die |
105
|
|
|
|
|
|
|
qq{HashRef: invalid value $meta for variable \$meta in method build_new}; |
106
|
|
|
|
|
|
|
} |
107
|
5
|
50
|
|
|
|
22
|
$our = defined $our ? $our : q|@EXPORT, @EXPORT_OK, %EXPORT_TAGS|; |
108
|
|
|
|
|
|
|
|
109
|
5
|
|
|
|
|
25
|
my %class = %Module::Generate::CLASS; |
110
|
5
|
|
|
|
|
59
|
my $begin = ''; |
111
|
5
|
|
|
|
|
27
|
my $export = $self->default_export_hash( $mg, \%class ); |
112
|
5
|
|
|
|
|
13
|
for ( keys %{$meta} ) { |
|
5
|
|
|
|
|
25
|
|
113
|
30
|
50
|
|
|
|
133
|
if ( $meta->{$_}->{meta} =~ m/^(ACCESSOR|METHOD)$/ ) { |
114
|
30
|
100
|
|
|
|
82
|
if ( $1 eq 'ACCESSOR' ) { |
115
|
|
|
|
|
|
|
$begin .= $_ . q| => | . $meta->{$_}->{default} . q|, | |
116
|
24
|
100
|
|
|
|
78
|
if $meta->{$_}->{default}; |
117
|
|
|
|
|
|
|
} |
118
|
30
|
|
|
|
|
53
|
my $import = $meta->{$_}->{import}; |
119
|
30
|
|
|
|
|
41
|
my $now = shift @{$import}; |
|
30
|
|
|
|
|
54
|
|
120
|
30
|
|
|
|
|
116
|
$self->build_export_tags( $_, "${1}S", $export, $now, $import ); |
121
|
|
|
|
|
|
|
$self->build_export_tags( "has_$_", 'PREDICATES', $export, $now, |
122
|
|
|
|
|
|
|
[] ) |
123
|
30
|
100
|
|
|
|
99
|
if $meta->{$_}->{predicate}; |
124
|
|
|
|
|
|
|
$self->build_export_tags( "clear_$_", 'CLEARERS', $export, $now, |
125
|
|
|
|
|
|
|
[] ) |
126
|
30
|
100
|
|
|
|
96
|
if $meta->{$_}->{clearer}; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
5
|
|
|
|
|
13
|
$self->export->{ $class{CURRENT}{NAME} } = { %{$export} }; |
|
5
|
|
|
|
|
38
|
|
130
|
5
|
|
|
|
|
102
|
$mg->our( '(' . $our . ', %ACCESSORS)' ); |
131
|
5
|
|
|
|
|
87
|
$begin = $self->build_exporter( '%ACCESSORS = (' . $begin . ')', |
132
|
|
|
|
|
|
|
$mg, $export, $meta ); |
133
|
5
|
50
|
|
|
|
29
|
if ( $class{CURRENT}{BEGIN} ) { |
134
|
0
|
|
|
|
|
0
|
( my $code = $class{CURRENT}{BEGIN} ) =~ s/\s*\}\s*$//; |
135
|
0
|
|
|
|
|
0
|
$begin = $code . $begin . "\}"; |
136
|
|
|
|
|
|
|
} |
137
|
5
|
|
|
|
|
44
|
else { $begin = qq|{ $begin }|; } |
138
|
5
|
|
|
|
|
28
|
$class{CURRENT}{BEGIN} = $begin; |
139
|
5
|
|
|
|
|
133
|
delete $class{CURRENT}{SUBS}{new}; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub build_exporter { |
144
|
13
|
|
|
13
|
1
|
4984
|
my ( $self, $begin, $mg, $export, $meta ) = @_; |
145
|
13
|
100
|
66
|
|
|
77
|
if ( !defined($begin) || ref $begin ) { |
146
|
2
|
50
|
|
|
|
7
|
$begin = defined $begin ? $begin : 'undef'; |
147
|
2
|
|
|
|
|
19
|
die |
148
|
|
|
|
|
|
|
qq{Str: invalid value $begin for variable \$begin in method build_exporter}; |
149
|
|
|
|
|
|
|
} |
150
|
11
|
100
|
100
|
|
|
113
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
151
|
2
|
50
|
|
|
|
9
|
$mg = defined $mg ? $mg : 'undef'; |
152
|
2
|
|
|
|
|
22
|
die |
153
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method build_exporter}; |
154
|
|
|
|
|
|
|
} |
155
|
9
|
100
|
100
|
|
|
48
|
if ( ( ref($export) || "" ) ne "HASH" ) { |
156
|
2
|
50
|
|
|
|
6
|
$export = defined $export ? $export : 'undef'; |
157
|
2
|
|
|
|
|
20
|
die |
158
|
|
|
|
|
|
|
qq{HashRef: invalid value $export for variable \$export in method build_exporter}; |
159
|
|
|
|
|
|
|
} |
160
|
7
|
100
|
100
|
|
|
38
|
if ( ( ref($meta) || "" ) ne "HASH" ) { |
161
|
2
|
50
|
|
|
|
6
|
$meta = defined $meta ? $meta : 'undef'; |
162
|
2
|
|
|
|
|
17
|
die |
163
|
|
|
|
|
|
|
qq{HashRef: invalid value $meta for variable \$meta in method build_exporter}; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
5
|
|
|
|
|
16
|
my $ex = delete $export->{EXPORT}; |
167
|
5
|
|
|
|
|
13
|
my $ex_ok = delete $export->{EXPORT_OK}; |
168
|
5
|
|
|
|
|
27
|
my $ex_tags = Module::Generate::_stringify_struct( 'undefined', $export ); |
169
|
5
|
|
|
|
|
6387
|
$ex_tags =~ s/^{/(/; |
170
|
5
|
|
|
|
|
33
|
$ex_tags =~ s/}$/);/; |
171
|
|
|
|
|
|
|
$begin |
172
|
|
|
|
|
|
|
= '@EXPORT = (' |
173
|
33
|
|
|
|
|
84
|
. join( ', ', map {qq|'$_'|} @{$ex} ) . ');' |
|
5
|
|
|
|
|
21
|
|
174
|
|
|
|
|
|
|
. '@EXPORT_OK = (' |
175
|
5
|
|
|
|
|
17
|
. join( ', ', map {qq|'$_'|} @{$ex_ok} ) . ');' |
|
56
|
|
|
|
|
144
|
|
|
5
|
|
|
|
|
13
|
|
176
|
|
|
|
|
|
|
. '%EXPORT_TAGS = ' |
177
|
|
|
|
|
|
|
. $ex_tags |
178
|
|
|
|
|
|
|
. $begin; |
179
|
5
|
|
|
|
|
27
|
return $begin; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub build_export_tags { |
184
|
53
|
|
|
53
|
1
|
6557
|
my ( $self, $name, $type, $export, $now, $import ) = @_; |
185
|
53
|
100
|
66
|
|
|
201
|
if ( !defined($name) || ref $name ) { |
186
|
2
|
50
|
|
|
|
6
|
$name = defined $name ? $name : 'undef'; |
187
|
2
|
|
|
|
|
41
|
die |
188
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_export_tags}; |
189
|
|
|
|
|
|
|
} |
190
|
51
|
100
|
66
|
|
|
151
|
if ( !defined($type) || ref $type ) { |
191
|
2
|
50
|
|
|
|
5
|
$type = defined $type ? $type : 'undef'; |
192
|
2
|
|
|
|
|
21
|
die |
193
|
|
|
|
|
|
|
qq{Str: invalid value $type for variable \$type in method build_export_tags}; |
194
|
|
|
|
|
|
|
} |
195
|
49
|
100
|
100
|
|
|
139
|
if ( ( ref($export) || "" ) ne "HASH" ) { |
196
|
2
|
50
|
|
|
|
9
|
$export = defined $export ? $export : 'undef'; |
197
|
2
|
|
|
|
|
20
|
die |
198
|
|
|
|
|
|
|
qq{HashRef: invalid value $export for variable \$export in method build_export_tags}; |
199
|
|
|
|
|
|
|
} |
200
|
47
|
100
|
|
|
|
110
|
if ( defined $now ) { |
201
|
32
|
100
|
100
|
|
|
161
|
if ( ref $now || $now !~ m/^[-+\d]\d*$/ ) { |
202
|
2
|
|
|
|
|
18
|
die |
203
|
|
|
|
|
|
|
qq{Optional[Int]: invalid value $now for variable \$now in method build_export_tags}; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
45
|
100
|
100
|
|
|
183
|
if ( !defined($import) || ( ref($import) || "" ) ne "ARRAY" ) { |
|
|
|
66
|
|
|
|
|
207
|
2
|
50
|
|
|
|
7
|
$import = defined $import ? $import : 'undef'; |
208
|
2
|
|
|
|
|
19
|
die |
209
|
|
|
|
|
|
|
qq{ArrayRef: invalid value $import for variable \$import in method build_export_tags}; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
43
|
|
|
|
|
65
|
push @{ $export->{$type} }, $name; |
|
43
|
|
|
|
|
139
|
|
213
|
43
|
|
|
|
|
70
|
push @{ $export->{EXPORT_OK} }, $name; |
|
43
|
|
|
|
|
79
|
|
214
|
43
|
100
|
|
|
|
84
|
push @{ $export->{EXPORT} }, $name if $now; |
|
20
|
|
|
|
|
40
|
|
215
|
43
|
|
|
|
|
55
|
for my $i ( @{$import} ) { |
|
43
|
|
|
|
|
82
|
|
216
|
2
|
|
|
|
|
9
|
$i =~ s/^\s*|\s*$//; |
217
|
2
|
|
|
|
|
4
|
push @{ $export->{$i} }, $name; |
|
2
|
|
|
|
|
7
|
|
218
|
|
|
|
|
|
|
} |
219
|
43
|
|
|
|
|
76
|
return $export; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub after_class { |
224
|
7
|
|
|
7
|
1
|
754
|
my ( $self, $mg ) = @_; |
225
|
7
|
100
|
100
|
|
|
69
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
226
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
227
|
2
|
|
|
|
|
20
|
die |
228
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method after_class}; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
5
|
|
|
|
|
31
|
$mg->use(q|Exporter qw/import/|); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub build_sub_or_accessor_attributes { |
236
|
30
|
|
|
30
|
1
|
45862
|
my ( $orig, $self, @params ) |
237
|
|
|
|
|
|
|
= ( 'SUPER::build_sub_or_accessor_attributes', @_ ); |
238
|
|
|
|
|
|
|
|
239
|
30
|
|
|
|
|
177
|
my @res = $self->$orig(@params); |
240
|
|
|
|
|
|
|
unshift @res, ( |
241
|
|
|
|
|
|
|
qr/^(\:import|\:i$)/ => sub { |
242
|
6
|
|
|
6
|
|
3389
|
$params[-1]->{ $params[-3] }->{import} = [0]; |
243
|
|
|
|
|
|
|
}, |
244
|
|
|
|
|
|
|
qr/^(\:import|\:i)\(/ => sub { |
245
|
14
|
|
|
14
|
|
3830
|
my $value = shift; |
246
|
14
|
|
|
|
|
113
|
$value =~ s/(\:import|\:i)\((.*)\)$/$2/sg; |
247
|
14
|
|
|
|
|
112
|
$params[-1]->{ $params[-3] }->{import} = [ split /,/, $value ]; |
248
|
|
|
|
|
|
|
} |
249
|
30
|
|
|
|
|
1581
|
); |
250
|
|
|
|
|
|
|
|
251
|
30
|
50
|
|
|
|
234
|
return wantarray ? @res : $res[0]; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub build_accessor_no_arguments { |
255
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $mg, $token, $meta ) = @_; |
256
|
|
|
|
|
|
|
|
257
|
0
|
|
|
|
|
0
|
$meta->{ $token->[0] }->{meta} = 'ACCESSOR'; |
258
|
|
|
|
|
|
|
$mg->accessor( $token->[0] ) |
259
|
|
|
|
|
|
|
->code( $self->build_accessor_code( $token->[0], '', '', '' ) ) |
260
|
|
|
|
|
|
|
->clear_tests->test( |
261
|
|
|
|
|
|
|
$self->build_tests( |
262
|
0
|
|
|
|
|
0
|
$token->[0], $meta->{ $token->[0] }, |
263
|
|
|
|
|
|
|
'', {%Module::Generate::CLASS} |
264
|
|
|
|
|
|
|
) |
265
|
|
|
|
|
|
|
)->pod(qq|call $token->[0] accessor function.|) |
266
|
|
|
|
|
|
|
->example(qq|$token->[0](\$value)|); |
267
|
0
|
|
|
|
|
0
|
return $meta; |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub build_accessor_code { |
272
|
32
|
|
|
32
|
1
|
5127
|
my ( $self, $name, $private, $type, $trigger ) = @_; |
273
|
32
|
100
|
66
|
|
|
155
|
if ( !defined($name) || ref $name ) { |
274
|
2
|
50
|
|
|
|
6
|
$name = defined $name ? $name : 'undef'; |
275
|
2
|
|
|
|
|
20
|
die |
276
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_accessor_code}; |
277
|
|
|
|
|
|
|
} |
278
|
30
|
100
|
66
|
|
|
130
|
if ( !defined($private) || ref $private ) { |
279
|
2
|
50
|
|
|
|
7
|
$private = defined $private ? $private : 'undef'; |
280
|
2
|
|
|
|
|
19
|
die |
281
|
|
|
|
|
|
|
qq{Str: invalid value $private for variable \$private in method build_accessor_code}; |
282
|
|
|
|
|
|
|
} |
283
|
28
|
100
|
66
|
|
|
122
|
if ( !defined($type) || ref $type ) { |
284
|
2
|
50
|
|
|
|
7
|
$type = defined $type ? $type : 'undef'; |
285
|
2
|
|
|
|
|
19
|
die |
286
|
|
|
|
|
|
|
qq{Str: invalid value $type for variable \$type in method build_accessor_code}; |
287
|
|
|
|
|
|
|
} |
288
|
26
|
100
|
66
|
|
|
115
|
if ( !defined($trigger) || ref $trigger ) { |
289
|
2
|
50
|
|
|
|
6
|
$trigger = defined $trigger ? $trigger : 'undef'; |
290
|
2
|
|
|
|
|
21
|
die |
291
|
|
|
|
|
|
|
qq{Str: invalid value $trigger for variable \$trigger in method build_accessor_code}; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
24
|
|
|
|
|
221
|
return qq|{ |
295
|
|
|
|
|
|
|
my ( \$value ) = \@_; $private |
296
|
|
|
|
|
|
|
if ( defined \$value ) { $type |
297
|
|
|
|
|
|
|
\$ACCESSORS{$name} = \$value; $trigger |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
return \$ACCESSORS{$name}; |
300
|
|
|
|
|
|
|
}|; |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub build_accessor { |
305
|
24
|
|
|
24
|
1
|
6694
|
my ( $orig, $self, @params ) = ( 'SUPER::build_accessor', @_ ); |
306
|
|
|
|
|
|
|
|
307
|
24
|
|
|
|
|
130
|
my @res = $self->$orig(@params); |
308
|
|
|
|
|
|
|
$params[0]->clear_tests->test( |
309
|
|
|
|
|
|
|
$self->build_tests( |
310
|
24
|
|
|
|
|
1818
|
$params[1], $params[2]->{ $params[1] }, |
311
|
|
|
|
|
|
|
'', {%Module::Generate::CLASS} |
312
|
|
|
|
|
|
|
) |
313
|
|
|
|
|
|
|
); |
314
|
|
|
|
|
|
|
$params[0]->pod( |
315
|
|
|
|
|
|
|
sprintf |
316
|
|
|
|
|
|
|
q|call %s accessor function. Expects a single param to be of type %s.|, |
317
|
|
|
|
|
|
|
$params[1], |
318
|
|
|
|
|
|
|
$params[2]->{ $params[1] }->{type}->[0] || 'Any' |
319
|
24
|
50
|
100
|
|
|
511
|
) unless $params[2]->{ $params[1] }->{pod}; |
320
|
|
|
|
|
|
|
$params[0]->example(qq|$params[1]()|) |
321
|
24
|
50
|
|
|
|
290
|
unless $params[2]->{ $params[1] }->{example}; |
322
|
|
|
|
|
|
|
|
323
|
24
|
50
|
|
|
|
213
|
return wantarray ? @res : $res[0]; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
sub build_modify { |
327
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub build_sub_no_arguments { |
332
|
13
|
|
|
13
|
1
|
22
|
my ( $self, $mg, $token, $meta ) = @_; |
333
|
|
|
|
|
|
|
|
334
|
13
|
|
|
|
|
19
|
my $name = shift @{$token}; |
|
13
|
|
|
|
|
23
|
|
335
|
|
|
|
|
|
|
$name =~ m/^(begin|unitcheck|check|init|end|new)$/ |
336
|
0
|
|
|
|
|
0
|
? $mg->$name( join ' ', @{$token} ) |
337
|
|
|
|
|
|
|
: $mg->sub($name) |
338
|
13
|
50
|
|
|
|
54
|
->code( $self->build_sub_code( '', '', '', join( ' ', @{$token} ) ) ) |
|
13
|
|
|
|
|
142
|
|
339
|
|
|
|
|
|
|
->pod(qq|call $name function. Expects no params.|) |
340
|
|
|
|
|
|
|
->example(qq|$name()|); |
341
|
13
|
|
|
|
|
229
|
return $meta; |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
sub build_sub_code { |
346
|
27
|
|
|
27
|
1
|
7213
|
my ( $self, $name, $params, $subtype, $code ) = @_; |
347
|
27
|
100
|
66
|
|
|
135
|
if ( !defined($name) || ref $name ) { |
348
|
2
|
50
|
|
|
|
7
|
$name = defined $name ? $name : 'undef'; |
349
|
2
|
|
|
|
|
21
|
die |
350
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_sub_code}; |
351
|
|
|
|
|
|
|
} |
352
|
25
|
100
|
66
|
|
|
98
|
if ( !defined($params) || ref $params ) { |
353
|
2
|
50
|
|
|
|
7
|
$params = defined $params ? $params : 'undef'; |
354
|
2
|
|
|
|
|
19
|
die |
355
|
|
|
|
|
|
|
qq{Str: invalid value $params for variable \$params in method build_sub_code}; |
356
|
|
|
|
|
|
|
} |
357
|
23
|
100
|
66
|
|
|
85
|
if ( !defined($subtype) || ref $subtype ) { |
358
|
2
|
50
|
|
|
|
8
|
$subtype = defined $subtype ? $subtype : 'undef'; |
359
|
2
|
|
|
|
|
19
|
die |
360
|
|
|
|
|
|
|
qq{Str: invalid value $subtype for variable \$subtype in method build_sub_code}; |
361
|
|
|
|
|
|
|
} |
362
|
21
|
100
|
66
|
|
|
94
|
if ( !defined($code) || ref $code ) { |
363
|
2
|
50
|
|
|
|
6
|
$code = defined $code ? $code : 'undef'; |
364
|
2
|
|
|
|
|
21
|
die |
365
|
|
|
|
|
|
|
qq{Str: invalid value $code for variable \$code in method build_sub_code}; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
19
|
|
|
|
|
58
|
$params =~ s/^\s*,\s*//; |
369
|
19
|
100
|
|
|
|
74
|
$params = qq|my ($params) = \@_;| if $params; |
370
|
19
|
|
|
|
|
87
|
return qq|{ |
371
|
|
|
|
|
|
|
$params $subtype |
372
|
|
|
|
|
|
|
$code; |
373
|
|
|
|
|
|
|
}|; |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
sub build_sub { |
378
|
6
|
|
|
6
|
1
|
1849
|
my ( $orig, $self, @params ) = ( 'SUPER::build_sub', @_ ); |
379
|
|
|
|
|
|
|
|
380
|
6
|
|
|
|
|
45
|
my @res = $self->$orig(@params); |
381
|
|
|
|
|
|
|
$params[0]->clear_tests->test( |
382
|
|
|
|
|
|
|
$self->build_tests( |
383
|
6
|
|
|
|
|
419
|
$params[1], $params[2]->{ $params[1] }, |
384
|
|
|
|
|
|
|
'', {%Module::Generate::CLASS} |
385
|
|
|
|
|
|
|
) |
386
|
|
|
|
|
|
|
); |
387
|
6
|
|
|
|
|
89
|
$params[0]->pod( |
388
|
|
|
|
|
|
|
qq|call $params[1] function. Expects $params[2]->{$params[1]}->{params_explanation}| |
389
|
|
|
|
|
|
|
); |
390
|
|
|
|
|
|
|
|
391
|
6
|
50
|
|
|
|
114
|
return wantarray ? @res : $res[0]; |
392
|
|
|
|
|
|
|
} |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
sub build_clearer { |
395
|
14
|
|
|
14
|
1
|
3640
|
my ( $self, $mg, $name, $meta ) = @_; |
396
|
14
|
100
|
100
|
|
|
97
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
397
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
398
|
2
|
|
|
|
|
19
|
die |
399
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method build_clearer}; |
400
|
|
|
|
|
|
|
} |
401
|
12
|
100
|
66
|
|
|
69
|
if ( !defined($name) || ref $name ) { |
402
|
2
|
50
|
|
|
|
8
|
$name = defined $name ? $name : 'undef'; |
403
|
2
|
|
|
|
|
20
|
die |
404
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_clearer}; |
405
|
|
|
|
|
|
|
} |
406
|
10
|
100
|
100
|
|
|
46
|
if ( ( ref($meta) || "" ) ne "HASH" ) { |
407
|
2
|
50
|
|
|
|
8
|
$meta = defined $meta ? $meta : 'undef'; |
408
|
2
|
|
|
|
|
21
|
die |
409
|
|
|
|
|
|
|
qq{HashRef: invalid value $meta for variable \$meta in method build_clearer}; |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
8
|
|
|
|
|
39
|
my %class = %Module::Generate::CLASS; |
413
|
8
|
|
|
|
|
42
|
$mg->sub(qq|clear_$name|)->code( |
414
|
|
|
|
|
|
|
qq|{ |
415
|
|
|
|
|
|
|
delete \$ACCESSORS{$name}; |
416
|
|
|
|
|
|
|
return 1; |
417
|
|
|
|
|
|
|
}| |
418
|
|
|
|
|
|
|
)->pod(qq|clear $name accessor function.|) |
419
|
|
|
|
|
|
|
->example(qq|clear_$name()|)->clear_tests->test( |
420
|
|
|
|
|
|
|
[ 'ok', qq|$class{CURRENT}{NAME}::clear_$name| ], |
421
|
|
|
|
|
|
|
[ 'is', qq|$class{CURRENT}{NAME}::$name|, 'undef' ] |
422
|
|
|
|
|
|
|
); |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
} |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
sub build_predicate { |
427
|
11
|
|
|
11
|
1
|
3672
|
my ( $self, $mg, $name, $meta ) = @_; |
428
|
11
|
100
|
100
|
|
|
85
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
429
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
430
|
2
|
|
|
|
|
20
|
die |
431
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method build_predicate}; |
432
|
|
|
|
|
|
|
} |
433
|
9
|
100
|
66
|
|
|
54
|
if ( !defined($name) || ref $name ) { |
434
|
2
|
50
|
|
|
|
6
|
$name = defined $name ? $name : 'undef'; |
435
|
2
|
|
|
|
|
21
|
die |
436
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_predicate}; |
437
|
|
|
|
|
|
|
} |
438
|
7
|
100
|
100
|
|
|
40
|
if ( ( ref($meta) || "" ) ne "HASH" ) { |
439
|
2
|
50
|
|
|
|
9
|
$meta = defined $meta ? $meta : 'undef'; |
440
|
2
|
|
|
|
|
18
|
die |
441
|
|
|
|
|
|
|
qq{HashRef: invalid value $meta for variable \$meta in method build_predicate}; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
5
|
|
|
|
|
25
|
my %class = %Module::Generate::CLASS; |
445
|
|
|
|
|
|
|
$mg->sub(qq|has_$name|)->code( |
446
|
|
|
|
|
|
|
qq|{ |
447
|
|
|
|
|
|
|
return exists \$ACCESSORS{$name}; |
448
|
|
|
|
|
|
|
}| |
449
|
|
|
|
|
|
|
) |
450
|
|
|
|
|
|
|
->pod( |
451
|
|
|
|
|
|
|
qq|has_$name accessor function will return trye if $name accessor has a value.| |
452
|
|
|
|
|
|
|
)->example(qq|has_$name()|)->clear_tests->test( |
453
|
|
|
|
|
|
|
( $meta->{$name}->{required} || $meta->{$name}->{default} |
454
|
|
|
|
|
|
|
? ( [ 'is', qq|$class{CURRENT}{NAME}::has_$name|, 1 ], ) |
455
|
|
|
|
|
|
|
: ( [ 'is', qq|$class{CURRENT}{NAME}::has_$name|, q|''| ], ) |
456
|
|
|
|
|
|
|
), |
457
|
5
|
50
|
66
|
|
|
44
|
$self->build_tests( $name, $meta->{$name}, '', \%class ), |
458
|
|
|
|
|
|
|
[ 'is', qq|$class{CURRENT}{NAME}::has_$name|, 1 ], |
459
|
|
|
|
|
|
|
); |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
sub build_coerce { |
464
|
35
|
|
|
35
|
1
|
6382
|
my ( $self, $name, $param, $code ) = @_; |
465
|
35
|
100
|
66
|
|
|
206
|
if ( !defined($name) || ref $name ) { |
466
|
2
|
50
|
|
|
|
6
|
$name = defined $name ? $name : 'undef'; |
467
|
2
|
|
|
|
|
20
|
die |
468
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_coerce}; |
469
|
|
|
|
|
|
|
} |
470
|
33
|
100
|
66
|
|
|
132
|
if ( !defined($param) || ref $param ) { |
471
|
2
|
50
|
|
|
|
6
|
$param = defined $param ? $param : 'undef'; |
472
|
2
|
|
|
|
|
20
|
die |
473
|
|
|
|
|
|
|
qq{Str: invalid value $param for variable \$param in method build_coerce}; |
474
|
|
|
|
|
|
|
} |
475
|
31
|
100
|
|
|
|
102
|
if ( defined $code ) { |
476
|
2
|
50
|
|
|
|
7
|
if ( ref $code ) { |
477
|
2
|
|
|
|
|
19
|
die |
478
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $code for variable \$code in method build_coerce}; |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
} |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
return |
483
|
29
|
0
|
|
|
|
175
|
defined $code |
|
|
50
|
|
|
|
|
|
484
|
|
|
|
|
|
|
? $code =~ m/^\w+$/ |
485
|
|
|
|
|
|
|
? qq|$param = $code($param);| |
486
|
|
|
|
|
|
|
: $code |
487
|
|
|
|
|
|
|
: q||; |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
sub build_trigger { |
492
|
30
|
|
|
30
|
1
|
23452
|
my ( $self, $name, $param, $code ) = @_; |
493
|
30
|
100
|
66
|
|
|
179
|
if ( !defined($name) || ref $name ) { |
494
|
2
|
50
|
|
|
|
8
|
$name = defined $name ? $name : 'undef'; |
495
|
2
|
|
|
|
|
21
|
die |
496
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_trigger}; |
497
|
|
|
|
|
|
|
} |
498
|
28
|
100
|
66
|
|
|
123
|
if ( !defined($param) || ref $param ) { |
499
|
2
|
50
|
|
|
|
7
|
$param = defined $param ? $param : 'undef'; |
500
|
2
|
|
|
|
|
20
|
die |
501
|
|
|
|
|
|
|
qq{Str: invalid value $param for variable \$param in method build_trigger}; |
502
|
|
|
|
|
|
|
} |
503
|
26
|
100
|
|
|
|
69
|
if ( defined $code ) { |
504
|
2
|
50
|
|
|
|
8
|
if ( ref $code ) { |
505
|
2
|
|
|
|
|
18
|
die |
506
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $code for variable \$code in method build_trigger}; |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
return |
511
|
24
|
0
|
|
|
|
85
|
defined $code |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
512
|
|
|
|
|
|
|
? $code =~ m/^1$/ |
513
|
|
|
|
|
|
|
? qq|_trigger_$name| |
514
|
|
|
|
|
|
|
: $code =~ m/^\w+$/ ? qq|$code($param);| |
515
|
|
|
|
|
|
|
: $code |
516
|
|
|
|
|
|
|
: q||; |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
} |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
sub build_tests { |
521
|
73
|
|
|
73
|
1
|
17814
|
my ( $self, $name, $meta, $mod, $class ) = @_; |
522
|
73
|
100
|
66
|
|
|
349
|
if ( !defined($name) || ref $name ) { |
523
|
2
|
50
|
|
|
|
8
|
$name = defined $name ? $name : 'undef'; |
524
|
2
|
|
|
|
|
21
|
die |
525
|
|
|
|
|
|
|
qq{Str: invalid value $name for variable \$name in method build_tests}; |
526
|
|
|
|
|
|
|
} |
527
|
71
|
100
|
100
|
|
|
250
|
if ( ( ref($meta) || "" ) ne "HASH" ) { |
528
|
2
|
50
|
|
|
|
7
|
$meta = defined $meta ? $meta : 'undef'; |
529
|
2
|
|
|
|
|
18
|
die |
530
|
|
|
|
|
|
|
qq{HashRef: invalid value $meta for variable \$meta in method build_tests}; |
531
|
|
|
|
|
|
|
} |
532
|
69
|
100
|
|
|
|
164
|
if ( defined $mod ) { |
533
|
37
|
100
|
|
|
|
93
|
if ( ref $mod ) { |
534
|
2
|
|
|
|
|
20
|
die |
535
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $mod for variable \$mod in method build_tests}; |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
} |
538
|
67
|
100
|
|
|
|
139
|
if ( defined $class ) { |
539
|
37
|
100
|
100
|
|
|
128
|
if ( ( ref($class) || "" ) ne "HASH" ) { |
540
|
2
|
|
|
|
|
50
|
die |
541
|
|
|
|
|
|
|
qq{Optional[HashRef]: invalid value $class for variable \$class in method build_tests}; |
542
|
|
|
|
|
|
|
} |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
65
|
|
|
|
|
109
|
my @tests; |
546
|
65
|
100
|
|
|
|
155
|
if ($class) { |
547
|
35
|
|
|
|
|
76
|
my $cls = $class->{CURRENT}->{NAME}; |
548
|
35
|
100
|
|
|
|
137
|
if ( $meta->{meta} eq 'ACCESSOR' ) { |
|
|
50
|
|
|
|
|
|
549
|
|
|
|
|
|
|
$meta->{private} |
550
|
|
|
|
|
|
|
? do { |
551
|
8
|
|
|
|
|
36
|
push @tests, |
552
|
|
|
|
|
|
|
[ |
553
|
|
|
|
|
|
|
'eval', |
554
|
|
|
|
|
|
|
qq|${cls}::${name}()|, |
555
|
|
|
|
|
|
|
'private method|private attribute' |
556
|
|
|
|
|
|
|
]; |
557
|
|
|
|
|
|
|
} |
558
|
29
|
100
|
|
|
|
78
|
: do { |
559
|
|
|
|
|
|
|
push @tests, [ 'is', qq|${cls}::${name}()|, 'undef' ] |
560
|
21
|
100
|
100
|
|
|
132
|
if !$meta->{required} && !$meta->{default}; |
561
|
21
|
|
|
|
|
88
|
push @tests, [ 'eval', qq|${cls}::${name}()|, q|^$| ]; |
562
|
|
|
|
|
|
|
my (@test_cases) |
563
|
21
|
|
100
|
|
|
115
|
= $self->build_test_data( $meta->{type}->[0] || 'Any', |
564
|
|
|
|
|
|
|
$name ); |
565
|
21
|
100
|
|
|
|
15301
|
if ( scalar @test_cases > 1 ) { |
566
|
18
|
|
|
|
|
50
|
my $valid = shift @test_cases; |
567
|
18
|
|
|
|
|
95
|
push @tests, |
568
|
|
|
|
|
|
|
[ 'deep', qq|${cls}::${name}($valid)|, $valid ]; |
569
|
18
|
50
|
|
|
|
61
|
unless ( $meta->{coerce} ) { |
570
|
18
|
|
|
|
|
47
|
for (@test_cases) { |
571
|
95
|
|
|
|
|
330
|
push @tests, |
572
|
|
|
|
|
|
|
[ |
573
|
|
|
|
|
|
|
'eval', qq|${cls}::${name}($_)|, |
574
|
|
|
|
|
|
|
'invalid|value|type|constraint|greater|atleast' |
575
|
|
|
|
|
|
|
]; |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
} |
578
|
18
|
|
|
|
|
74
|
push @tests, [ 'deep', qq|${cls}::${name}|, $valid ]; |
579
|
|
|
|
|
|
|
} |
580
|
|
|
|
|
|
|
}; |
581
|
|
|
|
|
|
|
} |
582
|
|
|
|
|
|
|
elsif ( $meta->{meta} eq 'METHOD' ) { |
583
|
|
|
|
|
|
|
$meta->{private} |
584
|
|
|
|
|
|
|
? do { |
585
|
0
|
|
|
|
|
0
|
push @tests, |
586
|
|
|
|
|
|
|
[ 'eval', qq|${cls}::${name}()|, 'private method' ]; |
587
|
|
|
|
|
|
|
} |
588
|
6
|
50
|
66
|
|
|
30
|
: $meta->{param} && do { |
589
|
|
|
|
|
|
|
my %test_data = map { |
590
|
|
|
|
|
|
|
$_ => [ |
591
|
|
|
|
|
|
|
$self->build_test_data( |
592
|
|
|
|
|
|
|
$meta->{params_map}->{$_}->{type} || 'Any', $name |
593
|
|
|
|
|
|
|
), |
594
|
|
|
|
|
|
|
( $meta->{params_map}->{$_}->{type} || 'Any' ) |
595
|
|
|
|
|
|
|
!~ m/^(|Optional|Any|Item)/ ? q|undef| : () |
596
|
|
|
|
|
|
|
] |
597
|
|
|
|
|
|
|
} @{ $meta->{param} }; |
598
|
|
|
|
|
|
|
for my $key ( @{ $meta->{param} } ) { |
599
|
|
|
|
|
|
|
for my $ah ( splice @{ $test_data{$key} }, 1 ) { |
600
|
|
|
|
|
|
|
push @tests, |
601
|
|
|
|
|
|
|
[ |
602
|
|
|
|
|
|
|
'eval', |
603
|
|
|
|
|
|
|
sprintf( |
604
|
|
|
|
|
|
|
q|%s::%s(%s)|, |
605
|
|
|
|
|
|
|
$cls, $name, |
606
|
|
|
|
|
|
|
join ', ', |
607
|
|
|
|
|
|
|
map { $key eq $_ ? $ah : $test_data{$_}->[0] } |
608
|
|
|
|
|
|
|
@{ $meta->{param} } |
609
|
|
|
|
|
|
|
), |
610
|
|
|
|
|
|
|
'invalid|value|type|constraint|greater|atleast' |
611
|
|
|
|
|
|
|
]; |
612
|
|
|
|
|
|
|
} |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
} |
616
|
|
|
|
|
|
|
} |
617
|
65
|
100
|
|
|
|
169
|
push @tests, @{ $meta->{test} } if $meta->{test}; |
|
2
|
|
|
|
|
5
|
|
618
|
65
|
|
|
|
|
309
|
return @tests; |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
1; |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
__END__ |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
=head1 NAME |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
Hades::Realm::Exporter - Hades realm for Exporter |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
=head1 VERSION |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
Version 0.01 |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
=cut |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=head1 SYNOPSIS |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
Quick summary of what the module does: |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
Hades->run({ |
641
|
|
|
|
|
|
|
eval => 'Kosmos { |
642
|
|
|
|
|
|
|
[curae penthos] :t(Int) :d(2) :p :pr :c :r :i(1, GROUP) |
643
|
|
|
|
|
|
|
geras $nosoi :t(Int) :d(5) :i { if (penthos() == $nosoi) { return curae; } } |
644
|
|
|
|
|
|
|
}', |
645
|
|
|
|
|
|
|
realm => 'Exporter', |
646
|
|
|
|
|
|
|
}); |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
... generates ... |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
package Kosmos; |
651
|
|
|
|
|
|
|
use strict; |
652
|
|
|
|
|
|
|
use warnings; |
653
|
|
|
|
|
|
|
use Exporter qw/import/; |
654
|
|
|
|
|
|
|
our $VERSION = 0.01; |
655
|
|
|
|
|
|
|
our ( @EXPORT, @EXPORT_OK, %EXPORT_TAGS, %ACCESSORS ); |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
BEGIN { |
658
|
|
|
|
|
|
|
@EXPORT = ( |
659
|
|
|
|
|
|
|
'curae', 'has_curae', 'clear_curae', 'penthos', |
660
|
|
|
|
|
|
|
'has_penthos', 'clear_penthos' |
661
|
|
|
|
|
|
|
); |
662
|
|
|
|
|
|
|
@EXPORT_OK = ( |
663
|
|
|
|
|
|
|
'curae', 'has_curae', 'clear_curae', 'penthos', |
664
|
|
|
|
|
|
|
'has_penthos', 'clear_penthos', 'geras' |
665
|
|
|
|
|
|
|
); |
666
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
667
|
|
|
|
|
|
|
'METHODS' => ['geras'], |
668
|
|
|
|
|
|
|
'CLEARERS' => [ 'clear_curae', 'clear_penthos' ], |
669
|
|
|
|
|
|
|
'GROUP' => [ 'curae', 'penthos' ], |
670
|
|
|
|
|
|
|
'PREDICATES' => [ 'has_curae', 'has_penthos' ], |
671
|
|
|
|
|
|
|
'ACCESSORS' => [ 'curae', 'penthos' ] |
672
|
|
|
|
|
|
|
); |
673
|
|
|
|
|
|
|
%ACCESSORS = ( curae => 2, penthos => 2, ); |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
sub curae { |
677
|
|
|
|
|
|
|
my ($value) = @_; |
678
|
|
|
|
|
|
|
my $private_caller = caller(); |
679
|
|
|
|
|
|
|
if ( $private_caller ne __PACKAGE__ ) { |
680
|
|
|
|
|
|
|
die "cannot call private method curae from $private_caller"; |
681
|
|
|
|
|
|
|
} |
682
|
|
|
|
|
|
|
if ( defined $value ) { |
683
|
|
|
|
|
|
|
if ( ref $value || $value !~ m/^[-+\d]\d*$/ ) { |
684
|
|
|
|
|
|
|
die qq{Int: invalid value $value for accessor curae}; |
685
|
|
|
|
|
|
|
} |
686
|
|
|
|
|
|
|
$ACCESSORS{curae} = $value; |
687
|
|
|
|
|
|
|
} |
688
|
|
|
|
|
|
|
return $ACCESSORS{curae}; |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
sub has_curae { |
692
|
|
|
|
|
|
|
return exists $ACCESSORS{curae}; |
693
|
|
|
|
|
|
|
} |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
sub clear_curae { |
696
|
|
|
|
|
|
|
delete $ACCESSORS{curae}; |
697
|
|
|
|
|
|
|
return 1; |
698
|
|
|
|
|
|
|
} |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
sub penthos { |
701
|
|
|
|
|
|
|
my ($value) = @_; |
702
|
|
|
|
|
|
|
my $private_caller = caller(); |
703
|
|
|
|
|
|
|
if ( $private_caller ne __PACKAGE__ ) { |
704
|
|
|
|
|
|
|
die "cannot call private method penthos from $private_caller"; |
705
|
|
|
|
|
|
|
} |
706
|
|
|
|
|
|
|
if ( defined $value ) { |
707
|
|
|
|
|
|
|
if ( ref $value || $value !~ m/^[-+\d]\d*$/ ) { |
708
|
|
|
|
|
|
|
die qq{Int: invalid value $value for accessor penthos}; |
709
|
|
|
|
|
|
|
} |
710
|
|
|
|
|
|
|
$ACCESSORS{penthos} = $value; |
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
return $ACCESSORS{penthos}; |
713
|
|
|
|
|
|
|
} |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
sub has_penthos { |
716
|
|
|
|
|
|
|
return exists $ACCESSORS{penthos}; |
717
|
|
|
|
|
|
|
} |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
sub clear_penthos { |
720
|
|
|
|
|
|
|
delete $ACCESSORS{penthos}; |
721
|
|
|
|
|
|
|
return 1; |
722
|
|
|
|
|
|
|
} |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
sub geras { |
725
|
|
|
|
|
|
|
my ($nosoi) = @_; |
726
|
|
|
|
|
|
|
$nosoi = defined $nosoi ? $nosoi : 5; |
727
|
|
|
|
|
|
|
if ( !defined($nosoi) || ref $nosoi || $nosoi !~ m/^[-+\d]\d*$/ ) { |
728
|
|
|
|
|
|
|
$nosoi = defined $nosoi ? $nosoi : 'undef'; |
729
|
|
|
|
|
|
|
die |
730
|
|
|
|
|
|
|
qq{Int: invalid value $nosoi for variable \$nosoi in method geras}; |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
if ( penthos() == $nosoi ) { return curae(); } |
733
|
|
|
|
|
|
|
} |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
1; |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
__END__ |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
=head2 new |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
Instantiate a new Hades::Realm::Exporter object. |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
Hades::Realm::Exporter->new |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
=head2 build_self |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
call build_self method. Expects param $name to be a Optional[Str]. |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
$obj->build_self($name) |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=head2 default_export_hash |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
call default_export_hash method. Expects param $mg to be a Object, param $class to be a HashRef, param $export to be a HashRef. |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
$obj->default_export_hash($mg, $class, $export) |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
=head2 build_new |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
call build_new method. Expects param $mg to be a Object, param $meta to be a HashRef, param $our to be any value including undef. |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
$obj->build_new($mg, $meta, $our) |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
=head2 build_exporter |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
call build_exporter method. Expects param $begin to be a Str, param $mg to be a Object, param $export to be a HashRef, param $meta to be a HashRef. |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
$obj->build_exporter($begin, $mg, $export, $meta) |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=head2 build_export_tags |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
call build_export_tags method. Expects param $name to be a Str, param $type to be a Str, param $export to be a HashRef, param $now to be a Optional[Int], param $import to be a ArrayRef. |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
$obj->build_export_tags($name, $type, $export, $now, $import) |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
=head2 after_class |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
call after_class method. Expects param $mg to be a Object. |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
$obj->after_class($mg) |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
=head2 build_sub_or_accessor_attributes |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
call build_sub_or_accessor_attributes method. |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
=head2 build_accessor_no_arguments |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
call build_accessor_no_arguments method. Expects param $mg to be any value including undef, param $token to be any value including undef, param $meta to be any value including undef. |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
$obj->build_accessor_no_arguments($mg, $token, $meta) |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
=head2 build_accessor_code |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
call build_accessor_code method. Expects param $name to be a Str, param $private to be a Str, param $type to be a Str, param $trigger to be a Str. |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
$obj->build_accessor_code($name, $private, $type, $trigger) |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
=head2 build_accessor |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
call build_accessor method. |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
=head2 build_modify |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
call build_modify method. Expects no params. |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
$obj->build_modify() |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
=head2 build_sub_no_arguments |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
call build_sub_no_arguments method. Expects param $mg to be any value including undef, param $token to be any value including undef, param $meta to be any value including undef. |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
$obj->build_sub_no_arguments($mg, $token, $meta) |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
=head2 build_sub_code |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
call build_sub_code method. Expects param $name to be a Str, param $params to be a Str, param $subtype to be a Str, param $code to be a Str. |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
$obj->build_sub_code($name, $params, $subtype, $code) |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
=head2 build_sub |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
call build_sub method. |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
=head2 build_clearer |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
call build_clearer method. Expects param $mg to be a Object, param $name to be a Str, param $meta to be a HashRef. |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
$obj->build_clearer($mg, $name, $meta) |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
=head2 build_predicate |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
call build_predicate method. Expects param $mg to be a Object, param $name to be a Str, param $meta to be a HashRef. |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
$obj->build_predicate($mg, $name, $meta) |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=head2 build_coerce |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
call build_coerce method. Expects param $name to be a Str, param $param to be a Str, param $code to be a Optional[Str]. |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
$obj->build_coerce($name, $param, $code) |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
=head2 build_trigger |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
call build_trigger method. Expects param $name to be a Str, param $param to be a Str, param $code to be a Optional[Str]. |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
$obj->build_trigger($name, $param, $code) |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
=head2 build_tests |
850
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
call build_tests method. Expects param $name to be a Str, param $meta to be a HashRef, param $mod to be a Optional[Str], param $class to be a Optional[HashRef]. |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
$obj->build_tests($name, $meta, $mod, $class) |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
=head1 ACCESSORS |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=head2 export |
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
get or set export. |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
$obj->export; |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
$obj->export($value); |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
=head1 AUTHOR |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
LNATION, C<< <email at lnation.org> >> |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=head1 BUGS |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-hades::realm::exporter at rt.cpan.org>, or through |
872
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Realm-Exporter>. I will be notified, and then you'll |
873
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
=head1 SUPPORT |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
perldoc Hades::Realm::Exporter |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
You can also look for information at: |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
=over 4 |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Realm-Exporter> |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Hades-Realm-Exporter> |
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
=item * CPAN Ratings |
894
|
|
|
|
|
|
|
|
895
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/Hades-Realm-Exporter> |
896
|
|
|
|
|
|
|
|
897
|
|
|
|
|
|
|
=item * Search CPAN |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
L<https://metacpan.org/release/Hades-Realm-Exporter> |
900
|
|
|
|
|
|
|
|
901
|
|
|
|
|
|
|
=back |
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by LNATION. |
908
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
This is free software, licensed under: |
910
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
912
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
=cut |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
|