| 1 | package Net::Google::Code; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use Any::Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 6 | with 'Net::Google::Code::TypicalRoles'; | |||||||||||||
| 5 | 6 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 6 | our $VERSION = '0.19'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | 6 | has 'project' => ( | |||||||||||||
| 10 | isa => 'Str', | ||||||||||||||
| 11 | is => 'rw', | ||||||||||||||
| 12 | ); | ||||||||||||||
| 13 | |||||||||||||||
| 14 | 6 | has 'labels' => ( | |||||||||||||
| 15 | isa => 'ArrayRef', | ||||||||||||||
| 16 | is => 'rw', | ||||||||||||||
| 17 | ); | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 6 | has 'owners' => ( | |||||||||||||
| 20 | isa => 'ArrayRef', | ||||||||||||||
| 21 | is => 'rw', | ||||||||||||||
| 22 | ); | ||||||||||||||
| 23 | |||||||||||||||
| 24 | 6 | has 'members' => ( | |||||||||||||
| 25 | isa => 'ArrayRef', | ||||||||||||||
| 26 | is => 'rw', | ||||||||||||||
| 27 | ); | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 6 | has 'summary' => ( | |||||||||||||
| 30 | isa => 'Str', | ||||||||||||||
| 31 | is => 'rw', | ||||||||||||||
| 32 | ); | ||||||||||||||
| 33 | |||||||||||||||
| 34 | 6 | has 'description' => ( | |||||||||||||
| 35 | isa => 'Str', | ||||||||||||||
| 36 | is => 'rw', | ||||||||||||||
| 37 | ); | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 6 | has 'issues' => ( | |||||||||||||
| 40 | isa => 'ArrayRef[Net::Google::Code::Issue]', | ||||||||||||||
| 41 | is => 'rw', | ||||||||||||||
| 42 | ); | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 6 | has 'downloads' => ( | |||||||||||||
| 45 | isa => 'ArrayRef[Net::Google::Code::Download]', | ||||||||||||||
| 46 | is => 'rw', | ||||||||||||||
| 47 | ); | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 6 | has 'wikis' => ( | |||||||||||||
| 50 | isa => 'ArrayRef[Net::Google::Code::Wiki]', | ||||||||||||||
| 51 | is => 'rw', | ||||||||||||||
| 52 | ); | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 1 | ▶ | sub download { | ||||||||||||
|
Subroutine
download: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||
| 55 | 1 | my $self = shift; | |||||||||||||
| 56 | 1 | require Net::Google::Code::Download; | |||||||||||||
| 57 | 1 | ▶ | return Net::Google::Code::Download->new( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 58 | project => $self->project, | ||||||||||||||
| 59 | $self->email ? ( email => $self->email ) : (), | ||||||||||||||
| 60 | $self->password ? ( password => $self->password ) : (), | ||||||||||||||
| 61 | @_ | ||||||||||||||
| 62 | ); | ||||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | 1 | ▶ | sub issue { | ||||||||||||
|
Subroutine
issue: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||
| 66 | 1 | my $self = shift; | |||||||||||||
| 67 | 1 | require Net::Google::Code::Issue; | |||||||||||||
| 68 | 1 | ▶ | return Net::Google::Code::Issue->new( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 69 | project => $self->project, | ||||||||||||||
| 70 | $self->email ? ( email => $self->email ) : (), | ||||||||||||||
| 71 | $self->password ? ( password => $self->password ) : (), | ||||||||||||||
| 72 | @_ | ||||||||||||||
| 73 | ); | ||||||||||||||
| 74 | } | ||||||||||||||
| 75 | |||||||||||||||
| 76 | 1 | ▶ | sub wiki { | ||||||||||||
|
Subroutine
wiki: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||
| 77 | 1 | my $self = shift; | |||||||||||||
| 78 | 1 | require Net::Google::Code::Wiki; | |||||||||||||
| 79 | 1 | ▶ | return Net::Google::Code::Wiki->new( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 80 | project => $self->project, | ||||||||||||||
| 81 | $self->email ? ( email => $self->email ) : (), | ||||||||||||||
| 82 | $self->password ? ( password => $self->password ) : (), | ||||||||||||||
| 83 | @_ | ||||||||||||||
| 84 | ); | ||||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | |||||||||||||||
| 88 | 1 | ▶ | sub load { | ||||||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 89 | 1 | my $self = shift; | |||||||||||||
| 90 | 1 | my $content = $self->fetch( $self->base_url ); | |||||||||||||
| 91 | 1 | return $self->parse( $content ); | |||||||||||||
| 92 | } | ||||||||||||||
| 93 | |||||||||||||||
| 94 | 1 | ▶ | sub parse { | ||||||||||||
|
Subroutine
parse: called CC=11 SCAR=24.4
Pod
documented
| |||||||||||||||
| 95 | 1 | my $self = shift; | |||||||||||||
| 96 | 1 | my $tree = shift; | |||||||||||||
| 97 | 1 | my $need_delete = not blessed $tree; | |||||||||||||
| 98 | 1 | ▶ | $tree = $self->html_tree( html => $tree ) unless blessed $tree; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 99 | |||||||||||||||
| 100 | 1 | my $summary = | |||||||||||||
| 101 | $tree->look_down( id => 'psum' )->find_by_tag_name('a')->content_array_ref->[0]; | ||||||||||||||
| 102 | 1 | ▶ | $self->summary($summary) if $summary; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 103 | |||||||||||||||
| 104 | 1 | my $description = | |||||||||||||
| 105 | $tree->look_down( id => 'wikicontent' )->content_array_ref->[0]->as_text; | ||||||||||||||
| 106 | 1 | ▶ | $self->description($description) if $description; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 107 | |||||||||||||||
| 108 | 1 | ▶ | if ( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 109 | my $members_header = $tree->look_down( | ||||||||||||||
| 110 | _tag => 'b', | ||||||||||||||
| 111 | 6 | ▶ | sub { $_[0]->as_text eq 'Committers:' } | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 112 | ) | ||||||||||||||
| 113 | ) | ||||||||||||||
| 114 | { | ||||||||||||||
| 115 | 1 | my @a = $members_header->parent->find_by_tag_name('a'); | |||||||||||||
| 116 | 1 | my @members; | |||||||||||||
| 117 | 1 | for my $member (@a) { | |||||||||||||
| 118 | 2 | push @members, $member->as_text; | |||||||||||||
| 119 | } | ||||||||||||||
| 120 | |||||||||||||||
| 121 | 1 | $self->members( \@members ); | |||||||||||||
| 122 | } | ||||||||||||||
| 123 | |||||||||||||||
| 124 | 1 | ▶ | if ( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 125 | my $owners_header = $tree->look_down( | ||||||||||||||
| 126 | _tag => 'b', | ||||||||||||||
| 127 | 5 | ▶ | sub { $_[0]->as_text eq 'Owners:' } | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 128 | ) | ||||||||||||||
| 129 | ) | ||||||||||||||
| 130 | { | ||||||||||||||
| 131 | 1 | my @a = $owners_header->parent->find_by_tag_name('a'); | |||||||||||||
| 132 | 1 | my @owners; | |||||||||||||
| 133 | 1 | for my $owner (@a) { | |||||||||||||
| 134 | 1 | push @owners, $owner->as_text; | |||||||||||||
| 135 | } | ||||||||||||||
| 136 | |||||||||||||||
| 137 | 1 | $self->owners( \@owners ); | |||||||||||||
| 138 | } | ||||||||||||||
| 139 | |||||||||||||||
| 140 | 1 | my @labels; | |||||||||||||
| 141 | 1 | my @labels_tags = $tree->look_down( href => qr/q\=label\:/ ); | |||||||||||||
| 142 | 1 | for my $tag (@labels_tags) { | |||||||||||||
| 143 | 1 | push @labels, $tag->content_array_ref->[0]; | |||||||||||||
| 144 | } | ||||||||||||||
| 145 | 1 | ▶ | $self->labels( \@labels ) if @labels; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 146 | 1 | ▶ | $tree->delete if $need_delete; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 147 | 1 | return 1; | |||||||||||||
| 148 | } | ||||||||||||||
| 149 | |||||||||||||||
| 150 | |||||||||||||||
| 151 | 1 | ▶ | sub load_downloads { | ||||||||||||
|
Subroutine
load_downloads: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 152 | 1 | my $self = shift; | |||||||||||||
| 153 | 1 | my $content = $self->fetch( $self->base_feeds_url . 'downloads/list' ); | |||||||||||||
| 154 | 1 | my @rows = $self->rows( html => $content ); | |||||||||||||
| 155 | 1 | my @downloads; | |||||||||||||
| 156 | 1 | require Net::Google::Code::Download; | |||||||||||||
| 157 | 1 | for my $row ( @rows ) { | |||||||||||||
| 158 | 2 | my $download = Net::Google::Code::Download->new( | |||||||||||||
| 159 | project => $self->project, | ||||||||||||||
| 160 | %$row, | ||||||||||||||
| 161 | ); | ||||||||||||||
| 162 | 2 | $download->load; | |||||||||||||
| 163 | 2 | push @downloads, $download; | |||||||||||||
| 164 | } | ||||||||||||||
| 165 | 1 | $self->downloads( \@downloads ); | |||||||||||||
| 166 | } | ||||||||||||||
| 167 | |||||||||||||||
| 168 | |||||||||||||||
| 169 | 1 | ▶ | sub load_wikis { | ||||||||||||
|
Subroutine
load_wikis: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 170 | 1 | my $self = shift; | |||||||||||||
| 171 | |||||||||||||||
| 172 | 1 | my $wiki_svn = $self->base_svn_url . 'wiki/'; | |||||||||||||
| 173 | 1 | my $content = $self->fetch( $wiki_svn ); | |||||||||||||
| 174 | 1 | my $tree = $self->html_tree( html => $content ); | |||||||||||||
| 175 | |||||||||||||||
| 176 | 1 | my @wikis; | |||||||||||||
| 177 | 1 | my @li = $tree->find_by_tag_name('li'); | |||||||||||||
| 178 | 1 | for my $li ( @li ) { | |||||||||||||
| 179 | 2 | my $name = $li->as_text; | |||||||||||||
| 180 | 2 | ▶ | if ( $name =~ /(\S+)\.wiki$/ ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 181 | 1 | $name = $1; | |||||||||||||
| 182 | 1 | require Net::Google::Code::Wiki; | |||||||||||||
| 183 | 1 | my $wiki = Net::Google::Code::Wiki->new( | |||||||||||||
| 184 | project => $self->project, | ||||||||||||||
| 185 | name => $name, | ||||||||||||||
| 186 | ); | ||||||||||||||
| 187 | 1 | $wiki->load; | |||||||||||||
| 188 | 1 | push @wikis, $wiki; | |||||||||||||
| 189 | } | ||||||||||||||
| 190 | } | ||||||||||||||
| 191 | 1 | $tree->delete; | |||||||||||||
| 192 | 1 | $self->wikis( \@wikis ); | |||||||||||||
| 193 | } | ||||||||||||||
| 194 | |||||||||||||||
| 195 | 6 | ▶ | no Any::Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 196 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 197 | |||||||||||||||
| 198 | 6 | 1; | |||||||||||||
| 199 | |||||||||||||||
| 200 | __END__ | ||||||||||||||