/usr/share/perl5/Net/Google/Code/Role/Fetchable.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 | package Net::Google::Code::Role::Fetchable;
use Any::Moose 'Role';
use Params::Validate ':all';
use WWW::Mechanize;
our $MECH;
sub mech {
if (!$MECH) {
$MECH = WWW::Mechanize->new(
agent => 'Net-Google-Code',
keep_alive => 4,
cookie_jar => {},
stack_depth => 1,
timeout => 60,
);
}
return $MECH ;
}
sub fetch {
my $self = shift;
my ($url) = validate_pos( @_, { type => SCALAR } );
$self->mech->get($url);
if ( !$self->mech->response->is_success ) {
die "Server threw an error "
. $self->mech->response->status_line . " for "
. $url;
}
else {
my $content = $self->mech->content;
# auto decode the content to erase HTML::Parser's utf8 warning like this:
# Parsing of undecoded UTF-8 will give garbage when decoding entities
utf8::downgrade( $content, 1 );
return $content;
}
}
no Any::Moose;
1;
__END__
=head1 NAME
Net::Google::Code::Role::Fetchable - Fetchable Role
=head1 DESCRIPTION
=head1 INTERFACE
=over 4
=item mech
=item fetch
=back
=head1 AUTHOR
sunnavy C<< <sunnavy@bestpractical.com> >>
=head1 LICENCE AND COPYRIGHT
Copyright 2009 Best Practical Solutions.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
|