File Coverage

blib/lib/Mojolicious/Plugin/LinkEmbedder/Link/Video/Vimeo.pm
Criterion Covered Total %
statement 3 13 23.0
branch 0 4 0.0
condition 0 4 0.0
subroutine 1 4 25.0
pod 0 3 0.0
total 4 28 14.2


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::LinkEmbedder::Link::Video::Vimeo;
2 1     1   2256 use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text::HTML';
  1         3  
  1         6  
3              
4             has media_id => sub {
5             my $self = shift;
6             my $media_id = $self->url->path->[-1];
7              
8             $media_id =~ s!\.html$!!;
9             $media_id;
10             };
11              
12 0     0 0   sub provider_name {'Vimeo'}
13              
14             sub learn {
15 0     0 0   my ($self, $c, $cb) = @_;
16              
17 0 0         return $self->SUPER::learn($c, $cb) unless $self->media_id;
18 0           $self->$cb;
19 0           $self;
20             }
21              
22             sub to_embed {
23 0     0 0   my $self = shift;
24 0 0         my $media_id = $self->media_id or return $self->SUPER::to_embed;
25 0           my $src = Mojo::URL->new('//player.vimeo.com/video/86404451?portrait=0&color=ffffff');
26 0           my %args = @_;
27              
28             $self->_iframe(
29             src => "//player.vimeo.com/video/$media_id?portrait=0&color=ffffff",
30             class => 'link-embedder video-vimeo',
31             width => $args{width} || 500,
32 0   0       height => $args{height} || 281
      0        
33             );
34             }
35              
36             1;