Translate.pm

filter: Statementstmt 54.2% 19 / 35 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 42.1% 27 / 64 CC 9 SCAR 39.3
CC
9
Cov
37%
said
90.0
help
2.0
BEGIN
1.0
CRAP 51.1
« Convert.pm ↑ Summary Spell.pm »
1 package Bot::BasicBot::Pluggable::Module::Translate;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Bot::BasicBot::Pluggable::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw(Bot::BasicBot::Pluggable::Module);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Locale::Language;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Lingua::Translate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Lingua::Translate::Babelfish;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 0 ▶sub said {
Subroutine said: not called CC=9 SCAR=45.0
Pod documented
13 0 my ($self, $mess, $pri) = @_;
14  
15 0 my $sentence = $mess->{body};
16 0 my $who = $mess->{who};
17  
18 0 ▶ return unless ($pri == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless $pri == 2 0 0 0
19  
20 0 my $to;
21 my $from;
22  
23 0 ▶ return unless ($sentence =~ s!\s*translate to (\w+)(?: from (\w+))?\s*!$to = lc($1); $from = lc($2) || 'english'; ""!ei);
Branch: 1 branch
BranchTrueFalseTotal
unless $sentence =~ s/\s*translate to (\w+)(?: from (\w+))?\s*/$to = lc $1; $from = lc $2 || "english"; "";/ie 0 0 0
Condition0%0/2
lc $2 || 'english'
l!l
00
MC/DC0%0/1
lc $2 || 'english'
lc $2
Truth table0%0/2
A
A= lc $2
Aresult
11
00
24  
25 0 ▶ return "I need a sentence to translate!" if $sentence =~ m!^\s*$!;
Branch: 1 branch
BranchTrueFalseTotal
if $sentence =~ /^\s*$/ 0 0 0
26  
27 0 ▶ my $to_code = (length($to) == 2)? $to : lc(language2code($to));
Branch: 1 branch
BranchTrueFalseTotal
length $to == 2 ? : 0 0 0
28 0 ▶ my $from_code = (length($from) == 2)? $from : lc(language2code($from));
Branch: 1 branch
BranchTrueFalseTotal
length $from == 2 ? : 0 0 0
29
30  
31 0 ▶ my $xl8r = Lingua::Translate->new(src => $from_code, dest => $to_code) ||
Condition0%0/2
'Lingua::Translate'->new('src', $from_code, 'dest', $to_code) || (return "Can't do $from_code to $to_code")
l!l
00
MC/DC0%0/1
'Lingua::Translate'->new('src', $from_code, 'dest', $to_code) || (return "Can't do $from_code to $to_code")
'Lingua::Translate'->new('src', $from_code, 'dest', $to_code)
Truth table0%0/2
A
A= 'Lingua::Translate'->new('src', $from_code, 'dest', $to_code)
Aresult
11
00
32 return "Can't do $from_code to $to_code";
33
34 0 ▶ my $return = $xl8r->translate($sentence) || return "Hrmm, I couldn't translate '$sentence'";
Condition0%0/2
$xl8r->translate($sentence) || (return "Hrmm, I couldn't translate '${sentence}'")
l!l
00
MC/DC0%0/1
$xl8r->translate($sentence) || (return "Hrmm, I couldn't translate '${sentence}'")
$xl8r->translate($sentence)
Truth table0%0/2
A
A= $xl8r->translate($sentence)
Aresult
11
00
35 0 return $return;
36
37  
38 }
39  
40 0 ▶sub help {
Subroutine help: not called CC=1 SCAR=6.9
Pod documented
41 0 return "translate to <language> [from <other language>] <phrase>";
42 }
43  
44 1 1;
45  
46 =head1 NAME
47  
48 Bot::BasicBot::Pluggable::Module::Translate - do language translations
49  
50 =head1 SYNOPSIS
51  
52  
53 =head1 IRC USAGE
54  
55 translate to <language> [from <other language>] <phrase>
56  
57 =head1 AUTHOR
58  
59 Simon Wistow, <simon@thegestalt.org>
60  
61 =head1 COPYRIGHT
62  
63 Copyright 2005, Simon Wistow
64  
65 Distributed under the same terms as Perl itself.
66  
67 =head1 SEE ALSO
68  
69  
70 =cut
71  
« Convert.pm ↑ Summary Spell.pm »