line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
$Devel::IPerl::Display::Role::MIMESource::VERSION = '0.012'; |
2
|
|
|
|
|
|
|
use strict; |
3
|
2
|
|
|
2
|
|
9645
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
use autodie; |
6
|
2
|
|
|
2
|
|
1382
|
use Moo::Role; |
|
2
|
|
|
|
|
25524
|
|
|
2
|
|
|
|
|
9
|
|
7
|
2
|
|
|
2
|
|
11642
|
use MooX::Types::MooseLike::Base qw(Bool); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
20
|
|
8
|
2
|
|
|
2
|
|
2368
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
11715
|
|
|
2
|
|
|
|
|
154
|
|
9
|
2
|
|
|
2
|
|
1295
|
use MIME::Base64; |
|
2
|
|
|
|
|
86509
|
|
|
2
|
|
|
|
|
68
|
|
10
|
2
|
|
|
2
|
|
986
|
use Path::Class; |
|
2
|
|
|
|
|
1269
|
|
|
2
|
|
|
|
|
115
|
|
11
|
2
|
|
|
2
|
|
372
|
|
|
2
|
|
|
|
|
30949
|
|
|
2
|
|
|
|
|
837
|
|
12
|
|
|
|
|
|
|
with qw(Devel::IPerl::Display::Role::Source Devel::IPerl::Display::Role::MIMEType); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has use_data_uri => ( is => 'rw', isa => Bool, default => sub { 1 } ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has _data => ( is => 'lazy', clearer => 1, builder => 1 ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
if( $self->bytestream ) { |
20
|
5
|
|
|
5
|
|
36
|
return $self->bytestream; |
21
|
5
|
50
|
|
|
|
25
|
} elsif( $self->filename ) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
my $data = file( $self->filename )->slurp( iomode => '<:raw' ); |
23
|
|
|
|
|
|
|
return $data; |
24
|
5
|
|
|
|
|
32
|
} elsif( $self->uri ) { |
25
|
5
|
|
|
|
|
1418
|
my $ua = LWP::UserAgent->new(); |
26
|
|
|
|
|
|
|
my $response = $ua->get( $self->uri ); |
27
|
0
|
|
|
|
|
0
|
die "Could not retrieve data" unless $response->is_success; |
28
|
0
|
|
|
|
|
0
|
my $data = $response->decoded_content; |
29
|
0
|
0
|
|
|
|
0
|
return $data; |
30
|
0
|
|
|
|
|
0
|
} |
31
|
0
|
|
|
|
|
0
|
die "No data to build display"; # TODO create exception class |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
my ($self) = @_; |
35
|
|
|
|
|
|
|
if( $self->bytestream || $self->use_data_uri ) { |
36
|
|
|
|
|
|
|
return "data:@{[ $self->mimetype ]};base64,@{[ encode_base64($self->_data) ]}"; |
37
|
5
|
|
|
5
|
|
10
|
} elsif( $self->uri ) { |
38
|
5
|
100
|
66
|
|
|
123
|
return $self->uri; |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
39
|
4
|
|
|
|
|
31
|
} elsif( $self->filename ) { |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
54
|
|
40
|
|
|
|
|
|
|
return file($self->filename)->absolute; # TODO should this be a URI? Use Path::Class:URI for that. |
41
|
0
|
|
|
|
|
0
|
} |
42
|
|
|
|
|
|
|
} |
43
|
1
|
|
|
|
|
22
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=encoding UTF-8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Devel::IPerl::Display::Role::MIMESource |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 VERSION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
version 0.012 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AUTHOR |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Zakariyya Mughal <zmughal@cpan.org> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Zakariyya Mughal. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
68
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |