File Coverage

blib/lib/Acme/MetaSyntactic/any.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 9 10 90.0
pod 4 4 100.0
total 37 38 97.3


line stmt bran cond sub pod time code
1             package Acme::MetaSyntactic::any;
2 2     2   23440 use strict;
  2         4  
  2         78  
3 2     2   11 use List::Util 'shuffle';
  2         2  
  2         272  
4 2     2   479 use Acme::MetaSyntactic ();
  2         5  
  2         177  
5             our $VERSION = '1.000';
6              
7             our $Theme = 'any';
8              
9             sub import {
10             # export the metaany function
11 2     2   13 my $callpkg = caller;
12 2         6 my $meta = Acme::MetaSyntactic::any->new();
13 2     2   11 no strict 'refs';
  2         4  
  2         601  
14 2     2   9 *{"$callpkg\::metaany"} = sub { $meta->name( @_ ) };
  2         76  
  2         1578  
15             }
16              
17             sub name {
18 4     4 1 7 my $self = shift;
19             my $theme =
20 4         20 ( shuffle( grep { !/^(?:any|random)$/ } Acme::MetaSyntactic->themes() ) )[0];
  12         80  
21 4         52 $self->{meta}->name( $theme, @_ );
22             }
23              
24             sub new {
25 6     6 1 8 my $class = shift;
26              
27             # we need a full Acme::MetaSyntactic object, to support AMS::Locale
28 6         36 return bless { meta => Acme::MetaSyntactic->new( @_ ) }, $class;
29             }
30              
31 2     2 1 10 sub theme { $Theme };
32              
33       0 1   sub has_remotelist { };
34              
35             1;
36              
37             =encoding iso-8859-1
38              
39             =head1 NAME
40              
41             Acme::MetaSyntactic::any - Items from any theme
42              
43             =head1 DESCRIPTION
44              
45             This theme simply selects a theme at random from all available
46             themes, and returns names from it.
47              
48             The selection is done in such a manner that you'll see no repetition
49             in the items returned from a given theme, until all items from the
50             theme have been seen.
51              
52             =head1 METHODS
53              
54             =over 4
55              
56             =item new( @args )
57              
58             Create a new instance.
59              
60             The parameters will be used to create the underlying Acme::MetaSyntactic
61             object, and will be passed to the randomly chosen theme. This can be
62             useful for themes deriving from Acme::MetaSyntactic::Locale.
63              
64             =item name( $count )
65              
66             Implement the name() method for this class.
67              
68             =item theme()
69              
70             Return the theme name (C).
71              
72             =item has_remotelist()
73              
74             Always return false.
75              
76             =back
77              
78             =head1 CONTRIBUTOR
79              
80             Philippe Bruhat, upon request of Sébastien Aperghis-Tramoni.
81              
82             Introduced in Acme-MetaSyntactic version 0.12, published on March 7, 2005.
83              
84             Updated to conform with interface changes required by
85             C in version 0.49, published
86             on November 21, 2005.
87              
88             Received its own version number for Acme-MetaSyntactic version 1.000,
89             published on May 7, 2012.
90              
91             =head1 SEE ALSO
92              
93             L.
94              
95             =cut
96