[Bps-public-commit] r19613 - in Net-Google-Code/trunk/lib/Net/Google/Code: Role
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Mon May 11 03:46:17 EDT 2009
Author: sunnavy
Date: Mon May 11 03:46:16 2009
New Revision: 19613
Added:
Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm
Removed:
Net-Google-Code/trunk/lib/Net/Google/Code/Role/Connectable.pm
Modified:
Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm
Net-Google-Code/trunk/lib/Net/Google/Code/IssueSearch.pm
Net-Google-Code/trunk/lib/Net/Google/Code/Role.pm
Log:
role name change: Connectable => Fetchable, also make Fetchable indepedent of URL role
Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm (original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm Mon May 11 03:46:16 2009
@@ -39,7 +39,7 @@
my $self = shift;
my ($id) = validate_pos( @_, { type => SCALAR } );
$self->state->{id} = $id;
- my $content = $self->fetch( "issues/detail?id=" . $id );
+ my $content = $self->fetch( $self->base_url . "issues/detail?id=" . $id );
$self->parse($content);
return $id;
}
Modified: Net-Google-Code/trunk/lib/Net/Google/Code/IssueSearch.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/IssueSearch.pm (original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/IssueSearch.pm Mon May 11 03:46:16 2009
@@ -44,7 +44,7 @@
$self->_q( $args{_q} ) if defined $args{_q};
}
- $self->fetch('issues/list');
+ $self->fetch( $self->base_url . 'issues/list');
my $mech = $self->mech;
$mech->submit_form(
form_number => 2,
Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Role.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Role.pm (original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Role.pm Mon May 11 03:46:16 2009
@@ -3,7 +3,8 @@
use Params::Validate;
use Net::Google::Code::Mechanize;
-with 'Net::Google::Code::Role::Connectable';
+with 'Net::Google::Code::Role::Fetchable';
+with 'Net::Google::Code::Role::URL';
has 'project' => (
isa => 'Str',
Added: Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm Mon May 11 03:46:16 2009
@@ -0,0 +1,63 @@
+package Net::Google::Code::Role::Fetchable;
+use Moose::Role;
+use Params::Validate ':all';
+use WWW::Mechanize;
+
+has mech => (
+ isa => 'WWW::Mechanize',
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+ my $m = WWW::Mechanize->new(
+ agent => 'Net-Google-Code',
+ cookie_jar => {},
+ stack_depth => 1,
+ timeout => 60,
+ );
+ return $m;
+ }
+);
+
+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 {
+ return $self->mech->content;
+ }
+}
+
+no Moose::Role;
+
+1;
+
+__END__
+
+=head1 NAME
+
+Net::Google::Code::Role::Connectable -
+
+
+=head1 DESCRIPTION
+
+=head1 INTERFACE
+
+=head2 fetch
+
+=head1 AUTHOR
+
+sunnavy C<< <sunnavy at 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.
+
More information about the Bps-public-commit
mailing list