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 9     9   49 use strict;
  9         15  
  9         302  
4 9     9   37 use warnings;
  9         24  
  9         445  
5              
6 9     9   42 use vars qw($VERSION);
  9         13  
  9         387  
7             BEGIN {
8 9     9   206 $VERSION='2.29'; # version template
9             }
10 9     9   35 no warnings 'uninitialized';
  9         42  
  9         471  
11 9     9   42 use Carp;
  9         12  
  9         529  
12 9     9   42 use Treex::PML::Schema::Constants;
  9         41  
  9         740  
13 9     9   40 use base qw(Treex::PML::Schema::XMLNode);
  9         11  
  9         3896  
14              
15 6     6 1 41 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 68     68 1 142 my ($template,$opts)=@_;
20 68         163 for my $c (
21 40         85 sort {$a->{'-#'} <=> $b->{'-#'}}
22 11         23 ((map { @{$template->{$_}} } grep {exists $template->{$_} } qw(copy import)),
  11         33  
  136         360  
23 12         16 (map { values %{$template->{$_}} } grep {exists $template->{$_} } qw(template derive)))) {
  12         85  
  136         302  
24             # print STDERR "Processing <$c->{-xml_name}>\n";
25 36         200 $c->simplify($opts);
26             }
27 68 50       284 delete $template->{template} unless $opts->{'preserve_templates'};
28 68 50       219 delete $template->{copy} unless $opts->{'no_copy'};
29 68         161 for (qw(derive import)) {
30 136 100       322 if ($template->get_decl_type == PML_TEMPLATE_DECL) {
31 2 50       17 delete $template->{$_} unless $opts->{'no_template_'.$_};
32             } else {
33 134 50       459 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__