File Coverage

blib/lib/Kwiki/PageTemperature.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package Kwiki::PageTemperature;
2 1     1   70502 use Kwiki::Plugin '-Base';
  0            
  0            
3             use mixin 'Kwiki::Installer';
4              
5             const class_id => 'page_temperature';
6             const time_period_minutes => 60 * 24 * 60;
7             const color_divisor => (60 * 24 * 60) / 255;
8              
9             our $VERSION = '0.01';
10              
11             sub register {
12             my $registry = shift;
13             $registry->add(status => 'page_temperature',
14             template => 'page_temperature.html',
15             show_for => 'display',
16             );
17             }
18              
19             sub page_age {
20             my $page = $self->hub->pages->current;
21             $page->age_in_minutes < $self->time_period_minutes
22             ? $page->age_in_minutes
23             : $self->time_period_minutes;
24             }
25              
26             sub red {
27             int(($self->time_period_minutes - $self->page_age)/$self->color_divisor);
28             }
29              
30             sub blue {
31             int($self->page_age/$self->color_divisor);
32             }
33              
34             __DATA__