view release on metacpan or search on metacpan
- flip the executable bit on script/metafy
1.009 2013-08-12 BOOK
[ENHANCEMENTS]
- Test::MetaSyntactic now enforces stricter rules on themes:
a theme will fail if it is empty, or if it returns the empty
string as a name
1.008 2013-01-13 BOOK
[ENHANCEMENTS]
- the load_data() method now closes the DATA filehandle when done.
Many themes use __DATA__ to store their names, which could cause
problems ("Too many open files"), when loading a lot of themes.
(see http://www.cpantesters.org/cpan/report/25449004)
1.007 2012-10-08 BOOK
[ENHANCEMENTS]
- Test::MetaSyntactic now supports RELEASE_TESTING
(and keeps supporting AUTHOR_TESTING for backwards compatibility)
1.006 2012-08-26 BOOK
[ENHANCEMENTS]
- add support for end-of-line comments in the __DATA__ section
(in the load_data() method)
1.005 2012-07-24 BOOK
[TESTS]
- fix t/31any.t to work with themes having very few items
1.004 2012-06-28 BOOK
[ENHANCEMENTS]
- add support for POST request in Acme::MetaSyntactic::RemoteList
[TICKET CLOSED]
- #16256 on rt.cpan.org (David Landgren provided 11 new beverages
and corrected a typo in AMS::booze)
0.50 2005-11-26 BOOK
[NEW WEEKLY THEME 2005/11/28]
- unicode
[ENHANCEMENTS]
- Acme::MetaSyntactic::List and Acme::MetaSyntactic::Locale-based
theme can now supply their lists to __PACKAGE__->init(), instead
of storing them in __DATA__. The data format must be the same
as the one that load_data() returns.
[FILE UPDATE]
- Oops. The DATES file was not listed in the MANIFEST file,
and therefore not included in version 0.49.
- DATES now lists all planned themes for 2005.
0.49 2005-11-20 BOOK
[NEW WEEKLY THEME 2005/11/21]
- pm_groups
[THEME UPDATES]
0.04 2005-01-15 BOOK
- Correct a typo in Markefile.PL (thanks to Mike Castle)
- The method themes() returns the sorted list of available themes
- New themes:
+ crypto (anonymous)
+ simpsons
- closed ticket #9725 on rt.cpan.org (wishlist)
0.03 2005-01-14 BOOK
- Documentation patches
- Put everything in __DATA__ to make adding new themes easier
- New themes (the names in parentheses indicate who suggested
the theme and/or provided the list):
+ dilbert (Sébastien Aperghis-Tramoni)
+ donmartin (Vahe Sarkissian)
+ pynchon (David Landgren)
+ robin
- closed ticket #9731 on rt.cpan.org (discussion)
0.02 2005-01-14 BOOK
- The module now exports all meta* functions.
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
lib/Acme/MetaSyntactic.pm view on Meta::CPAN
eval $code;
$META{$theme} = 1; # loaded
# export the metatheme() function
no strict 'refs';
my $callpkg = caller;
*{"$callpkg\::meta$theme"} = sub { $meta->name( $theme, @_ ) };
}
}
# load the content of __DATA__ into a structure
# this class method is used by the other Acme::MetaSyntactic classes
sub load_data {
my ($class, $theme ) = @_;
my $data = {};
my $fh;
{ no strict 'refs'; $fh = *{"$theme\::DATA"}{IO}; }
my $item;
my @items;
$$item = "";
{
local $_;
while (<$fh>) {
/^#\s*(\w+.*)$/ && do {
push @items, $item;
lib/Acme/MetaSyntactic.pm view on Meta::CPAN
my @keys = split m!\s+|\s*/\s*!, $1;
$last = $item, $item = $item->{$_} ||= {} for @keys;
$item = \( $last->{ $keys[-1] } = "" );
next;
};
s/#.*//; # remove end-of-line comments
$$item .= $_;
}
}
# avoid leaving all the DATA handles open
close $fh;
# clean up the items
for( @items, $item ) {
$$_ =~ s/\A\s*//;
$$_ =~ s/\s*\z//;
$$_ =~ s/\s+/ /g;
}
return $data;
}
lib/Acme/MetaSyntactic.pm view on Meta::CPAN
This class method adds a new theme to the list. It also creates and
exports all the convenience functions (C<metaI<theme>()>) needed.
Note that this method can only create themes that implement the
C<Acme::MetaSyntactic::List> behaviour.
=item load_data( $data )
This method is used by the "behaviour" classes (such as
C<Acme::MetaSyntactic::List>) to read the content of the C<DATA>
filehandle and fetch the theme data.
The format is very simple. If the C<DATA> filehandle contains the
following data:
# names
bam zowie plonk
powie kapow # comment
# multi level
abc def
# empty
# multi lingual
fr de
lib/Acme/MetaSyntactic.pm view on Meta::CPAN
lingual => "fr de",
},
empty => ""
}
For example, C<Acme::MetaSyntactic::List> uses the single parameter C<names>
to fetch the lists of names for creating its subclasses.
The C<init()> method in all "behaviour" classes will also accept an optional
C<$data> hashref and if it provided, will use it instead of reading the
C<__DATA__> section of the module. The actual structure of the hashref
depends on the C<Acme::MetaSyntactic::> class.
=back
Convenience methods also exists for all the themes. The methods are named
after the theme. They are exported only when the theme is actually used
or when it appear in the C<Acme::MetaSyntactic> import list. The first
imported theme is the default, used by the C<metaname()> function.
=head1 EXPORTS
lib/Acme/MetaSyntactic/Alias.pm view on Meta::CPAN
=head1 NAME
Acme::MetaSyntactic::bonk - The bonk theme
=head1 DESCRIPTION
This theme is just an alias of the C<batman> theme.
=cut
# no __DATA__ section required!
=head1 DESCRIPTION
C<Acme::MetaSyntactic::Alias> is the base class for any themes that is
simply an alias of another theme.
=head1 METHOD
Acme::MetaSyntactic::Alias defines a single method, C<init()> that
make aliases very easy to write (see the full example in L<SYNOPSIS>):
lib/Acme/MetaSyntactic/List.pm view on Meta::CPAN
=head1 NAME
Acme::MetaSyntactic::beatles - The fab four theme
=head1 DESCRIPTION
Ladies and gentlemen, I<The Beatles>. I<(hysteric cries)>
=cut
__DATA__
# names
john paul
george ringo
=head1 DESCRIPTION
C<Acme::MetaSyntactic::List> is the base class for all themes that are
meant to return a random excerpt from a predefined list.
=head1 METHOD
lib/Acme/MetaSyntactic/List.pm view on Meta::CPAN
=over 4
=item new()
The constructor of a single instance. An instance will not repeat items
until the list is exhausted.
=item init()
init() must be called when the subclass is loaded, so as to read the
__DATA__ section and fully initialise it.
=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.
=item theme()
lib/Acme/MetaSyntactic/Locale.pm view on Meta::CPAN
=head1 NAME
Acme::MetaSyntactic::digits - The numbers theme
=head1 DESCRIPTION
You can count on this module. Almost.
=cut
__DATA__
# default
en
# names en
zero one two three four five six seven eight nine
# names fr
zero un deux trois quatre cinq six sept huit neuf
# names it
zero uno due tre quattro cinque sei sette otto nove
# names yi
nul eyn tsvey dray fir finf zeks zibn akht nayn
lib/Acme/MetaSyntactic/Locale.pm view on Meta::CPAN
C<Win32::Locale>).
POSIX locales are defined as C<language[_territory][.codeset][@modifier]>.
If the specific territory is not supported, C<Acme::MetaSyntactic::Locale>
will use the language, and if the language isn't supported either,
the default is used.
=item init()
init() must be called when the subclass is loaded, so as to read the
__DATA__ section and fully initialise it.
=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<lang> parameter passed to the
constructor).
=item lang()
lib/Acme/MetaSyntactic/MultiList.pm view on Meta::CPAN
=head1 NAME
Acme::MetaSyntactic::digits - The numbers theme
=head1 DESCRIPTION
You can count on this module. Almost.
=cut
__DATA__
# default
:all
# names primes even
two
# names primes odd
three five seven
# names composites even
four six eight
# names composites odd
nine
lib/Acme/MetaSyntactic/MultiList.pm view on Meta::CPAN
$meta = Acme::MetaSyntactic::digits->new( category => ':all' );
If no C<category> parameter is given, C<Acme::MetaSyntactic::MultiList>
will use the class default. If the class doesn't define a default,
then C<:all> is used.
=item init()
init() must be called when the subclass is loaded, so as to read the
__DATA__ section and fully initialise it.
=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()
lib/Acme/MetaSyntactic/foo.pm view on Meta::CPAN
used by Dutch programmers to fill the roles of I<foo>, I<bar>, and I<baz>.
=back
=head1 SEE ALSO
L<Acme::MetaSyntactic>, L<Acme::MetaSyntactic::Locale>.
=cut
__DATA__
# default
en
# names en
foo bar baz foobar fubar qux quux corge grault
garply waldo fred plugh xyzzy thud
# names fr
toto titi tata tutu pipo
bidon test1 test2 test3
truc chose machin chouette bidule
# names nl
lib/Test/MetaSyntactic.pm view on Meta::CPAN
$tb->diag("Names too long: @failed") if @failed;
}
}
# t/24data.t
sub subtest_data {
my ( $theme, $file ) = @_;
$file = '' if !defined $file;
_check_file_lines(
$theme, $file,
"__DATA__ section for %s",
sub {
my @lines;
my $in_data;
for my $line (@_) {
$in_data++ if $line =~ /^__DATA__$/;
next if !$in_data;
push @lines, $line
if /^#/ && !/^# ?(?:names(?: +[-\w]+)*|default)\s*$/;
}
return @lines;
}
);
}
sub subtest_version {
lib/Test/MetaSyntactic.pm view on Meta::CPAN
Checks that each metasyntactic name in the theme is a valid Perl
variable name.
=head2 subtest_length( $theme )
Checks that each name in the theme has valid length.
=head2 subtest_data( $theme, $source )
Checks that the C<__DATA__> section (if any) of the theme source is
properly formatted.
=head2 subtest_import( $theme )
Checks that the exported C<meta$theme> function returns an item from
C<$theme>.
=head2 subtest_noimport( $theme )
Checks that C<use Acme::MetaSyntactic::I<$theme> ()> does not export
},
long =>
{ chain => { empty => '', not => { empty => 'zlonk powie' } } },
now => {
test => {
the =>
{ slash => { too => 'zamm crr_aaack whamm clank boff' } }
}
},
},
"read DATA correctly"
);
__DATA__
# foo
bar
# names en
name
on 3
lines
# long chain empty
# long chain not empty
zlonk powie
t/32multi.t view on Meta::CPAN
ok( $meta->has_category('fr/lyon'), "instance has 'fr/lyon'" );
ok( !$meta->has_category('fr/rennes'), "instance hasn't 'fr/rennes'" );
}
package Acme::MetaSyntactic::mongers;
use Acme::MetaSyntactic::MultiList;
our @ISA = ('Acme::MetaSyntactic::MultiList');
__PACKAGE__->init();
1;
__DATA__
# default
fr/lyon
# names fr paris
grinder lacravate echo book
# names fr lyon perrache
book
# names fr lyon ailleurs
jq dm stomakc
# names fr marseille
maddingue arhuman
t/33locale_territory.t view on Meta::CPAN
$tests{$t}, "$t => @{[$meta->lang]}" );
}
}
package Acme::MetaSyntactic::test_ams_digits;
use Acme::MetaSyntactic::Locale;
our @ISA = ('Acme::MetaSyntactic::Locale');
__PACKAGE__->init();
1;
__DATA__
# default
en
# names en
seventy
# names fr fr
soixante_dix
# names fr be
septante
plan('tests', 7);
is( $Acme::MetaSyntactic::yeye::Default, 'chats_sauvages', "Default category");
is( $Acme::MetaSyntactic::yeye::MultiList{idole_des_jeunes}[0], 'Jean_Philippe', 'Christian name of idole des jeunes');
is( $Acme::MetaSyntactic::yeye::MultiList{idole_des_jeunes}[1], 'Smet', 'Surname of idole des jeunes');
is( $Acme::MetaSyntactic::yeye::MultiList{chaussettes_noires}[0], 'Claude', 'Christian name of the singer of chaussettes noires');
is( $Acme::MetaSyntactic::yeye::MultiList{chaussettes_noires}[1], 'Moine', 'Surname of the singer of chaussettes noires');
is( $Acme::MetaSyntactic::yeye::MultiList{chats_sauvages}[0], 'Herve', 'Christian name of the singer of chats sauvages');
is( $Acme::MetaSyntactic::yeye::MultiList{chats_sauvages}[1], 'Fornieri', 'Surname of the singer of chats sauvages');
package Acme::MetaSyntactic::yeye;
__DATA__
# default
chaussettes_noires
# names idole_des_jeunes
Johnny Halliday
# names chaussettes_noires
Eddy Mitchell
# names chats_sauvages
Dick Rivers
t/35remote.t view on Meta::CPAN
map { Acme::MetaSyntactic::RemoteList::tr_nonword($_) }
map { Acme::MetaSyntactic::RemoteList::tr_accent($_) }
$content =~ /^\* (.*?)\s*$/gm;
return @items;
},
);
__PACKAGE__->init();
1;
__DATA__
# names
bonk clank_est eee_yow swoosh urkk wham_eth z_zwap
t/35remote2.t view on Meta::CPAN
map { Acme::MetaSyntactic::RemoteList::tr_nonword($_) }
map { Acme::MetaSyntactic::RemoteList::tr_accent($_) }
$content =~ /^\* (.*?)\s*$/gm;
return @items;
},
);
__PACKAGE__->init();
1;
__DATA__
# names
bonk clank_est eee_yow swoosh urkk wham_eth z_zwap
t/lib/Acme/MetaSyntactic/test_ams_list.pm view on Meta::CPAN
package Acme::MetaSyntactic::test_ams_list;
use strict;
use Acme::MetaSyntactic::List;
our @ISA = qw( Acme::MetaSyntactic::List );
__PACKAGE__->init();
1;
__DATA__
# names
John Paul George Ringo
t/lib/Acme/MetaSyntactic/test_ams_locale.pm view on Meta::CPAN
package Acme::MetaSyntactic::test_ams_locale;
use strict;
use Acme::MetaSyntactic::Locale;
our @ISA = qw( Acme::MetaSyntactic::Locale );
__PACKAGE__->init();
1;
__DATA__
# default
fr
# names en
zero one two three four five six seven eight nine
# names fr
zero un deux trois quatre cinq six sept huit neuf
# names it
zero uno due tre quattro cinque sei sette otto nove
# names yi
nul eyn tsvey dray fir finf zeks zibn akht nayn
t/lib/Acme/MetaSyntactic/test_ams_remote.pm view on Meta::CPAN
use Acme::MetaSyntactic::List;
our @ISA = qw( Acme::MetaSyntactic::List );
__PACKAGE__->init();
our %Remote = (
source => 'http://www.perdu.com/',
);
1;
__DATA__
# names
Vous Etes Perdu
Pas de panique on va vous aider