LinkEmbedder/Link/Xkcd.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 3 SCAR 22.5
CC
3
Cov
0%
_learn_from_dom
12.0
BEGIN
2.0
CRAP 9.5
1 package LinkEmbedder::Link::Xkcd;
2 use Mojo::Base 'LinkEmbedder::Link';
3  
4 has provider_name => 'Xkcd';
5 has provider_url => sub { Mojo::URL->new('https://xkcd.com') };
6  
7 sub _learn_from_dom {
8 my ($self, $dom) = @_;
9 $self->SUPER::_learn_from_dom($dom);
10  
11 my $img = $dom->at('#comic img') or return;
12 $self->description($img->{title}) if $img->{title};
13 $self->height(0)->width(0)->type('photo');
14 $self->title($img->{alt} || $img->{title}) if $img->{alt} or $img->{title};
15 $self->thumbnail_url($img->{src});
16 }
17  
18 1;