File Coverage

blib/lib/Mojolicious/Plugin/LinkEmbedder/Link/Video/Collegehumor.pm
Criterion Covered Total %
statement 3 16 18.7
branch 0 4 0.0
condition 0 4 0.0
subroutine 1 4 25.0
pod 3 3 100.0
total 7 31 22.5


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::LinkEmbedder::Link::Video::Collegehumor;
2              
3             =head1 NAME
4              
5             Mojolicious::Plugin::LinkEmbedder::Link::Video::Collegehumor - collegehumor.com link
6              
7             =head1 DESCRIPTION
8              
9             This class inherit from L.
10              
11             =cut
12              
13 1     1   377 use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text::HTML';
  1         13  
  1         4  
14              
15             =head1 ATTRIBUTES
16              
17             =head2 media_id
18              
19             Returns the the digit from the second path part from L.
20              
21             =head2 provider_name
22              
23             =cut
24              
25             has media_id => sub { shift->url->path =~ m!/(\d+)/! ? $1 : '' };
26 0     0 1   sub provider_name {'Collegehumor'}
27              
28             =head1 METHODS
29              
30             =head2 learn
31              
32             =cut
33              
34             sub learn {
35 0     0 1   my ($self, $c, $cb) = @_;
36              
37 0 0         if ($self->media_id) {
38 0           $self->$cb;
39             }
40             else {
41 0           $self->SUPER::learn($c, $cb);
42             }
43              
44 0           return $self;
45             }
46              
47             =head2 to_embed
48              
49             Returns the HTML code for an iframe embedding this movie.
50              
51             =cut
52              
53             sub to_embed {
54 0     0 1   my $self = shift;
55 0 0         my $media_id = $self->media_id or return $self->SUPER::to_embed;
56 0           my $src = Mojo::URL->new('http://www.collegehumor.com/e');
57 0           my %args = @_;
58              
59 0           push @{$src->path}, $media_id;
  0            
60              
61 0   0       $self->_iframe(
      0        
62             src => $src,
63             class => 'link-embedder video-collegehumor',
64             width => $args{width} || 600,
65             height => $args{height} || 369
66             );
67             }
68              
69             =head1 AUTHOR
70              
71             Marcus Ramberg
72              
73             =cut
74              
75             1;