lib/IRC/Bot/Hangman/WordList.pm

filter: Statementstmt 50.0% 15 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 47.7% 21 / 44 CC 4 SCAR 17.5
CC
4
Cov
42%
word_list
12.0
load
6.0
BEGIN
1.0
CRAP 5.8
« lib/IRC/Bot/Hangman/Command.pm ↑ Summary lib/IRC/Bot/Hangman/Command/Eliza.pm »
1 =head1 NAME
2  
3 IRC::Bot::Hangman::WordList - Word list plugin engine
4  
5 =head1 SYNOPSIS
6  
7 use IRC::Bot::Hangman::WordList;
8 $words = IRC::Bot::Hangman::WordList->load( 'too_easy' );
9 print $words->[3];
10  
11 =head1 DESCRIPTION
12  
13 This module loads the word list plugins
14 and provide a list based on a name
15  
16 =cut
17  
18 package IRC::Bot::Hangman::WordList;
19 1 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Carp qw( carp croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Module::Find qw( useall );
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 our %WORDLISTS = map { $_->name => $_ } useall( __PACKAGE__ );
25  
26  
27  
28 =head2 load( plugin name )
29  
30 Returns a word list loaded
31 from a specific plugin
32  
33 =cut
34  
35 0 ▶sub load {
Subroutine load: not called CC=2 SCAR=17.9
Pod documented
36 0 my $class = shift;
37 0 my $name = shift;
38 0 my $module = $WORDLISTS{$name};
39 0 ▶ unless ($module) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($module) 0 0 0
40 0 carp "$name is not a registered word list, try " . join(' or ', keys %WORDLISTS);
41 0 return;
42 }
43  
44 0 $class->word_list( $module );
45 }
46  
47  
48 =head2 word_list
49  
50 Loads the word list
51  
52 =cut
53  
54 0 ▶sub word_list {
Subroutine word_list: not called CC=3 SCAR=24.8
Pod documented
55 0 my $self = shift;
56 0 my $module = shift;
57 0 my $fh = "${module}::DATA";
58 0 my @words;
59 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
60 0 chomp;
61 0 ▶ push @words, $_ if $_;
Branch: 1 branch
BranchTrueFalseTotal
if $_ 0 0 0
62 }
63 0 \@words;
64 }
65  
66  
67 1 1;
68  
69  
70 =head1 AUTHOR
71  
72 Pierre Denis <pierre@itrelease.net>
73  
74 http://www.itrelease.net/
75  
76 =head1 COPYRIGHT
77  
78 Copyright 2005 IT Release Ltd - All Rights Reserved.
79  
80 This module is released under the same license as Perl itself.
81  
82 =cut
« lib/IRC/Bot/Hangman/Command.pm ↑ Summary lib/IRC/Bot/Hangman/Command/Eliza.pm »