line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
12
|
|
|
12
|
|
15891
|
use 5.20.0; |
|
12
|
|
|
|
|
50
|
|
2
|
12
|
|
|
12
|
|
96
|
use strict; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
341
|
|
3
|
12
|
|
|
12
|
|
68
|
use warnings; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
550
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Art::World::Util { |
6
|
|
|
|
|
|
|
|
7
|
12
|
|
|
12
|
|
83
|
use Zydeco; |
|
12
|
|
|
|
|
32
|
|
|
12
|
|
|
|
|
105
|
|
8
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
425346
|
use feature qw( postderef ); |
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
546
|
|
10
|
12
|
|
|
12
|
|
79
|
no warnings qw( experimental::postderef ); |
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
761
|
|
11
|
|
|
|
|
|
|
|
12
|
12
|
|
|
12
|
|
26394
|
class Math { |
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
124
|
|
|
12
|
|
|
|
|
357
|
|
13
|
|
|
|
|
|
|
method pick ( Int $min, Int $max ) { |
14
|
100
|
|
33
|
100
|
0
|
257
|
return $min + int ( rand ( $max - $min )); |
|
100
|
|
66
|
|
|
261
|
|
|
100
|
|
|
|
|
149
|
|
|
100
|
|
|
|
|
113798
|
|
|
100
|
|
|
|
|
304
|
|
|
100
|
|
|
|
|
1755
|
|
|
100
|
|
|
|
|
2427
|
|
15
|
100
|
|
|
|
|
2199
|
} |
16
|
12
|
|
|
12
|
|
777121
|
} |
|
12
|
|
|
12
|
|
34
|
|
|
12
|
|
|
|
|
230
|
|
|
12
|
|
|
|
|
226
|
|
|
12
|
|
|
|
|
6486
|
|
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
62
|
|
17
|
|
|
|
|
|
|
|
18
|
12
|
|
|
12
|
|
71355
|
class Meta { |
|
12
|
|
|
|
|
39
|
|
|
12
|
|
|
|
|
112
|
|
|
12
|
|
|
|
|
320
|
|
19
|
|
|
|
|
|
|
method get_class( Object $klass ) { |
20
|
|
|
|
|
|
|
return ref $klass; |
21
|
17
|
|
33
|
17
|
0
|
46
|
} |
|
17
|
|
66
|
|
|
58
|
|
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
479
|
|
|
17
|
|
|
|
|
77
|
|
|
17
|
|
|
|
|
2014
|
|
|
17
|
|
|
|
|
223
|
|
22
|
17
|
|
|
|
|
168
|
|
|
12
|
|
|
|
|
554
|
|
23
|
12
|
|
|
|
|
243
|
method get_set_attributes_only( Object $clazz ) { |
24
|
|
|
|
|
|
|
return keys %{ $clazz }; |
25
|
0
|
|
0
|
0
|
0
|
0
|
} |
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
26
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
12
|
|
|
|
|
259
|
|
27
|
12
|
|
|
|
|
283
|
method get_all_attributes( Object $claxx ) { |
28
|
|
|
|
|
|
|
return keys( %{ |
29
|
0
|
|
0
|
0
|
0
|
0
|
'Moo'->_constructor_maker_for( |
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
30
|
|
|
|
|
|
|
$self->get_class( $claxx ) |
31
|
0
|
|
|
|
|
0
|
)->all_attribute_specs |
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
}); |
33
|
|
|
|
|
|
|
} |
34
|
12
|
|
|
|
|
224
|
|
35
|
12
|
|
|
|
|
180
|
method random_set_of_agents ( Int $num ) { } |
36
|
12
|
|
0
|
12
|
0
|
1580493
|
} |
|
12
|
|
0
|
12
|
|
35
|
|
|
12
|
|
|
0
|
|
243
|
|
|
12
|
|
|
|
|
141
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
12
|
|
|
|
|
6536
|
|
|
12
|
|
|
|
|
38
|
|
|
12
|
|
|
|
|
67
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Makes possible to generate fake Persons very easily |
39
|
12
|
|
|
12
|
|
106166
|
class Person { |
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
124
|
|
40
|
|
|
|
|
|
|
|
41
|
12
|
|
|
|
|
8620
|
require Faker; |
|
12
|
|
|
|
|
856083
|
|
42
|
12
|
|
33
|
|
|
309
|
has firstname ( isa => Str ) = $self->generator->person_first_name; |
|
127
|
|
|
|
|
1220
|
|
|
127
|
|
|
|
|
354
|
|
|
127
|
|
|
|
|
651
|
|
|
12
|
|
|
|
|
704
|
|
43
|
12
|
|
33
|
|
|
151
|
has lastname ( isa => Str ) = $self->generator->person_last_name; |
|
127
|
|
|
|
|
667248
|
|
|
127
|
|
|
|
|
457
|
|
|
127
|
|
|
|
|
664
|
|
|
12
|
|
|
|
|
310
|
|
44
|
12
|
|
|
|
|
169
|
has generator ( isa => InstanceOf[ 'Faker' ] ) = Faker->new; |
|
127
|
|
|
|
|
129682
|
|
|
12
|
|
|
|
|
7312
|
|
45
|
12
|
|
33
|
|
|
176
|
has fake_name ( isa => Str ) = $self->firstname .' '. $self->lastname; |
|
127
|
|
|
|
|
9670
|
|
|
127
|
|
|
|
|
439
|
|
|
127
|
|
|
|
|
2148
|
|
46
|
12
|
|
|
|
|
301
|
|
47
|
|
|
|
|
|
|
method generate_discourse( ArrayRef $buzz = [] ) { |
48
|
1
|
|
33
|
1
|
0
|
4
|
for ( 0 .. int rand( 3 )) { push $buzz->@*, Faker->new->company_buzzword_type1 }; |
|
1
|
|
33
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16875
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
1161
|
|
|
1
|
|
|
|
|
11
|
|
49
|
1
|
|
|
|
|
7
|
return join ' ', $buzz->@*; |
|
2
|
|
|
|
|
24180
|
|
50
|
1
|
|
|
|
|
919
|
} |
51
|
12
|
|
|
12
|
|
4576022
|
} |
|
12
|
|
|
12
|
|
36
|
|
|
12
|
|
|
|
|
253
|
|
|
12
|
|
|
|
|
296
|
|
|
1
|
|
|
|
|
10
|
|
|
12
|
|
|
|
|
6092
|
|
|
12
|
|
|
|
|
32
|
|
|
12
|
|
|
|
|
63
|
|
52
|
|
|
|
|
|
|
|
53
|
12
|
|
|
12
|
|
36428
|
class String { |
|
12
|
|
|
|
|
38
|
|
|
12
|
|
|
|
|
107
|
|
|
12
|
|
|
|
|
300
|
|
54
|
|
|
|
|
|
|
method titlify( Str $token ) { |
55
|
1
|
|
33
|
1
|
0
|
178
|
return join '', map { ucfirst lc $_ } split /(\s+)/, $token; |
|
1
|
|
33
|
|
|
10
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
818
|
|
|
1
|
|
|
|
|
16
|
|
56
|
1
|
|
|
|
|
9
|
} |
|
3
|
|
|
|
|
15
|
|
57
|
12
|
|
|
12
|
|
405812
|
} |
|
12
|
|
|
12
|
|
30
|
|
|
12
|
|
|
|
|
196
|
|
|
12
|
|
|
|
|
164
|
|
|
12
|
|
|
|
|
5885
|
|
|
12
|
|
|
|
|
34
|
|
|
12
|
|
|
|
|
61
|
|
58
|
|
|
|
|
|
|
|
59
|
12
|
|
|
12
|
|
57037
|
class Time { |
|
12
|
|
|
|
|
36
|
|
|
12
|
|
|
|
|
119
|
|
60
|
12
|
|
|
|
|
9119
|
require Time::Moment; |
61
|
12
|
|
|
|
|
17338
|
# YYYY-MM-DDThh:mm:ss |
62
|
|
|
|
|
|
|
has source! ( |
63
|
12
|
|
|
|
|
167
|
isa => |
64
|
|
|
|
|
|
|
( Str ) & |
65
|
12
|
|
|
|
|
88583
|
( StrMatch[ qr/ \A \d{4} - \d{2} - \d{2} T \d{2} : \d{2} : \d{2} \z /x ] )); |
66
|
12
|
|
33
|
|
|
191
|
has datetime ( isa => InstanceOf[ 'Time::Moment' ], lazy => true ) = Time::Moment->from_string( $self->source . 'Z' ); |
|
1
|
|
|
|
|
151822
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
75
|
|
67
|
12
|
|
|
12
|
|
1866831
|
} |
|
12
|
|
|
12
|
|
41
|
|
|
12
|
|
|
|
|
279
|
|
|
12
|
|
|
|
|
7923
|
|
|
12
|
|
|
|
|
42
|
|
|
12
|
|
|
|
|
65
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Art::World::Util - Generating all kind of data for the Art::World |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SYNOPSIS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
use Art::World::Util; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
say Art::World::Util->new_person->fake_name; |
85
|
|
|
|
|
|
|
#==> Firtname Lastname |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
say Art::World::Util->new_math->pick( 10, 1000 )); |
88
|
|
|
|
|
|
|
#==> 666 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
C<Art::World::Util> provide useful generation tools for automated C<Agents> |
93
|
|
|
|
|
|
|
creation, data manipulation and other utilities that are not strictly related to |
94
|
|
|
|
|
|
|
the Art::World entities. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 Methods |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head3 Art::World::Math |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Artists usually don't like maths too much. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head4 pick() |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Pick an integer between a range that can be passed as a parameter. Mostly a way |
105
|
|
|
|
|
|
|
to not have to memorize C<$min + int ( rand ( $max - $min ))>. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head3 Art::World::Meta |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Looks like the Art::World::Meta toolkit. See |
110
|
|
|
|
|
|
|
L<https://metacpan.org/pod/Class::MOP::Class> for extreme cases. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $meta = $self->meta; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Also there is the Zydeco's C<$class> object. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This is a couple of utilities that makes a sort of meta-programming very simple. It is |
117
|
|
|
|
|
|
|
more like a reminder for my bad memory than something very interesting. Largely |
118
|
|
|
|
|
|
|
inspired by L<this Perl Monks thread|https://www.perlmonks.org/?node_id=1043195>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Art::World::Meta->get_all_attributes( $artist ); |
121
|
|
|
|
|
|
|
# ==> ( 'id', 'name', 'reputation', 'artworks', 'collectors', 'collected', 'status' ) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Mostly useless since Zydeco rely on Moo(se) so the Moose Meta Object Protocol is |
124
|
|
|
|
|
|
|
available. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head4 get_class( Object $klass ) |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the class of the object. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head4 get_set_attributes_only( Object $clazz ) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns only attributes that are set for a particular object. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head4 get_all_attributes( Object $claxx ) |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns even non-set attributes for a particular object. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head3 Art::World::Person |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head4 fake_name() |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Generate a complete person name using L<Faker>. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head3 Art::World::String |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head4 titlify() |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head3 Art::World::Time |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Handy way for generating a L<Time::Moment> object that can be used for C<Events> for example. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $t = Art::World::Util->new_time( source => '2020-02-16T08:18:43' ); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Sébastien Feugère <sebastien@feugere.net> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Copyright 2006-2021 Sebastien Feugère |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0. |