lib/Horris/Connection/Plugin/Kspell.pm

filter: Statementstmt 41.9% 13 / 31 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 1 totaltotal 39.0% 16 / 41 CC 5 SCAR 21.2
CC
5
Cov
37%
irc_privmsg
12.0
_kspell
12.0
BEGIN
1.0
CRAP 8.3
« blib/lib/Horris.pm ↑ Summary blib/lib/App/Horris/CLI/Command/feed.pm »
1 package Horris::Connection::Plugin::Kspell;
2 # ABSTRACT: KoreanSpeller Plugin on Horris
3  
4  
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Encode qw/encode decode/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use WebService::KoreanSpeller;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 extends 'Horris::Connection::Plugin';
9 1 with 'MooseX::Role::Pluggable::Plugin';
10  
11 0 ▶sub irc_privmsg {
Subroutine irc_privmsg: not called CC=3 SCAR=24.8
Pod undocumented
12 0 my ($self, $message) = @_;
13 0 my @msg = $self->_kspell($message);
14  
15 0 ▶ return unless @msg;
Branch: 1 branch
BranchTrueFalseTotal
unless @msg 0 0 0
16  
17 0 for (@msg) {
18 0 $self->connection->irc_privmsg({
19 channel => $message->channel,
20 message => $_
21 });
22 }
23  
24 0 return $self->pass;
25 }
26  
27 0 ▶sub _kspell {
Subroutine _kspell: not called CC=3 SCAR=24.8
28 0 my ($self, $message) = @_;
29 0 my $raw = $message->message;
30  
31 0 ▶ unless ($raw =~ m/^kspell/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raw =~ /^kspell/i) 0 0 0
32 0 return undef;
33 }
34  
35 0 $raw =~ s/^kspell[\S]*\s+//i;
36 0 $raw = decode('utf8', $raw);
37 0 my $checker = WebService::KoreanSpeller->new( text=> $raw );
38 0 my @results = $checker->spellcheck;
39 0 my @correct;
40 0 for my $item (@results) {
41 0 push @correct, encode('utf8', $item->{incorrect} . ' -> ' . $item->{correct});
42 }
43  
44 0 return @correct;
45 }
46  
47 1 __PACKAGE__->meta->make_immutable;
48  
49 1 1;
50  
51 __END__
« blib/lib/Horris.pm ↑ Summary blib/lib/App/Horris/CLI/Command/feed.pm »