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