File Coverage

lib/Data/Processor/Generator.pm
Criterion Covered Total %
statement 22 22 100.0
branch 10 10 100.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 36 37 97.3


line stmt bran cond sub pod time code
1 19     19   272 use 5.10.1;
  19         86  
2 19     19   123 use strict;
  19         41  
  19         636  
3 19     19   117 use warnings;
  19         37  
  19         4271  
4             package Data::Processor::Generator;
5              
6             # make template: recursive tree traversal
7             sub make_data_template{
8 17     17 0 17 my $schema_section = shift;
9              
10 17         19 my $data = {};
11              
12 17         22 for my $key (sort keys %{$schema_section}){
  17         37  
13              
14             # data keys always are hashes in schema.
15 26 100       55 if (ref $schema_section->{$key} eq ref {} ){
16 19 100       25 if ($key eq 'members'){
17             # "members" indicates children but is not written in data
18             return make_data_template(
19 5         13 $schema_section->{$key},
20             );
21             }
22             else{
23 14 100       22 if (exists $schema_section->{$key}->{description}){
24             $data->{$key} = $schema_section->{$key}->{description}
25 8         24 }
26              
27 14 100       27 if (exists $schema_section->{$key}->{value}){
28 4         9 $data->{$key} .= $schema_section->{$key}->{value};
29             }
30              
31             # we guess that if a section does not have a value
32             # we might be interested in entering into it, too
33             # Inversely, if there is a value, it is an end-point.
34 14 100       22 if (! exists $schema_section->{$key}->{value}){
35             $data->{$key} = make_data_template(
36 10         19 $schema_section->{$key},
37             );
38             }
39             }
40             }
41             }
42 12         27 return $data;
43             }
44              
45              
46             1