Permalink
Browse files

depends on Net::Google::DataAPI 0.09

  • Loading branch information...
1 parent a562723 commit 35318d59d1a9b97a6a706ca5b13123dc81998dbc @nobuo-danjou nobuo-danjou committed Dec 18, 2009
View
@@ -1,5 +1,6 @@
Changes
inc/Module/Install.pm
+inc/Module/Install/Any/Moose.pm
inc/Module/Install/AuthorTests.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
View
@@ -4,10 +4,15 @@ all_from 'lib/Net/Google/Spreadsheets.pm';
requires 'Carp';
requires 'XML::Atom';
-requires 'Moose' => '0.34';
-requires 'Net::Google::DataAPI' => '0.04';
+requires 'Net::Google::AuthSub';
+requires 'Net::Google::DataAPI' => '0.09';
requires 'URI';
requires 'Path::Class';
+requires 'namespace::autoclean';
+requires_any_moose(
+ moose => '0.56',
+ mouse => '0.40',
+);
tests_recursive;
author_tests 'xt';
@@ -1,21 +1,45 @@
package Net::Google::Spreadsheets;
-use Moose;
+use Any::Moose;
use Net::Google::DataAPI;
-use namespace::clean -except => 'meta';
+use namespace::autoclean;
use 5.008001;
+use Net::Google::AuthSub;
+use Net::Google::DataAPI::Auth::AuthSub;
our $VERSION = '0.07';
-with 'Net::Google::DataAPI::Role::Service' => {
- gdata_version => '3.0',
- service => 'wise',
- source => __PACKAGE__.'-'.$VERSION,
- ns => {
- gs => 'http://schemas.google.com/spreadsheets/2006',
- gsx => 'http://schemas.google.com/spreadsheets/2006/extended',
- batch => 'http://schemas.google.com/gdata/batch',
+with 'Net::Google::DataAPI::Role::Service';
+has '+gdata_version' => (default => '3.0');
+has '+namespaces' => (
+ default => sub {
+ {
+ gs => 'http://schemas.google.com/spreadsheets/2006',
+ gsx => 'http://schemas.google.com/spreadsheets/2006/extended',
+ batch => 'http://schemas.google.com/gdata/batch',
+ }
+ },
+);
+
+has username => (is => 'ro', isa => 'Str');
+has password => (is => 'ro', isa => 'Str');
+has account_type => (is => 'ro', isa => 'Str', required => 1, default => 'HOSTED_OR_GOOGLE');
+has source => (is => 'ro', isa => 'Str', required => 1, default => __PACKAGE__ . '-' . $VERSION);
+
+sub _build_auth {
+ my ($self) = @_;
+ my $authsub = Net::Google::AuthSub->new(
+ source => $self->source,
+ service => 'wise',
+ account_type => $self->account_type,
+ );
+ my $res = $authsub->login( $self->username, $self->password );
+ unless ($res && $res->is_success) {
+ die 'Net::Google::AuthSub login failed';
}
-};
+ return Net::Google::DataAPI::Auth::AuthSub->new(
+ authsub => $authsub,
+ );
+}
feedurl spreadsheet => (
default => 'http://spreadsheets.google.com/feeds/spreadsheets/private/full',
@@ -32,6 +56,11 @@ around spreadsheets => sub {
return @result;
};
+sub BUILD {
+ my $self = shift;
+ $self->auth;
+}
+
__PACKAGE__->meta->make_immutable;
1;
@@ -1,6 +1,6 @@
package Net::Google::Spreadsheets::Cell;
-use Moose;
-use namespace::clean -except => 'meta';
+use Any::Moose;
+use namespace::autoclean;
use XML::Atom::Util qw(first);
with 'Net::Google::DataAPI::Role::Entry';
@@ -1,6 +1,6 @@
package Net::Google::Spreadsheets::Record;
-use Moose;
-use namespace::clean -except => 'meta';
+use Any::Moose;
+use namespace::autoclean;
use XML::Atom::Util qw(nodelist);
with
@@ -1,6 +1,6 @@
package Net::Google::Spreadsheets::Row;
-use Moose;
-use namespace::clean -except => 'meta';
+use Any::Moose;
+use namespace::autoclean;
use Net::Google::DataAPI;
use XML::Atom::Util qw(nodelist);
@@ -1,6 +1,6 @@
package Net::Google::Spreadsheets::Spreadsheet;
-use Moose;
-use namespace::clean -except => 'meta';
+use Any::Moose;
+use namespace::autoclean;
use Net::Google::DataAPI;
with 'Net::Google::DataAPI::Role::Entry';
@@ -1,7 +1,7 @@
package Net::Google::Spreadsheets::Table;
-use Moose;
-use Moose::Util::TypeConstraints;
-use namespace::clean -except => 'meta';
+use Any::Moose;
+use Any::Moose '::Util::TypeConstraints';
+use namespace::autoclean;
use Net::Google::DataAPI;
use XML::Atom::Util qw(nodelist first create_element);
@@ -111,7 +111,7 @@ __PACKAGE__->meta->make_immutable;
package # hide from PAUSE
Net::Google::Spreadsheets::Table::Column;
-use Moose;
+use Any::Moose;
has 'index' => ( is => 'ro', isa => 'Str' );
has 'name' => ( is => 'ro', isa => 'Str' );
@@ -1,6 +1,6 @@
package Net::Google::Spreadsheets::Worksheet;
-use Moose;
-use namespace::clean -except => 'meta';
+use Any::Moose;
+use namespace::autoclean;
use Net::Google::DataAPI;
with 'Net::Google::DataAPI::Role::Entry';
View
@@ -17,22 +17,24 @@ throws_ok {
{
my $res = Test::MockObject->new;
$res->mock(is_success => sub {return 1});
- $res->mock(auth => sub {return 'foobar'});
my $auth = Test::MockModule->new('Net::Google::AuthSub');
$auth->mock('login' => sub {return $res});
+ $auth->mock(auth_params => sub {return (Authorization => 'GoogleLogin auth="foobar"')});
ok my $service = Net::Google::Spreadsheets->new(
username => 'foo',
password => 'bar',
);
- is $service->ua->default_headers->header('Authorization'), 'GoogleLogin auth=foobar';
my $ua = Test::MockModule->new('LWP::UserAgent');
{
- $ua->mock('request' => sub {return HTTP::Response->parse(<<'END')});
-302 Found
-Location: http://www.google.com/
-
-END
+ $ua->mock('request' => sub {
+ my ($self, $req) = @_;
+ is $req->header('Authorization'), 'GoogleLogin auth="foobar"';
+ my $res = HTTP::Response->new(302);
+ $res->header(Location => 'http://www.google.com/');
+ return $res;
+ }
+ );
throws_ok {
$service->spreadsheets;
} qr{302 Found};
View
@@ -1,2 +1,5 @@
[TestingAndDebugging::ProhibitNoStrict]
allow=refs
+
+[TestingAndDebugging::RequireUseStrict]
+equivalent_modules = Any::Moose

0 comments on commit 35318d5

Please sign in to comment.