File Coverage

blib/lib/Bootylicious/Comment.pm
Criterion Covered Total %
statement 30 35 85.7
branch 2 2 100.0
condition n/a
subroutine 11 13 84.6
pod 1 7 14.2
total 44 57 77.1


line stmt bran cond sub pod time code
1             package Bootylicious::Comment;
2              
3 13     13   563 use strict;
  13         20  
  13         429  
4 13     13   55 use warnings;
  13         16  
  13         357  
5              
6 13     13   57 use base 'Bootylicious::Document';
  13         17  
  13         1192  
7              
8 13     13   437 use Bootylicious::Article;
  13         31  
  13         127  
9 13     13   338 use Bootylicious::Timestamp;
  13         24  
  13         94  
10 13     13   271 use File::stat;
  13         20  
  13         99  
11              
12             sub new {
13 30     30 1 944 my $self = shift->SUPER::new;
14 30         207 my %params = @_;
15              
16 30         65 foreach my $method (qw/author email url content/) {
17 120 100       316 $self->$method($params{$method}) if defined $params{$method};
18             }
19              
20 30         103 return $self;
21             }
22              
23             sub created {
24 60     60 0 265 Bootylicious::Timestamp->new(epoch => stat(shift->path)->mtime);
25             }
26 5     5 0 15 sub email { shift->metadata(email => @_) }
27 0     0 0 0 sub url { shift->metadata(url =>) }
28              
29 10     10 0 364 sub content { shift->inner(content => @_) }
30              
31             sub number {
32 2     2 0 5 my $self = shift;
33              
34 2         10 my $path = $self->path;
35              
36 2         32 my ($number) = ($path =~ m/-(\d+)$/);
37              
38 2         16 return $number;
39             }
40              
41             sub article {
42 0     0 0   my $self = shift;
43              
44 0           my $path = $self->path;
45 0           $path =~ s/\.comment-(\d+)$//;
46              
47 0           return Bootylicious::Article->new(path => $path);
48             }
49              
50             1;