LinkEmbedder/Link/Twitter.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 32 CC 2 SCAR 13.9
CC
2
Cov
0%
learn_p
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.0
1 package LinkEmbedder::Link::Twitter;
2 use Mojo::Base 'LinkEmbedder::Link';
3  
4 use Mojo::Util;
5  
6 has provider_name => 'Twitter';
7 has provider_url => sub { Mojo::URL->new('https://twitter.com') };
8  
9 sub learn_p {
10 my $self = shift;
11 my $path = $self->url->path;
12 return $self->SUPER::learn_p(@_) unless @$path >= 3 and $path->[1] eq 'status';
13  
14 $self->author_name($path->[0]);
15 $self->author_url($self->provider_url->clone->path("/$path->[0]"));
16 $self->template([__PACKAGE__, 'twitframe.html.ep']);
17 $self->url($self->provider_url->clone->path("/$path->[0]/status/$path->[2]"));
18 $self->type('rich');
19 return Mojo::Promise->resolve($self);
20 }
21  
22 1;
23  
24 __DATA__