blib/lib/Kwiki/Widgets/RandomQuote.pm

filter: Statementstmt 64.0% 16 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 60.6% 20 / 33 CC 1 SCAR 2.9
CC
1
Cov
64%
register
2.0
show
2.0
BEGIN
1.0
CRAP 1.3
↑ Summary
1 package Kwiki::Widgets::RandomQuote;
2 1 ▶use Kwiki::Plugin -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use mixin 'Kwiki::Installer';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.01';
5  
6 1 const class_id => 'widgets_random_quote';
7 1 const class_title => 'Random Qoute';
8  
9 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
10 0 my $registry = shift;
11 0 $registry->add(widget => 'random_quote',
12 template => 'widgets_random_quote.html');
13 }
14  
15 # This could be a really slow function.
16 0 ▶sub show {
Subroutine show: not called CC=1 SCAR=6.9
Pod undocumented
17 0 my @pages = $self->pages->all_ids_newest_first;
18 0 my $page = $self->pages->new_page($pages[int(rand(@pages))]);
19 0 my @paragraphs = split(/\n+/,$page->content);
20 0 my $choosen = @paragraphs[int(rand(@paragraphs))];
21 0 return $self->hub->formatter->text_to_html($choosen);
22 }
23  
24 1 __DATA__
↑ Summary