File Coverage

blib/lib/Treex/PML/Schema/Template.pm
Criterion Covered Total %
statement 39 47 82.9
branch 6 12 50.0
condition n/a
subroutine 10 12 83.3
pod 4 4 100.0
total 59 75 78.6


line stmt bran cond sub pod time code
1             package Treex::PML::Schema::Template;
2              
3 8     8   51 use strict;
  8         14  
  8         305  
4 8     8   40 use warnings;
  8         23  
  8         461  
5              
6 8     8   44 use vars qw($VERSION);
  8         15  
  8         381  
7             BEGIN {
8 8     8   192 $VERSION='2.28'; # version template
9             }
10 8     8   52 no warnings 'uninitialized';
  8         15  
  8         384  
11 8     8   76 use Carp;
  8         15  
  8         549  
12 8     8   51 use Treex::PML::Schema::Constants;
  8         13  
  8         901  
13 8     8   44 use base qw(Treex::PML::Schema::XMLNode);
  8         13  
  8         4313  
14              
15 6     6 1 22 sub get_decl_type { return(PML_TEMPLATE_DECL); }
16 0     0 1 0 sub get_decl_type_str { return('template'); }
17              
18             sub simplify {
19 67     67 1 199 my ($template,$opts)=@_;
20 67         198 for my $c (
21 40         97 sort {$a->{'-#'} <=> $b->{'-#'}}
22 11         17 ((map { @{$template->{$_}} } grep {exists $template->{$_} } qw(copy import)),
  11         46  
  134         473  
23 12         22 (map { values %{$template->{$_}} } grep {exists $template->{$_} } qw(template derive)))) {
  12         81  
  134         440  
24             # print STDERR "Processing <$c->{-xml_name}>\n";
25 36         219 $c->simplify($opts);
26             }
27 67 50       378 delete $template->{template} unless $opts->{'preserve_templates'};
28 67 50       222 delete $template->{copy} unless $opts->{'no_copy'};
29 67         211 for (qw(derive import)) {
30 134 100       443 if ($template->get_decl_type == PML_TEMPLATE_DECL) {
31 2 50       10 delete $template->{$_} unless $opts->{'no_template_'.$_};
32             } else {
33 132 50       627 delete $template->{$_} unless $opts->{'no_'.$_};
34             }
35             }
36             }
37             sub for_each_decl {
38 0     0 1   my ($self,$sub)=@_;
39 0           $sub->($self);
40 0           for my $d (qw(template type)) {
41 0 0         if (ref $self->{$d}) {
42 0           foreach (values %{$self->{$d}}) {
  0            
43 0           $_->for_each_decl($sub);
44             }
45             }
46             }
47             }
48              
49              
50              
51             1;
52             __END__