/usr/share/perl5/Net/Google/Code.pm is in libnet-google-code-perl 0.19-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | package Net::Google::Code;
use Any::Moose;
with 'Net::Google::Code::TypicalRoles';
use Scalar::Util qw/blessed/;
our $VERSION = '0.19';
has 'project' => (
isa => 'Str',
is => 'rw',
);
has 'labels' => (
isa => 'ArrayRef',
is => 'rw',
);
has 'owners' => (
isa => 'ArrayRef',
is => 'rw',
);
has 'members' => (
isa => 'ArrayRef',
is => 'rw',
);
has 'summary' => (
isa => 'Str',
is => 'rw',
);
has 'description' => (
isa => 'Str',
is => 'rw',
);
has 'issues' => (
isa => 'ArrayRef[Net::Google::Code::Issue]',
is => 'rw',
);
has 'downloads' => (
isa => 'ArrayRef[Net::Google::Code::Download]',
is => 'rw',
);
has 'wikis' => (
isa => 'ArrayRef[Net::Google::Code::Wiki]',
is => 'rw',
);
sub download {
my $self = shift;
require Net::Google::Code::Download;
return Net::Google::Code::Download->new(
project => $self->project,
$self->email ? ( email => $self->email ) : (),
$self->password ? ( password => $self->password ) : (),
@_
);
}
sub issue {
my $self = shift;
require Net::Google::Code::Issue;
return Net::Google::Code::Issue->new(
project => $self->project,
$self->email ? ( email => $self->email ) : (),
$self->password ? ( password => $self->password ) : (),
@_
);
}
sub wiki {
my $self = shift;
require Net::Google::Code::Wiki;
return Net::Google::Code::Wiki->new(
project => $self->project,
$self->email ? ( email => $self->email ) : (),
$self->password ? ( password => $self->password ) : (),
@_
);
}
sub load {
my $self = shift;
my $content = $self->fetch( $self->base_url );
return $self->parse( $content );
}
sub parse {
my $self = shift;
my $tree = shift;
my $need_delete = not blessed $tree;
$tree = $self->html_tree( html => $tree ) unless blessed $tree;
my $summary =
$tree->look_down( id => 'psum' )->find_by_tag_name('a')->content_array_ref->[0];
$self->summary($summary) if $summary;
my $description =
$tree->look_down( id => 'wikicontent' )->content_array_ref->[0]->as_text;
$self->description($description) if $description;
if (
my $members_header = $tree->look_down(
_tag => 'b',
sub { $_[0]->as_text eq 'Committers:' }
)
)
{
my @a = $members_header->parent->find_by_tag_name('a');
my @members;
for my $member (@a) {
push @members, $member->as_text;
}
$self->members( \@members );
}
if (
my $owners_header = $tree->look_down(
_tag => 'b',
sub { $_[0]->as_text eq 'Owners:' }
)
)
{
my @a = $owners_header->parent->find_by_tag_name('a');
my @owners;
for my $owner (@a) {
push @owners, $owner->as_text;
}
$self->owners( \@owners );
}
my @labels;
my @labels_tags = $tree->look_down( href => qr/q\=label\:/ );
for my $tag (@labels_tags) {
push @labels, $tag->content_array_ref->[0];
}
$self->labels( \@labels ) if @labels;
$tree->delete if $need_delete;
return 1;
}
sub load_downloads {
my $self = shift;
my $content = $self->fetch( $self->base_feeds_url . 'downloads/list' );
my @rows = $self->rows( html => $content );
my @downloads;
require Net::Google::Code::Download;
for my $row ( @rows ) {
my $download = Net::Google::Code::Download->new(
project => $self->project,
%$row,
);
$download->load;
push @downloads, $download;
}
$self->downloads( \@downloads );
}
sub load_wikis {
my $self = shift;
my $wiki_svn = $self->base_svn_url . 'wiki/';
my $content = $self->fetch( $wiki_svn );
my $tree = $self->html_tree( html => $content );
my @wikis;
my @li = $tree->find_by_tag_name('li');
for my $li ( @li ) {
my $name = $li->as_text;
if ( $name =~ /(\S+)\.wiki$/ ) {
$name = $1;
require Net::Google::Code::Wiki;
my $wiki = Net::Google::Code::Wiki->new(
project => $self->project,
name => $name,
);
$wiki->load;
push @wikis, $wiki;
}
}
$tree->delete;
$self->wikis( \@wikis );
}
no Any::Moose;
__PACKAGE__->meta->make_immutable;
1;
__END__
=head1 NAME
Net::Google::Code - a simple client library for google code
=head1 SYNOPSIS
use Net::Google::Code;
my $project = Net::Google::Code->new( project => 'net-google-code' );
$project->load; # load its metadata, e.g. summary, owners, members, etc.
print join(', ', @{ $project->owners } );
# return a Net::Google::Code::Issue object, of which the id is 30
$project->issue( id => 30 );
# return a Net::Google::Code::Download object, of which the file name is
# 'FooBar-0.01.tar.gz'
$project->download( name => 'FooBar-0.01.tar.gz' );
# return a Net::Google::Code::Wiki object, of which the page name is 'Test'
$project->wiki( name => 'Test' );
# loads all the downloads
$project->load_downloads;
my $downloads = $project->downloads;
# loads all the wikis
$project->load_wikis;
my $wikis = $project->wikis;
=head1 DESCRIPTION
Net::Google::Code is a simple client library for projects hosted in
Google Code.
Since 0.15, Net::Google::Code offers google's official issues api support.
Besides the new C<Net::Google::Code::Issue::list>,
C<Net::Google::Code::Issue::Comment::list> and
<Net::Googlel::Code::Issue::load_comments> methods, which use the api from
start, you can set C<$Net::Google::Code::Issue::USE_HYBRID> to true to load,
create and update issue with the api too.
But the official api is not function complete yet( e.g. no attachment
support, can't merge, etc. ), Net::Google::Code will back to the scraping
way to accomplish those stuff.
=head1 ATTRIBUTES
=over 4
=item project
the project name
=item email, password
user's email and password, used to authenticate
=item base_url
the project homepage
=item base_svn_url
the project svn url (without trunk)
=item base_feeds_url
the project feeds url
=item summary
=item description
=item labels
=item owners
=item members
=back
=head1 INTERFACE
=over 4
=item load
load project's home page, and parse its metadata
=item parse
acturally do the parse job, for load();
=item load_downloads
load all the downloads, and store them as an arrayref in $self->downloads
=item load_wikis
load all the wikis, and store them as an arrayref in $self->wikis
=item issue
return a new L<Net::Google::Code::Issue> object, arguments will be passed to
L<Net::Google::Code::Issue>'s new method.
=item download
return a new L<Net::Google::Code::Download> object, arguments will be passed to
L<Net::Google::Code::Download>'s new method.
=item wiki
return a new L<Net::Google::Code::Wiki> object, arguments will be passed to
L<Net::Google::Code::Wiki>'s new method.
=back
=head1 DEPENDENCIES
L<Any::Moose>, L<HTML::TreeBuilder>, L<WWW::Mechanize>, L<Params::Validate>
L<XML::FeedPP>, L<DateTime>, L<JSON>, L<URI::Escape>, L<MIME::Types>,
L<File::MMagic>
=head1 INCOMPATIBILITIES
None reported.
=head1 BUGS AND LIMITATIONS
No bugs have been reported.
This project is very very young, and api is not stable yet, so don't use this in
production, at least for now.
=head1 AUTHOR
sunnavy C<< <sunnavy@bestpractical.com> >>
Fayland Lam C<< <fayland@gmail.com> >>
=head1 LICENCE AND COPYRIGHT
Copyright 2008-2010 Best Practical Solutions.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
|