File Coverage

lib/Rex/File/Parser/Data.pm
Criterion Covered Total %
statement 27 28 96.4
branch 6 6 100.0
condition 1 3 33.3
subroutine 5 6 83.3
pod 0 3 0.0
total 39 46 84.7


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::File::Parser::Data;
6              
7 45     45   597 use v5.12.5;
  45         178  
8 45     45   992 use warnings;
  45         228  
  45         14032  
9              
10             our $VERSION = '1.14.2.3'; # TRIAL VERSION
11              
12             sub new {
13 4     4 0 10 my $that = shift;
14 4   33     23 my $proto = ref($that) || $that;
15 4         12 my $self = {@_};
16              
17 4         11 bless( $self, $proto );
18              
19 4         11 return $self;
20             }
21              
22             sub read {
23 4     4 0 12 my ( $self, $file ) = @_;
24 4         14 return $self->_read_file($file);
25             }
26              
27             sub _read_file {
28 4     4   9 my ( $self, $file ) = @_;
29              
30 4         9 my $content = "";
31              
32 4         5 my $in_file = 0;
33 4         8 for my $line ( @{ $self->{"data"} } ) {
  4         19  
34 426         573 chomp $line;
35              
36 426 100       648 if ( $line eq "\@end" ) {
37 10         18 $in_file = 0;
38 10         17 next;
39             }
40              
41 416 100       599 if ($in_file) {
42 170         258 $content .= $line . $/;
43             }
44              
45 416 100       725 if ( $line eq "\@$file" ) {
46 4         7 $in_file = 1;
47 4         7 next;
48             }
49             }
50              
51 4         38 return $content;
52             }
53              
54             sub get {
55 0     0 0   my ( $self, $file ) = @_;
56             }
57              
58             1;