From 1931d497364d7afef46f7d54d94d0b13efad5850 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Thu, 26 Nov 2009 18:21:01 +0100 Subject: update tests makefile pod and declaration --- Makefile.PL | 3 ++- lib/Net/Backtweet.pm | 17 ++++++++++++----- lib/Net/Backtype.pm | 18 ++++++++++-------- t/01_basic.t | 23 +++++++++-------------- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index b657f2c..75deb47 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,7 +2,8 @@ use inc::Module::Install; name 'Net-Backtype'; all_from 'lib/Net/Backtype.pm'; -# requires ''; +requires 'Moose'; +requires 'MooseX::Net::API'; tests 't/*.t'; author_tests 'xt'; diff --git a/lib/Net/Backtweet.pm b/lib/Net/Backtweet.pm index 03abb0d..ba84758 100644 --- a/lib/Net/Backtweet.pm +++ b/lib/Net/Backtweet.pm @@ -4,9 +4,11 @@ use Moose; use MooseX::Net::API; extends 'Net::Backtype'; -has format => ( is => 'ro', isa => 'Str', default => 'json', ); -has '+api_base_url' => ( default => 'http://backtweets.com' ); -format_query 'format' => ( mode => 'append' ); +net_api_declare backtweet => ( + base_url => 'http://backtweets.com', + format => 'json', + format_mode => 'append', +); net_api_method backtweet_search => ( path => '/search', @@ -26,10 +28,11 @@ Net::Backtweet - client for the backtweet API use Net::Backtweet; my $client = Net::Backtweet->new(); + my $res = $client->backtweet_search(q => 'http://lumberjaph.net', key => $mykey); =head1 DESCRIPTION -Net::Backtype is a client for the backtweet API +Net::Backtype is a client for the backtweet API. =head2 METHODS @@ -43,12 +46,16 @@ See L. =head1 AUTHOR -franck cuny Efranck.cuny@rtgi.frE +franck cuny Efranck@lumberjaph.netE =head1 SEE ALSO =head1 LICENSE +Copyright 2009 by Linkfluence + +http://linkfluence.net + This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Net/Backtype.pm b/lib/Net/Backtype.pm index 58d9fa8..ac7816c 100644 --- a/lib/Net/Backtype.pm +++ b/lib/Net/Backtype.pm @@ -5,14 +5,11 @@ use MooseX::Net::API; our $VERSION = '0.01'; -has api_base_url => ( - isa => 'Str', - is => 'rw', - default => 'http://api.backtype.com' +net_api_declare backtype => ( + base_url => 'http://api.backtype.com', + format => 'json', + format_mode => 'append', ); -has format => ( is => 'ro', isa => 'Str', default => 'json', ); - -format_query 'format' => ( mode => 'append' ); net_api_method user_comments => ( path => '/user/$user/comments', @@ -102,6 +99,7 @@ Net::Backtype - client for the backtype API use Net::Backtype; my $client = Net::Backtype->new(); + my $res = $client->comments_page(url => 'http://...', key => $mykey); =head1 DESCRIPTION @@ -159,12 +157,16 @@ See L. =head1 AUTHOR -franck cuny Efranck.cuny@rtgi.frE +franck cuny Efranckcuny@lumberjaph.netE =head1 SEE ALSO =head1 LICENSE +Copyright 2009 by Linkfluence + +http://linkfluence.net + This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/t/01_basic.t b/t/01_basic.t index 83b718f..9e0c120 100644 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -5,8 +5,10 @@ use Net::Backtype; use Net::Backtweet; use YAML::Syck; -sum_methods( 'Net::Backtype', 11 ); -sum_methods( 'Net::Backtweet', 12 ); +BEGIN { + plan skip_all => 'set $ENV{BACKTYPE_KEY} for this test' + unless $ENV{BACKTYPE_KEY}; +} my $obj = Net::Backtweet->new; ok $obj, '... object created'; @@ -14,17 +16,10 @@ my $method = $obj->meta->find_method_by_name('user_comments'); ok $method->meta->has_attribute('method'), '... got method as attribute'; is $method->method, 'GET', '... method is GET'; +my $res = $obj->backtweet_search( + key => $ENV{BACKTYPE_KEY}, + q => 'http://lumberjaph.net' +); +cmp_ok scalar @{ $res->{tweets} }, '>=', 1, '... got more than one result'; done_testing; - -sub sum_methods { - my $module = shift; - my $expect = shift; - my $obj = $module->new(); - my @methods = $obj->meta->get_all_methods(); - my $total = 0; - foreach my $m (@methods) { - ++$total if $m->meta->has_attribute('description'); - } - is $total, $expect, "... got $expect methods in our client"; -} -- cgit 1.4.1