| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Fake::MetaSyntactic; |
|
2
|
|
|
|
|
|
|
$Data::Fake::MetaSyntactic::VERSION = '1.001'; |
|
3
|
1
|
|
|
1
|
|
16892
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
34
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
29
|
|
|
5
|
1
|
|
|
1
|
|
16
|
use Exporter 5.57 qw( import ); |
|
|
1
|
|
|
|
|
17
|
|
|
|
1
|
|
|
|
|
45
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( fake_meta fake_metatheme fake_metacategory ); |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
432
|
use Acme::MetaSyntactic (); |
|
|
1
|
|
|
|
|
7277
|
|
|
|
1
|
|
|
|
|
268
|
|
|
10
|
|
|
|
|
|
|
my @themes = grep $_ ne 'any', Acme::MetaSyntactic->themes; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub fake_meta { |
|
13
|
35
|
|
|
35
|
1
|
29874
|
my ($theme) = @_; |
|
14
|
35
|
|
66
|
|
|
81
|
$theme ||= fake_metatheme()->(); |
|
15
|
|
|
|
|
|
|
|
|
16
|
35
|
|
|
|
|
85
|
my $meta = Acme::MetaSyntactic->new; |
|
17
|
|
|
|
|
|
|
return sub { |
|
18
|
35
|
100
|
|
35
|
|
93
|
$meta->name( ref $theme eq 'CODE' ? $theme->() : $theme ); |
|
19
|
35
|
|
|
|
|
384
|
}; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub fake_metatheme { |
|
23
|
19
|
|
|
19
|
1
|
1582
|
return sub { $themes[ rand @themes ] }; |
|
|
12
|
|
|
12
|
|
2320
|
|
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub fake_metacategory { |
|
27
|
7
|
|
|
7
|
1
|
2256
|
my ($theme) = @_; |
|
28
|
7
|
|
66
|
|
|
29
|
$theme ||= fake_metatheme()->(); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return ref $theme eq 'CODE' |
|
31
|
|
|
|
|
|
|
? sub { |
|
32
|
5
|
|
|
5
|
|
16
|
my @categories = _categories( $theme->() ); |
|
33
|
5
|
|
|
|
|
30
|
$categories[ rand @categories ]; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
7
|
100
|
|
|
|
28
|
: do { |
|
36
|
5
|
|
|
|
|
11
|
my @categories = _categories($theme); |
|
37
|
5
|
|
|
6
|
|
95
|
sub { $categories[ rand @categories ] }; |
|
|
6
|
|
|
|
|
1669
|
|
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _categories { |
|
42
|
10
|
|
|
10
|
|
17
|
my ($theme) = @_; |
|
43
|
10
|
|
|
|
|
4602
|
require "Acme/MetaSyntactic/$theme.pm"; |
|
44
|
|
|
|
|
|
|
return ( |
|
45
|
|
|
|
|
|
|
$theme => map "$theme/$_", |
|
46
|
10
|
|
|
|
|
12030
|
eval { "Acme::MetaSyntactic::$theme"->categories } |
|
|
10
|
|
|
|
|
95
|
|
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Data::Fake::MetaSyntactic - Fake metasyntactic data generators |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Data::Fake::MetaSyntactic; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
fake_metatheme()->(); # foo, donmartin, weekdays, etc. |
|
63
|
|
|
|
|
|
|
fake_metacategory()->(); # foo/fr, donmartin, weekdays/nl, etc. |
|
64
|
|
|
|
|
|
|
fake_meta()->(); # titi, GING_GOYNG, vrijdag, etc. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This module provides fake data generators for L<Acme::MetaSyntactic>. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
All functions are exported by default. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 fake_meta |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$generator = fake_name( $theme ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Returns a generator that provides a randomly selected item from the |
|
79
|
|
|
|
|
|
|
given L<Acme::MetaSyntactic> theme. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The theme name can be given in the form C<theme/category> if the correspnding |
|
82
|
|
|
|
|
|
|
L<Acme::MetaSyntactic> theme supports categories. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
C<$theme> can be a code reference that returns a theme name when executed. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
If no C<$theme> is given, a random theme is picked for the generator |
|
87
|
|
|
|
|
|
|
among the installed ones. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 fake_metatheme |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$generator = fake_metatheme(); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns a generator that provides a random L<Acme::MetaSyntactic> theme name, |
|
94
|
|
|
|
|
|
|
among the installed ones. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 fake_metacategory |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$generator = fake_metacategory( $theme ); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns a generator that provides a random category from an installed |
|
101
|
|
|
|
|
|
|
L<Acme::MetaSyntactic> theme. The theme itself is a category of its own. |
|
102
|
|
|
|
|
|
|
The categories returned by the generator can be passed to L</fake_meta>. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
C<$theme> can be a code reference that returns a theme name when executed. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
If no C<$theme> is given, a random theme is picked for the generator |
|
107
|
|
|
|
|
|
|
among the installed ones. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over 4 |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Generate a random item from a given theme: |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$generator = fake_meta( $theme ); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Generate a random item from a randomly selected theme: |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$generator = fake_meta(); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Generate a random item from a different random theme each time: |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
$generator = fake_meta( fake_metatheme() ); |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
All themes have a default category. Since C<fake_metatheme()> returns |
|
132
|
|
|
|
|
|
|
a generator that only produces theme names, that implies the default |
|
133
|
|
|
|
|
|
|
category is always used in that case. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Generate a random item from a random category from a given theme: |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$generator = fake_meta( fake_metacategory( $theme ) ); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Generate a random item from a randomly selected theme, with |
|
144
|
|
|
|
|
|
|
a random category each time: |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$generator = fake_meta( fake_metacategory() ); |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Generate a random item from a different random theme/category each time: |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
$generator = fake_meta( fake_metacategory( fake_metatheme() ) ); |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=back |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 TRIVIA |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
IRC is one my source of inspiration (actually, the people on it). |
|
159
|
|
|
|
|
|
|
It seems L<Acme::MetaSyntactic> also inspires sillyness in people: |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
#perl-qa on 2015-02-03 (UTC times) |
|
162
|
|
|
|
|
|
|
04:23 <@xdg> BooK, I invite you to read this talk I gave and then contribute Data::Fake::MetaSyntactic. :-) http://tinyurl.com/pd5agr6 [ http://www.dagolden.com/wp-content/uploads/2009/04/Taking-Your-Perl-to-Eleven.pdf ] |
|
163
|
|
|
|
|
|
|
07:14 <@BooK> xdg: but I did Data::Faker::MetaSyntactic already!? |
|
164
|
|
|
|
|
|
|
07:35 <@BooK> ooh, different module |
|
165
|
|
|
|
|
|
|
08:03 <@BooK> xdg: I love it. will make the module |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L<Data::Fake>, L<Acme::MetaSyntactic>, L<Task::MetaSyntactic>. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Philippe Bruhat (BooK), <book@cpan.org>. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Copyright 2015 Philippe Bruhat (BooK), all rights reserved. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 LICENSE |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
182
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |