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