File Coverage

blib/lib/Net/Google/Code/Wiki/Comment.pm
Criterion Covered Total %
statement 22 22 100.0
branch 5 10 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 32 37 86.4


line stmt bran cond sub pod time code
1             package Net::Google::Code::Wiki::Comment;
2              
3 3     3   1762 use Any::Moose;
  3         7  
  3         31  
4 3     3   1612 use Params::Validate qw(:all);
  3         44  
  3         1633  
5             with 'Net::Google::Code::Role::HTMLTree';
6              
7             has 'content' => (
8             isa => 'Str',
9             is => 'rw',
10             );
11              
12             has 'author' => (
13             isa => 'Str',
14             is => 'rw',
15             );
16              
17             has 'date' => (
18             isa => 'Str',
19             is => 'rw',
20             );
21              
22             sub parse {
23 4     4 1 5 my $self = shift;
24 4         6 my $element = shift;
25 4         17 my $need_update = not blessed $element;
26 4 50       17 $element = $self->html_tree( html => $element ) unless blessed $element;
27              
28 4         21 my $author =
29             $element->look_down( class => 'author' )->find_by_tag_name('a')->as_text;
30 4         420 my $date = $element->look_down( class => 'date' )->attr('title');
31 4         290 my $content = $element->look_down( class => 'commentcontent' )->as_text;
32 4         404 $content =~ s/\s+$//; # remove trailing spaces
33              
34 4 50       42 $self->author( $author ) if $author;
35 4 50       27 $self->date( $date ) if $date;
36 4 50       28 $self->content( $content ) if $content;
37 4 50       14 $element->delete if $need_update;
38 4         15 return 1;
39             }
40              
41              
42 3     3   19 no Any::Moose;
  3         7  
  3         15  
43             __PACKAGE__->meta->make_immutable;
44              
45             1;
46             __END__