File Coverage

blib/lib/Devel/IPerl/Display/Role/WebImage.pm
Criterion Covered Total %
statement 15 17 88.2
branch 2 4 50.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 21 26 80.7


line stmt bran cond sub pod time code
1             # ABSTRACT: A role for image objects that is used to generate HTML with parameters such as geometry.
2             $Devel::IPerl::Display::Role::WebImage::VERSION = '0.012';
3             use strict;
4 2     2   1113 use warnings;
  2         3  
  2         57  
5 2     2   9  
  2         3  
  2         46  
6             use Moo::Role;
7 2     2   9  
  2         3  
  2         11  
8             with qw(Devel::IPerl::Display::Role::Displayable);
9              
10             requires '_as_text_plain';
11             requires 'mimetype';
12              
13             has [ qw[width height] ] => ( is => 'rw', predicate => 1 );
14              
15             my ($self) = @_;
16             my $data = $self->_data; # TODO when data is not retrievable
17 5     5 0 213 return {
18 5         64 $self->mimetype => $data,
19             "text/plain" => $self->_as_text_plain,
20 5         27 "text/html" => qq|<img
21             @{[ $self->has_width ? qq,width="@{[$self->width]}", : "" ]}
22             @{[ $self->has_height ? qq,height="@{[$self->height]}", : "" ]}
23 5 50       26 src="@{[ $self->_html_uri ]}" />|,
  0         0  
24 5 50       22 };
  0         0  
25 5         12 }
26              
27             1;
28              
29              
30             =pod
31              
32             =encoding UTF-8
33              
34             =head1 NAME
35              
36             Devel::IPerl::Display::Role::WebImage - A role for image objects that is used to generate HTML with parameters such as geometry.
37              
38             =head1 VERSION
39              
40             version 0.012
41              
42             =head1 SYNOPSIS
43              
44             my $web_image = Displayable::With::WebImage->new(
45             data => "...",
46             width => '100px',
47             height => '200px' );
48              
49             =head1 DESCRIPTION
50              
51             This role returns an HTML representation that takes into account the height and
52             width.
53              
54             =head1 AUTHOR
55              
56             Zakariyya Mughal <zmughal@cpan.org>
57              
58             =head1 COPYRIGHT AND LICENSE
59              
60             This software is copyright (c) 2014 by Zakariyya Mughal.
61              
62             This is free software; you can redistribute it and/or modify it under
63             the same terms as the Perl 5 programming language system itself.
64              
65             =cut