| 1 | package WWW::Comic::Plugin::DinosaurComics; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use HTML::TreeBuilder; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use vars qw($VERSION @ISA %COMICS); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | @ISA = qw(WWW::Comic::Plugin); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | %COMICS = ( dinosaur_comics => 'Dinosaur Comics'); | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $self = { uri => 'http://www.qwantz.com' }; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | $self->{ua} = $self->_new_agent; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | return $self | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub strip_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strip_url: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | unless ( $self->{cur} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $r = $self->{ua}->get( "$self->{uri}/index.php" ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ( $r->is_success ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $self->{tree} = HTML::TreeBuilder->new_from_content( $r->content ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $self->{cur} = $self->{tree}->look_down( _tag => 'img', class => 'comic' )->attr( 'src' ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $self->{cur} =~ s/^.*comic2-//; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $self->{cur} =~ s/\.png// | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $self->{cur} = 2372; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | return ( ( exists $args{id} and $args{id} =~ /\d+$/ and $args{id} <= $self->{cur} ) | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | ? "$self->{uri}/comics/comic2-$args{id}.png" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $args{"id"} and $args{"id"} =~ /\d+$/ and $args{"id"} <= $self->{"cur"}
exists $args{"id"} and $args{"id"} =~ /\d+$/
MC/DC0%0/3
exists $args{"id"} and $args{"id"} =~ /\d+$/ and $args{"id"} <= $self->{"cur"}
exists $args{"id"}
$args{"id"} =~ /\d+$/
$args{"id"} <= $self->{"cur"}
Truth table0%0/4
A and B and C
A= exists $args{"id"}B= $args{"id"} =~ /\d+$/C= $args{"id"} <= $self->{"cur"}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | : "$self->{uri}/comics/comic2-$self->{cur}.png" | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | WWW::Comic::Plugin::DinosaurComics - WWW::Comic plugin to fetch Dinosaur Comics | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | See L<WWW::Comic> for full details. | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | use strict; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | use WWW::Comic; | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | my $wc = new WWW::Comic; | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | my $latest = $wc->get_strip( comic => 'dinosaur_comics' ); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | my $favorite = $wc->get_strip( comic => 'dinosaur_comics', id => 1999 ); | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | A plugin for L<WWW::Comic> to fetch Dinosaur Comics from http://www.qwantz.com/ | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | See L<WWW::Comic> and L<WWW::Comic::Plugin> for information on the WWW::Comic | ||||||||||||||||||||||||||||||||||||||||||
| 69 | interface. | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | =item new | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | Constructor - see L<WWW::Comic> for usage | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | Luke Poskitt, C<< <ltp at cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | Please report any bugs or feature requests to C<bug-www-comic-plugin-dinosaurcomics at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||||||||||||
| 90 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Comic-Plugin-DinosaurComics>. I will be notified, and then you'll | ||||||||||||||||||||||||||||||||||||||||||
| 91 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | perldoc WWW::Comic::Plugin::DinosaurComics | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Comic-Plugin-DinosaurComics> | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | L<http://annocpan.org/dist/WWW-Comic-Plugin-DinosaurComics> | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | L<http://cpanratings.perl.org/d/WWW-Comic-Plugin-DinosaurComics> | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | L<http://search.cpan.org/dist/WWW-Comic-Plugin-DinosaurComics/> | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | Copyright 2013 Luke Poskitt. | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 134 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||||||||||||||||
| 135 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | 1; # End of WWW::Comic::Plugin::DinosaurComics | |||||||||||||||||||||||||||||||||||||||||