| 1 | package WWW::OReillyMedia::Store; | ||
| 2 | |||
| 3 | 1 | $WWW::OReillyMedia::Store::VERSION = '0.07'; | |
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | WWW::OReillyMedia::Store - Interface to the OReilly Media Store. | ||
| 8 | |||
| 9 | =head1 VERSION | ||
| 10 | |||
| 11 | Version 0.07 | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | 1 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | 1 | ▶ | use XML::Simple; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 1 | ▶ | use LWP::Simple; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 1 | ▶ | use WWW::OReillyMedia::Store::Book; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | |||
| 22 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 1 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | 1 | my $NEW_BOOKS = "http://feeds.feedburner.com/oreilly/newbooks?format=xml"; | |
| 26 | 1 | my $UPCOMING_BOOKS = "http://feeds.feedburner.com/oreilly/upcomingbooks?format=xml"; | |
| 27 | |||
| 28 | 0 | ▶ | has 'new_books_url' => (is => 'ro', default => sub { return $NEW_BOOKS; }); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 29 | 0 | ▶ | has 'upcoming_books_url' => (is => 'ro', default => sub { return $UPCOMING_BOOKS; }); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | Objective of this module is to provide an interface to the OReilly online media | ||
| 34 | store. This rely on the RSS feed made public by OReilly. | ||
| 35 | |||
| 36 | use strict; use warnings; | ||
| 37 | use WWW::OReillyMedia::Store; | ||
| 38 | |||
| 39 | my $store = WWW::OReillyMedia::Store->new; | ||
| 40 | |||
| 41 | my $new_books = $store->new_books; | ||
| 42 | my $upcoming_books = $store->upcoming_books; | ||
| 43 | |||
| 44 | print $new_books->[0]->as_string(); | ||
| 45 | print $upcoming_books->[0]->as_string(); | ||
| 46 | |||
| 47 | =head1 METHODS | ||
| 48 | |||
| 49 | =head2 new_books() | ||
| 50 | |||
| 51 | Fetches new books details from OReilly online store realtime. It returns the ref | ||
| 52 | to a list of objects of type L<WWW::OReillMedia::Store::Book>. | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | sub new_books { | ||
| 57 | 0 | ▶ | my ($self) = @_; |
|
Subroutine
new_books: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 58 | |||
| 59 | 0 | return $self->_fetch($self->new_books_url); | |
| 60 | } | ||
| 61 | |||
| 62 | =head2 upcoming_books() | ||
| 63 | |||
| 64 | Fetches upcoming books details from OReilly online store realtime. It returns the | ||
| 65 | ref to a list of objects of type L<WWW::OReillMedia::Store::Book>. | ||
| 66 | |||
| 67 | =cut | ||
| 68 | |||
| 69 | sub upcoming_books { | ||
| 70 | 0 | ▶ | my ($self) = @_; |
|
Subroutine
upcoming_books: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 71 | |||
| 72 | 0 | return $self->_fetch($self->upcoming_books_url); | |
| 73 | } | ||
| 74 | |||
| 75 | sub _fetch { | ||
| 76 | 0 | ▶ | my ($url) = @_; |
|
Subroutine
_fetch: not called CC=2 SCAR=17.9
| |||
| 77 | |||
| 78 | 0 | my $books = []; | |
| 79 | 0 | my $xml = get($url); | |
| 80 | 0 | my $feeds = XMLin($xml); | |
| 81 | 0 | foreach my $catalog (keys %{$feeds->{entry}}) { | |
| 82 | 0 | my $title = $feeds->{entry}->{$catalog}->{title}; | |
| 83 | 0 | push @$books, WWW::OReillMedia::Store::Book->new({ title => $title, catalog => $catalog }); | |
| 84 | } | ||
| 85 | |||
| 86 | 0 | return $books; | |
| 87 | } | ||
| 88 | |||
| 89 | =head1 AUTHOR | ||
| 90 | |||
| 91 | Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||
| 92 | |||
| 93 | =head1 REPOSITORY | ||
| 94 | |||
| 95 | L<https://github.com/Manwar/WWW-OReillyMedia-Store> | ||
| 96 | |||
| 97 | =head1 BUGS | ||
| 98 | |||
| 99 | Please report any bugs or feature requests to C<bug-www-oreillymedia-store at | ||
| 100 | rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-OReillyMedia-Store>. | ||
| 101 | I will be notified, and then you'll automatically be notified of progress on your | ||
| 102 | bug as I make changes. | ||
| 103 | |||
| 104 | =head1 SUPPORT | ||
| 105 | |||
| 106 | You can find documentation for this module with the perldoc command. | ||
| 107 | |||
| 108 | perldoc WWW::OReillyMedia::Store | ||
| 109 | |||
| 110 | You can also look for information at: | ||
| 111 | |||
| 112 | =over 4 | ||
| 113 | |||
| 114 | =item * RT: CPAN's request tracker | ||
| 115 | |||
| 116 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-OReillyMedia-Store> | ||
| 117 | |||
| 118 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 119 | |||
| 120 | L<http://annocpan.org/dist/WWW-OReillyMedia-Store> | ||
| 121 | |||
| 122 | =item * CPAN Ratings | ||
| 123 | |||
| 124 | L<http://cpanratings.perl.org/d/WWW-OReillyMedia-Store> | ||
| 125 | |||
| 126 | =item * Search CPAN | ||
| 127 | |||
| 128 | L<http://search.cpan.org/dist/WWW-OReillyMedia-Store/> | ||
| 129 | |||
| 130 | =back | ||
| 131 | |||
| 132 | =head1 LICENSE AND COPYRIGHT | ||
| 133 | |||
| 134 | Copyright (C) 2011 - 2014 Mohammad S Anwar. | ||
| 135 | |||
| 136 | This program is free software; you can redistribute it and/or modify it under | ||
| 137 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||
| 138 | license at: | ||
| 139 | |||
| 140 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||
| 141 | |||
| 142 | Any use, modification, and distribution of the Standard or Modified Versions is | ||
| 143 | governed by this Artistic License.By using, modifying or distributing the Package, | ||
| 144 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||
| 145 | not accept this license. | ||
| 146 | |||
| 147 | If your Modified Version has been derived from a Modified Version made by someone | ||
| 148 | other than you,you are nevertheless required to ensure that your Modified Version | ||
| 149 | complies with the requirements of this license. | ||
| 150 | |||
| 151 | This license does not grant you the right to use any trademark, service mark, | ||
| 152 | tradename, or logo of the Copyright Holder. | ||
| 153 | |||
| 154 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||
| 155 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||
| 156 | Package with respect to any patent claims licensable by the Copyright Holder that | ||
| 157 | are necessarily infringed by the Package. If you institute patent litigation | ||
| 158 | (including a cross-claim or counterclaim) against any party alleging that the | ||
| 159 | Package constitutes direct or contributory patent infringement,then this Artistic | ||
| 160 | License to you shall terminate on the date that such litigation is filed. | ||
| 161 | |||
| 162 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||
| 163 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||
| 164 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||
| 165 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||
| 166 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||
| 167 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||
| 168 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 169 | |||
| 170 | =cut | ||
| 171 | |||
| 172 | 1 | 1; # End of WWW::OReillyMedia::Store | |