X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FWebService%2FTDWTF.pm;h=fe9ea4da73a9e4b02f48b624c2bb116848907d49;hb=8773c4ec2c066ec03cb01a646f1f8b05b3497bde;hp=33827e47797084f501863f7195874d954db5a1d0;hpb=54c23de0aec8b304483d67092053f47cdc1cb1ae;p=webservice-tdwtf.git diff --git a/lib/WebService/TDWTF.pm b/lib/WebService/TDWTF.pm index 33827e4..fe9ea4d 100644 --- a/lib/WebService/TDWTF.pm +++ b/lib/WebService/TDWTF.pm @@ -11,11 +11,11 @@ use JSON::MaybeXS qw/decode_json/; use Scalar::Util qw/looks_like_number/; use WebService::TDWTF::Article; -my @subs = qw/article list_recent list_series list_author/; +my @subs = qw/article list_recent list_series list_author series/; our @EXPORT = map { "tdwtf_$_" } @subs; our @EXPORT_OK = (@EXPORT, @subs); - -our $VERSION = '0.001'; +our %EXPORT_TAGS = (all => [@EXPORT_OK]); +our $VERSION = '0.002'; our $AGENT = "WebService-TDWTF/$VERSION"; our $BASE_URL = 'http://thedailywtf.com/api'; @@ -57,11 +57,14 @@ sub list_recent { my $url = @_ == 2 ? 'articles' : 'articles/recent'; _list $url sub list_series { _list 'series', @_ } sub list_author { _list 'author', @_ } +sub series { @{_query "$BASE_URL/series/"} } + BEGIN { *tdwtf_article = \&article; *tdwtf_list_recent = \&list_recent; *tdwtf_list_series = \&list_series; *tdwtf_list_author = \&list_author; + *tdwtf_series = \&series; } 1; @@ -71,7 +74,7 @@ __END__ =head1 NAME -WebService::TDWTF - retreive articles from thedailywtf.com +WebService::TDWTF - retrieve articles from thedailywtf.com =head1 SYNOPSIS @@ -100,6 +103,13 @@ WebService::TDWTF - retreive articles from thedailywtf.com # All Error'd articles published in January 2014 my @jan14_errord = tdwtf_list_series 'errord', 2014, 1; + my @series = series; # List of all series + my $series = series; # Number of series ($series == @series) + print $series[0]->Slug; # alexs-soapbox + print $series[0]->Title; # Alex's Soapbox + print $series[0]->Description; # + print $series[0]->CssClass; # tales + =head1 DESCRIPTION WebService::TDWTF is an interface to the API of L. @@ -192,6 +202,16 @@ With two arguments, returns all articles by the given author published in the given month of the given year. I<$month> is an integer between 1 and 12. +=item B + +=item B + +In list context, returns a list of all existing article series. Each +series is an unblessed hashref with the keys C, C, +C<Description> and C<CssClass>. + +In scalar context, returns the number of existing article series. + =back =head1 NOTES