lib/MojoMojo/Formatter/Emote.pm

filter: Statementstmt 84.6% 11 / 13 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 3 / 3 totaltotal 72.4% 21 / 29 CC 4 SCAR 10.5
CC
4
Cov
70%
format_content
4.5
module_loaded
2.1
BEGIN
1.0
CRAP 2.8
« lib/MojoMojo/Formatter/WikipediaLink.pm ↑ Summary lib/MojoMojo/Controller/Tag.pm »
1 package MojoMojo::Formatter::Emote;
2  
3 26 ▶eval "use Text::Emoticon::MSN";
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 my $eval_res = $@;
5  
6 =head2 module_loaded
7  
8 Return true if the module is loaded.
9  
10 =cut
11  
12 124 ▶sub module_loaded { $eval_res ? 0 : 1 }
Subroutine module_loaded: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$eval_res ? : 0 124 124
13  
14 26 our $VERSION = '0.01';
15  
16 =head1 NAME
17  
18 MojoMojo::Formatter::Emote - MSN Smileys in your text.
19  
20 =head1 DESCRIPTION
21  
22 This formatter transforms the full range of MSN Smileys into
23 bitmaps on your page, using L<Text::Emoticon::MSN>.
24  
25 =head1 METHODS
26  
27 =head2 format_content_order
28  
29 Format order can be 1-99. The Emote formatter runs on 95.
30  
31 =cut
32  
33 248 ▶sub format_content_order { 95 }
Subroutine format_content_order: called CC=1 SCAR=0.0
Pod documented
34  
35 =head2 format_content
36  
37 Calls the formatter. Takes a ref to the content as well as the
38 context object.
39  
40 =cut
41  
42 124 ▶sub format_content {
Subroutine format_content: called CC=3 SCAR=15.1
Pod documented
43 124 my ($class, $content, $c)=@_;
44 124 ▶ return unless $class->module_loaded && $c->pref('enable_emoticons');
Branch: 1 branch
BranchTrueFalseTotal
unless $class->module_loaded and $c->pref("enable_emoticons") 124 0 124
Condition33%1/3
$class->module_loaded and $c->pref("enable_emoticons")
!ll&&!rl&&r
01240
MC/DC0%0/2
$class->module_loaded and $c->pref("enable_emoticons")
$class->module_loaded $c->pref("enable_emoticons")
Truth table33%1/3
A and B
A= $class->module_loadedB= $c->pref("enable_emoticons")
ABresult
0X0
100
111
45 0 my $emoticon = Text::Emoticon::MSN->new(
46 imgbase => $c->req->base.'/.static/emote',
47 xhtml => 1, strict => 1
48 );
49 # Let textile handle the rest
50 0 $$content = $emoticon->filter( $$content );
51 }
52  
53 =head1 SEE ALSO
54  
55 L<MojoMojo>, L<Module::Pluggable::Ordered>, L<Text::Emoticon::MSN>
56  
57 =head1 AUTHORS
58  
59 Marcus Ramberg <mramberg@cpan.org>
60  
61 =head1 LICENSE
62  
63 This library is free software. You can redistribute it and/or modify
64 it under the same terms as Perl itself.
65  
66 =cut
67  
68 26 1;
« lib/MojoMojo/Formatter/WikipediaLink.pm ↑ Summary lib/MojoMojo/Controller/Tag.pm »