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