File Coverage

blib/lib/Eixo/Base/Data.pm
Criterion Covered Total %
statement 17 26 65.3
branch 1 6 16.6
condition n/a
subroutine 4 5 80.0
pod 0 2 0.0
total 22 39 56.4


line stmt bran cond sub pod time code
1             package Eixo::Base::Data;
2              
3 1     1   494 use strict;
  1         1  
  1         25  
4 1     1   290 use Eixo::Base::Clase;
  1         1  
  1         3  
5              
6             sub getDataBySections{
7 0     0 0 0 my ($module) = @_;
8              
9 0         0 my $data = &getData($module);
10              
11 0         0 my $sections = {};
12 0         0 my $section_name = undef;
13              
14 0         0 foreach my $l (split(/\n/, $data)){
15              
16 0 0       0 if($l =~ /^\s*\@\@(\w+)/){
17 0         0 $section_name = $1;
18             }
19             else{
20 0 0       0 $sections->{$section_name} .= "$l\n" if($section_name);
21             }
22             }
23              
24 0         0 $sections;
25             }
26              
27             sub getData{
28 2     2 0 1330 my ($module) = @_;
29              
30 1     1   7 no strict 'refs';
  1         1  
  1         69  
31              
32 2         2 my $f = \*{$module . '::DATA'};
  2         4  
33              
34 2 50       5 return undef unless(defined($f));
35              
36 2         6 my $pos = tell($f);
37              
38 2         18 my $datos = join('', <$f>);
39              
40 2         5 seek($f, $pos, 0);
41              
42 2         5 return $datos;
43             }
44              
45             1;