/usr/share/perl5/Net/Google/Code/Download.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 | package Net::Google::Code::Download;
use Any::Moose;
use Params::Validate qw(:all);
use Scalar::Util qw/blessed/;
with 'Net::Google::Code::TypicalRoles';
has 'project' => (
isa => 'Str',
is => 'rw',
);
has 'name' => (
isa => 'Str',
is => 'rw',
);
has 'size' => (
isa => 'Str',
is => 'rw',
);
has 'download_url' => (
isa => 'Str',
is => 'rw',
);
has 'count' => (
isa => 'Int',
is => 'rw',
);
has 'labels' => (
isa => 'ArrayRef[Str]',
is => 'rw',
);
has 'checksum' => (
isa => 'Str',
is => 'rw',
);
has 'uploaded_by' => (
isa => 'Str',
is => 'rw',
);
has 'uploaded' => (
isa => 'Str',
is => 'rw',
);
sub load {
my $self = shift;
my $name = shift || $self->name;
die "current object doesn't have name and load() is not passed a name either"
unless $name;
# http://code.google.com/p/net-google-code/downloads/detail?name=Net-Google-Code-0.01.tar.gz
my $content =
$self->fetch( $self->base_url . "downloads/detail?name=$name" );
$self->name( $name ) unless $self->name && $self->name eq $name;
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 $entry;
my $uploaded = $tree->look_down(class => 'date')->attr('title');
$self->uploaded( $uploaded ) if $uploaded;
my @labels_tag = $tree->look_down( class => 'label' );
my @labels;
for my $tag ( @labels_tag ) {
push @labels, $tag->as_text;
}
$self->labels( \@labels );
# parse uploaded_by and download count.
# uploaded and labels are kind of special, so they're handleed above
my ($meta) = $tree->look_down( id => 'issuemeta' );
my @meta = $meta->find_by_tag_name('tr');
for my $meta (@meta) {
my ( $key, $value );
$key = $meta->find_by_tag_name('th');
next unless $key;
$key = $key->as_text;
my $td = $meta->find_by_tag_name('td');
next unless $td;
$value = $td->as_text;
if ( $key =~ /Uploaded.*?by/ ) {
$self->uploaded_by($value);
}
elsif ( $key =~ /Downloads/ ) {
$self->count($value);
}
}
# download_url and size
my $desc = $tree->look_down( class => 'vt issuedescription' );
my $box_inner = $desc->look_down( class => 'box-inner' );
$self->download_url( $box_inner->content_array_ref->[0]->attr('href') );
my $size = $box_inner->content_array_ref->[3];
$size =~ s/^\D+//;
$size =~ s/\s+$//;
$self->size( $size ) if $size;
# checksum
my $span = $desc->find_by_tag_name('span');
my $checksum = $span->content_array_ref->[0];
if ( $checksum =~ /^SHA1 Checksum:\s+(\w+)/ ) {
$self->checksum( $1 );
}
$tree->delete if $need_delete;
}
sub BUILDARGS {
my $class = shift;
my %args;
if ( @_ % 2 && ref $_[0] eq 'HASH' ) {
%args = %{$_[0]};
}
else {
%args = @_;
}
my %translations = ( filename => 'name', 'downloadcount' => 'count' );
for my $key ( keys %translations ) {
if ( exists $args{$key} ) {
$args{ $translations{$key} } = $args{$key};
}
}
return $class->SUPER::BUILDARGS(%args);
}
no Any::Moose;
__PACKAGE__->meta->make_immutable;
1;
__END__
=head1 NAME
Net::Google::Code::Download - Google Code Download
=head1 SYNOPSIS
use Net::Google::Code::Download;
my $issue = Net::Google::Code::Download->new( project => 'net-google-code' );
$issue->load( 'Net-Google-Code-0.01.tar.gz' );
=head1 DESCRIPTION
=head1 INTERFACE
=over 4
=item load
=item parse
=item project
=item name
=item size
=item download_url
=item count
=item labels
=item checksum
=item uploaded_by
=item uploaded
=back
=head1 AUTHOR
sunnavy C<< <sunnavy@bestpractical.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.
|