File Coverage

blib/lib/Devel/IPerl/Display/Role/Source.pm
Criterion Covered Total %
statement 21 21 100.0
branch 6 6 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 32 33 96.9


line stmt bran cond sub pod time code
1             $Devel::IPerl::Display::Role::Source::VERSION = '0.012';
2             use strict;
3 2     2   1215 use warnings;
  2         4  
  2         56  
4 2     2   10  
  2         3  
  2         59  
5             use Moo::Role;
6 2     2   8  
  2         4  
  2         17  
7             has [ qw[bytestream filename uri] ] => ( is => 'rw' );
8              
9             my ( $class, @args ) = @_;
10              
11 9     9 0 10717 # if first arg is data that needs to be determined
12             if( @args % 2 == 1 ) {
13             my $data = shift @args;
14 9 100       29 if( $data =~ /^http[s]?:/ ) {
15 8         11 unshift @args, uri => $data;
16 8 100       25 } elsif( eval { no warnings qw(newline); -f $data } ) {
    100          
17 2         11 # using no warnings/eval to avoid warning about newline in filename
18 2     2   994 unshift @args, filename => $data;
  2         4  
  2         204  
  6         160  
19             } else {
20 4         163 unshift @args, bytestream => $data;
21             }
22 2         9 }
23              
24             return { @args };
25             };
26 9         169  
27             1;
28              
29              
30             =pod
31              
32             =encoding UTF-8
33              
34             =head1 NAME
35              
36             Devel::IPerl::Display::Role::Source
37              
38             =head1 VERSION
39              
40             version 0.012
41              
42             =head1 AUTHOR
43              
44             Zakariyya Mughal <zmughal@cpan.org>
45              
46             =head1 COPYRIGHT AND LICENSE
47              
48             This software is copyright (c) 2014 by Zakariyya Mughal.
49              
50             This is free software; you can redistribute it and/or modify it under
51             the same terms as the Perl 5 programming language system itself.
52              
53             =cut