| 1 | package Net::Google::Code::Wiki; | ||||||||||||||||||||||||||||
| 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::TypicalRoles'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | has 'project' => ( | |||||||||||||||||||||||||||
| 8 | isa => 'Str', | ||||||||||||||||||||||||||||
| 9 | is => 'rw', | ||||||||||||||||||||||||||||
| 10 | ); | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | has 'name' => ( | |||||||||||||||||||||||||||
| 13 | isa => 'Str', | ||||||||||||||||||||||||||||
| 14 | is => 'rw', | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 3 | has 'source' => ( | |||||||||||||||||||||||||||
| 18 | isa => 'Str', | ||||||||||||||||||||||||||||
| 19 | is => 'rw', | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 3 | has 'content' => ( | |||||||||||||||||||||||||||
| 23 | isa => 'Str', | ||||||||||||||||||||||||||||
| 24 | is => 'rw', | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 3 | has 'updated' => ( | |||||||||||||||||||||||||||
| 28 | isa => 'Str', | ||||||||||||||||||||||||||||
| 29 | is => 'rw', | ||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 3 | has 'updated_by' => ( | |||||||||||||||||||||||||||
| 33 | isa => 'Str', | ||||||||||||||||||||||||||||
| 34 | is => 'rw', | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 3 | has 'labels' => ( | |||||||||||||||||||||||||||
| 38 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||
| 39 | is => 'rw', | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 3 | has 'summary' => ( | |||||||||||||||||||||||||||
| 43 | isa => 'Str', | ||||||||||||||||||||||||||||
| 44 | is => 'rw', | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 3 | has 'comments' => ( | |||||||||||||||||||||||||||
| 48 | isa => 'ArrayRef[Net::Google::Code::Wiki::Comment]', | ||||||||||||||||||||||||||||
| 49 | is => 'rw', | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 2 | ▶ | sub load_source { | ||||||||||||||||||||||||||
|
Subroutine
load_source: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 54 | 2 | ▶ | die "current object doesn't have name" unless $self->name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 2 | my $source = | |||||||||||||||||||||||||||
| 56 | $self->fetch( $self->base_svn_url . 'wiki/' . $self->name . '.wiki' ); | ||||||||||||||||||||||||||||
| 57 | 2 | $self->source($source); | |||||||||||||||||||||||||||
| 58 | 2 | return $self->parse_source; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | ▶ | sub parse_source { | ||||||||||||||||||||||||||
|
Subroutine
parse_source: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | 2 | my @meta = grep { /^#/ } split /\n/, $self->source; | |||||||||||||||||||||||||||
| 64 | 2 | for my $meta (@meta) { | |||||||||||||||||||||||||||
| 65 | 4 | chomp $meta; | |||||||||||||||||||||||||||
| 66 | 4 | ▶ | if ( $meta =~ /summary\s+(.*)/ ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 67 | 2 | $self->summary($1); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | elsif ( $meta =~ /labels\s+(.*)/ ) { | ||||||||||||||||||||||||||||
| 70 | 2 | my @labels = split /,\s*/, $1; | |||||||||||||||||||||||||||
| 71 | 2 | $self->labels( \@labels ); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=5 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 78 | 2 | ▶ | my $name = shift || $self->name; | ||||||||||||||||||||||||||
|
Condition33%1/3
shift() || $self->name
MC/DC0%0/2
shift() || $self->name
shift()
$self->name
Truth table33%1/3
A || B
A= shift()B= $self->name
| |||||||||||||||||||||||||||||
| 79 | 2 | ▶ | die "current object doesn't have name and load() is not passed a name either" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | unless $name; | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # http://code.google.com/p/net-google-code/wiki/TestPage | ||||||||||||||||||||||||||||
| 83 | 2 | my $content = $self->fetch( $self->base_url . 'wiki/' . $name ); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 2 | ▶ | $self->name($name) unless $self->name && $self->name eq $name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->name and $self->name eq $name
MC/DC0%0/2
$self->name and $self->name eq $name
$self->name
$self->name eq $name
Truth table33%1/3
A and B
A= $self->nameB= $self->name eq $name
| |||||||||||||||||||||||||||||
| 86 | 2 | $self->load_source; | |||||||||||||||||||||||||||
| 87 | 2 | return $self->parse($content); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | 2 | my $tree = shift; | |||||||||||||||||||||||||||
| 93 | 2 | ▶ | $tree = $self->html_tree( html => $tree ) unless blessed $tree; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | my $wiki = $tree->look_down( id => 'wikimaincol' ); | |||||||||||||||||||||||||||
| 96 | 2 | my $updated = | |||||||||||||||||||||||||||
| 97 | $wiki->find_by_tag_name('td')->find_by_tag_name('span')->attr('title'); | ||||||||||||||||||||||||||||
| 98 | 2 | my $updated_by = | |||||||||||||||||||||||||||
| 99 | $wiki->find_by_tag_name('td')->find_by_tag_name('a')->as_text; | ||||||||||||||||||||||||||||
| 100 | 2 | ▶ | $self->updated($updated) if $updated; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 2 | ▶ | $self->updated_by($updated_by) if $updated_by; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 2 | $self->content( $tree->content_array_ref->[-1]->as_HTML ); | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | my @comments = (); | |||||||||||||||||||||||||||
| 106 | 2 | my @comments_element = $tree->look_down( class => 'artifactcomment' ); | |||||||||||||||||||||||||||
| 107 | 2 | for my $element (@comments_element) { | |||||||||||||||||||||||||||
| 108 | 4 | ▶ | next unless $element->look_down( class => 'commentcontent' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 4 | require Net::Google::Code::Wiki::Comment; | |||||||||||||||||||||||||||
| 110 | 4 | my $comment = Net::Google::Code::Wiki::Comment->new; | |||||||||||||||||||||||||||
| 111 | 4 | $comment->parse($element); | |||||||||||||||||||||||||||
| 112 | 4 | push @comments, $comment; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 2 | $self->comments( \@comments ); | |||||||||||||||||||||||||||
| 115 | 2 | $tree->delete; | |||||||||||||||||||||||||||
| 116 | 2 | return 1; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 3 | ▶ | no Any::Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 120 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 3 | 1; | |||||||||||||||||||||||||||
| 123 | __END__ | ||||||||||||||||||||||||||||