Acme-MetaSyntactic

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
    - phonetic (Dutch list by Abigail)
    - pm_groups
    - punctuation (update from wikipedia by Abigail)
    - yapc (new YAPC by Abigail)
 
0.90 2006-09-03 BOOK
    [NEW WEEKLY THEME 2006/09/04]
    - state_flowers (Abigail)
    [THEME UPDATES]
    - pause_id
    - yapc (Vienna and Houston were selected for 2007)
 
0.89 2006-08-28 BOOK
    [NEW WEEKLY THEME 2006/08/28]
    - pause_id
    [THEME UPDATES]
    - dilbert
    - planets (Pluto is not a planet anymore)
    - pornstars
 
0.88 2006-08-22 BOOK

Changes  view on Meta::CPAN

415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
    - pornstars (Sébastien Aperghis-Tramoni)
    [ENHANCEMENTS]
    - New behaviour Acme::MetaSyntactic::MultiList allows themes
      to be organised in categories and sub-categories. Usage is
      similar to Acme::MetaSyntactic::Locale (except that the
      constructor parameter is named 'category')
    - the first theme to use this feature is... pornstars
    - Acme::MetaSyntactic::RemoteList has a new method sources()
      that can report the source URLs for subcategories (for
      Acme::MetaSyntactic::RemoteList)
    - the meta script accepts a new --category option, to select
      a category within an Acme::MetaSyntactic::MultiList theme
    [TESTS]
    - Since 0.59, Acme::MetaSyntactic::RemoteList could accept
      serveral sources. This functionality is now fully tested.
    - tests for Acme::MetaSyntactic::MultiList
    - skip a few more tests if LWP::UserAgent is not installed
    [THEME UPDATE]
    - hhgg (updated a reference link)
 
0.68 2006-03-24 BOOK

Changes  view on Meta::CPAN

867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
0.13 2005-03-06 BOOK
    [NEW WEEKLY THEME 2005/03/14]
    - loremipsum (Jérôme Fenal)
 
0.12 2005-03-06 BOOK
    [ENHANCEMENTS]
    - To prevent endless growth of the Acme::MetaSyntactic module,
      and support various theme behaviours, support for behaviour
      classes has been added.
    - The first behaviour class is Acme::MetaSyntactic::List, which
      reproduces the previous behaviour of selecting a number
      of random items from a list, with no repetition until
      the list is exhausted.
    - The 17 existing themes have been converted to the new scheme.
    [USAGE]
    - Acme::MetaSyntactic is a dependency for a least one module!
      Praise Bot::MetaSyntactic, which is the core of the meta bot
      running on irc://irc.perl.org/perlfr
    [INCOMPATIBILITIES]
    - the API has changed a little:
      + Acme::MetaSyntactic does not has methods named after the

lib/Acme/MetaSyntactic.pm  view on Meta::CPAN

401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
=item C<Acme::MetaSyntactic::List>
 
The theme is a simple collection of names. An object instance will
return names at random from the list, and not repeat any until the list
is exhausted.
 
=item C<Acme::MetaSyntactic::Locale>
 
The theme is made of several collections of names, each associated with
a "language". The language is either passed as a constructor parameter,
extracted from the environment or a default is selected.
 
=item C<Acme::MetaSyntactic::MultiList>
 
The theme is made of several collections of names, each associated with
a "category". Categories can include sub-categories, etc, I<ad infinitum>
(or when disk space or memory is exhausted, whichever happens first).
The category is either passed as a constructor parameter or the default
value is selected.
 
=item C<Acme::MetaSyntactic::Alias>
 
The theme is simply an alias of another theme. All items are identical,
as the original behaviour. The only difference is the theme name.
 
=back
 
Over time, new theme "behaviours" will be added.

lib/Acme/MetaSyntactic/Locale.pm  view on Meta::CPAN

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
    zero uno due tre quattro cinque sei sette otto nove
    # names yi
    nul eyn tsvey dray fir finf zeks zibn akht nayn
 
=head1 DESCRIPTION
 
C<Acme::MetaSyntactic::Locale> is the base class for all themes that are
meant to return a random excerpt from a predefined list I<that depends
on the language>.
 
The language is selected at construction time from:
 
=over 4
 
=item 1.
 
the given C<lang> or C<category> parameter,
 
=item 2.
 
the current locale, as given by the environment variables C<LANGUAGE>,
C<LANG> or (under Win32) Win32::Locale.
 
=item 3.
 
the default language for the selected theme.
 
=back
 
The language codes should conform to the RFC 3066 and ISO 639 standard.
 
=head1 METHODS
 
Acme::MetaSyntactic::Locale offers several methods, so that the subclasses
are easy to write (see full example in L<SYNOPSIS>):

lib/Acme/MetaSyntactic/Locale.pm  view on Meta::CPAN

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Return $count names (default: C<1>).
 
Using C<0> will return the whole list in list context, and the size of the
list in scalar context (according to the C<lang> parameter passed to the
constructor).
 
=item lang()
 
=item category()
 
Return the selected language for this instance.
 
=item languages()
 
=item categories()
 
Return the languages supported by the theme.
 
=item theme()
 
Return the theme name.

lib/Acme/MetaSyntactic/MultiList.pm  view on Meta::CPAN

172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
    nine
    # names other
    zero one
 
=head1 DESCRIPTION
 
C<Acme::MetaSyntactic::MultiList> is the base class for all themes
that are meant to return a random excerpt from a predefined list
I<divided in categories>.
 
The category is selected at construction time from:
 
=over 4
 
=item 1.
 
the given C<category> parameter,
 
=item 2.
 
the default category for the selected theme.
 
=back
 
Categories and sub-categories are separated by a C</> character.
 
=head1 METHODS
 
Acme::MetaSyntactic::MultiList offers several methods, so that the subclasses
are easy to write (see full example in L<SYNOPSIS>):

lib/Acme/MetaSyntactic/MultiList.pm  view on Meta::CPAN

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
=item name( $count )
 
Return $count names (default: C<1>).
 
Using C<0> will return the whole list in list context, and the size of the
list in scalar context (according to the C<category> parameter passed to the
constructor).
 
=item category()
 
Return the selected category for this instance.
 
=item categories()
 
Return the categories supported by the theme (except C<:all>).
 
=item has_category( $category )
 
Return a boolean value indicating if the theme contains the given category.
 
=item theme()

lib/Acme/MetaSyntactic/RemoteList.pm  view on Meta::CPAN

299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
Return the data structure containing the source URLs. This can be quite
different depending on the class: a single scalar (URL), an array
reference (list of URLs) or a hash reference (each value being either
a scalar or an array reference) for themes that are subclasses of
C<Acme::MetaSyntactic::MultiList>.
 
=item sources( [ $category ] )
 
Return the list of source URL. The C<$category> parameter can be used
to select the sources for a sub-category of the theme (in the case of
C<Acme::MetaSyntactic::MultiList>).
 
C<$category> can be an array reference containing a list of categories.
 
=item extract( $content )
 
Return a list of items from the C<$content> string. C<$content> is
expected to be the content available at the URL given by C<source()>.
 
=back

lib/Acme/MetaSyntactic/any.pm  view on Meta::CPAN

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
1;
 
=encoding iso-8859-1
 
=head1 NAME
 
Acme::MetaSyntactic::any - Items from any theme
 
=head1 DESCRIPTION
 
This theme simply selects a theme at random from all available
themes, and returns names from it.
 
The selection is done in such a manner that you'll see no repetition
in the items returned from a given theme, until all items from the
theme have been seen.
 
=head1 METHODS
 
=over 4
 
=item new( @args )
 
Create a new instance.

script/meta  view on Meta::CPAN

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
Fetch the remote list (if available) and print only the differences betwen
the current list and the remote list (items are prefixed by C<+> and C<->).
 
Option added by Abigail.
 
The output of this option is affected by the I<--whitespace> option.
 
=item I<--category> category
 
Only select items in the given category (for C<Acme::MetaSyntactic::MultiList>
subclasses). If not given, use the default category.
 
Silently fallbacks to the default if the category doesn't exist.
 
Another way to ask for a specific category is to skip the I<--category>
option and directly ask for C<theme/category>. Note that you cannot use
both calling conventions simultaneously.
 
=back
 
=head2 Informative options
 
The program will exit if any of these options is selected.
However, these options can be combined.
 
=over 4
 
=item I<--themes>
 
Print the list of available themes.
 
=item I<--sources>

script/metafy  view on Meta::CPAN

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
B<This will definitely break any program!>
 
=item I<--in-place>
 
Force in-place edition
 
=back
 
=head2 Informative options
 
The program will exit if any of these options is selected.
However, these options can be combined.
 
=over 4
 
=item I<--themes>
 
Print the list of available themes.
 
=item I<--version>

t/31any.t  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use lib 't/lib';
use NoLang;
 
# "alter" the shuffle method
{
    no warnings;
    my ( $i, $j ) = ( 0, 0 );
    *List::Util::shuffle = sub { sort @_ };    # item selection
    *Acme::MetaSyntactic::any::shuffle =       # theme selection
        sub (@) { my @t = sort @_; push @t, shift @t for 1 .. $j; $j++; @t };
}
 
# compute the first 6 installed themes
my $meta  = Acme::MetaSyntactic->new();
my $count = my @themes = grep { ! /^any$/ } sort $meta->themes();
my $max = $count >= 6 ? 5 : $count - 1;
@themes = @themes[ 0 .. $max ];
 
# the test list is computed now because of cache issues



( run in 0.683 second using v1.01-cache-2.11-cpan-87723dcf8b7 )