File Coverage

blib/lib/Mojolicious/Plugin/LinkEmbedder/Link/Image/Instagram.pm
Criterion Covered Total %
statement 3 22 13.6
branch 0 4 0.0
condition n/a
subroutine 1 5 20.0
pod 2 2 100.0
total 6 33 18.1


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::LinkEmbedder::Link::Image::Instagram;
2 1     1   443 use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Image';
  1         1  
  1         6  
3              
4             sub learn {
5 0     0 1   my ($self, $c, $cb) = @_;
6 0           my $ua = $self->{ua};
7 0           my $url = Mojo::URL->new('https://api.instagram.com/oembed');
8              
9 0           $url->query(url => $self->url);
10              
11             my $delay = Mojo::IOLoop->delay(
12             sub {
13 0     0     my $delay = shift;
14 0           $ua->get($url, $delay->begin);
15             },
16             sub {
17 0     0     my ($ua, $tx) = @_;
18 0           my $json = $tx->res->json;
19              
20 0           $self->author_name($json->{author_name});
21 0           $self->author_url($json->{author_url});
22 0           $self->media_id($json->{media_id});
23 0           $self->provider_url($json->{provider_url});
24 0           $self->provider_name($json->{provider_name});
25 0           $self->title($json->{title});
26 0           $self->{html} = $json->{html};
27 0           $self->$cb;
28             },
29 0           );
30 0 0         $delay->wait unless $delay->ioloop->is_running;
31             }
32              
33 0 0   0 1   sub to_embed { shift->{html} || '' }
34              
35             1;
36              
37             =encoding utf8
38              
39             =head1 NAME
40              
41             Mojolicious::Plugin::LinkEmbedder::Link::Image::Instagram - instagram.com image or video
42              
43             =head1 DESCRIPTION
44              
45             This class inherits from L.
46              
47             =head1 METHODS
48              
49             =head2 learn
50              
51             Gets the file imformation from the page meta information
52              
53             =head2 to_embed
54              
55             Returns markup.
56              
57             =head1 SEE ALSO
58              
59             L.
60              
61             =cut