blib/lib/OODoc/Text/Chapter.pm untested

filter: Statementstmt 0.0% 0 / 63 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 12 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 111 CC 7 SCAR 17.3
CC
7
Cov
0%
findSubroutine
12.0
findEntry
12.0
section
6.0
CRAP 5.6
1 # Copyrights 2003-2015 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5  
6 package OODoc::Text::Chapter;
7 use vars '$VERSION';
8 $VERSION = '2.01';
9  
10 use base 'OODoc::Text::Structure';
11  
12 use strict;
13 use warnings;
14  
15 use Log::Report 'oodoc';
16 use List::Util 'first';
17  
18  
19 sub init($)
20 { my ($self, $args) = @_;
21 $args->{type} ||= 'Chapter';
22 $args->{container} ||= delete $args->{manual} or panic;
23 $args->{level} ||= 1;
24  
25 $self->SUPER::init($args)
26 or return;
27  
28 $self->{OTC_sections} = [];
29  
30 $self;
31 }
32  
33 sub emptyExtension($)
34 { my ($self, $container) = @_;
35 my $empty = $self->SUPER::emptyExtension($container);
36 my @sections = map $_->emptyExtension($empty), $self->sections;
37 $empty->sections(@sections);
38 $empty;
39 }
40  
41 sub manual() {shift->container}
42 sub path() {shift->name}
43  
44 sub findSubroutine($)
45 { my ($self, $name) = @_;
46 my $sub = $self->SUPER::findSubroutine($name);
47 return $sub if defined $sub;
48  
49 foreach my $section ($self->sections)
50 { my $sub = $section->findSubroutine($name);
51 return $sub if defined $sub;
52 }
53  
54 undef;
55 }
56  
57 sub findEntry($)
58 { my ($self, $name) = @_;
59 return $self if $self->name eq $name;
60  
61 foreach my $section ($self->sections)
62 { my $entry = $section->findEntry($name);
63 return $entry if defined $entry;
64 }
65  
66 ();
67 }
68  
69 sub all($@)
70 { my $self = shift;
71 ($self->SUPER::all(@_), map {$_->all(@_)} $self->sections);
72 }
73  
74  
75 sub section($)
76 { my ($self, $thing) = @_;
77  
78 if(ref $thing)
79 { push @{$self->{OTC_sections}}, $thing;
80 return $thing;
81 }
82  
83 first {$_->name eq $thing} $self->sections;
84 }
85  
86  
87 sub sections()
88 { my $self = shift;
89 if(@_)
90 { $self->{OTC_sections} = [ @_ ];
91 $_->container($self) for @_;
92 }
93 @{$self->{OTC_sections}};
94 }
95  
96 1;