File Coverage

blib/lib/App/Modular/Module.pm
Criterion Covered Total %
statement 24 26 92.3
branch 2 4 50.0
condition n/a
subroutine 8 9 88.8
pod 4 4 100.0
total 38 43 88.3


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             #----------------------------------------------------------------------------
3             # App::Modular - perl program modularization framewok
4             # App::Modular/module.pm: base class for all modules
5             #
6             # Copyright (c) 2003-2004 Baltasar Cevc
7             #
8             # This code is released under the L Perl Artistic
9             # License, which can should be accessible via the C
10             # perlartistic> command and the file COPYING provided with this
11             #
12             # DISCLAIMER: THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND
13             # COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
14             # IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY
15             # OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE
16             # OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
17             # TRADEMARKS OR OTHER RIGHTS.
18             # IF YOU USE THIS SOFTWARE, YOU DO SO AT YOUR OWN RISK.
19             #
20             # See this internet site for more details: http://technik.juz-kirchheim.de/
21             #
22             # Creation: 02.12.03 bc
23             # Last Update: 06.04.08 bc
24             # Version: 0. 1. 3
25             # ----------------------------------------------------------------------------
26              
27             ###################
28             ### ###
29             ### "PREFIX" ###
30             ### ###
31             ###################
32             ###################
33             # Pragma #
34             ###################
35 4     4   3129 use strict;
  4         9  
  4         127  
36 4     4   24 use warnings;
  4         7  
  4         138  
37 4     4   97 use 5.006_001;
  4         14  
  4         261  
38              
39             ###################
40             # Module #
41             ###################
42             package App::Modular::Module;
43              
44 4     4   22 use vars qw($VERSION);
  4         8  
  4         1889  
45             $VERSION=0.001_003;
46              
47             ###################
48             ### ###
49             ### MENTHODS ###
50             ### ###
51             ###################
52             sub module_init {
53 18     18 1 6376 my $self = {};
54 18         30 my $type = shift;
55 18         43 $self->{'module_name'} = $type;
56 18 50       93 substr $self->{'module_name'}, 0,
57             length ("App::Modular::module::"), ''
58             if ( (index $self->{'module_name'}, "App::Modular::Module::") == 0);
59 18         80 $self->{'modularizer'} = App::Modular->instance();
60 18         248 $self->{'modularizer'}->mlog (99, "module $self->{'module_name'}:".
61             " blessed myself!");
62 18         150 return bless $self, $type;
63             };
64              
65             sub module_name {
66 0     0 1 0 my ($self) = @_;
67            
68 0         0 return $self->{'module_name'};
69             };
70              
71             sub modularizer {
72 50     50 1 184 my $self = shift;
73 50         226 return $self->{'modularizer'};
74             };
75              
76             sub DESTROY {
77 8     8   28 my ($self) = @_;
78             # foreach (keys %$self) { print "+++ $_:{".$self->{$_}."}\n"; }
79 8 50       41 $self->modularizer()->mlog (99, "module $self->{'module_name'}:".
80             " going to be destroyed")
81             if ($self->modularizer());
82             };
83              
84             sub module_depends {
85 14     14 1 141 return;
86             };
87              
88             ###################
89             ### ###
90             ###DOCUMENTATION###
91             ### ###
92             ###################
93             =pod
94              
95             =head1 NAME
96              
97             App::Modular::Module - App::Modular module base class.
98              
99             =head1 SYNOPSIS
100              
101             #!/usr/bin/perl -w
102             use strict;
103              
104             package App::Modular::Module::Dummy;
105              
106             use modularizer;
107             use base qw(App::Modular::Module);
108              
109             # a complete do-noting module :-)
110              
111             1;
112            
113             =head1 USAGE
114              
115             See L (secction 'usage') for an example.
116              
117             =head1 DESCRIPTION
118              
119             This class should be used as a base class for every modularizer
120             module. It provides some base methods to cleanly initialize and
121             destroy the module.
122             Every
123              
124             =head1 Creating a new module
125              
126             See the examples in the documentation of L for details.
127              
128             =head1 REFERENCE
129              
130             In this section I will describe the standard methods that every single module
131             inheritfs from the master module. The standard aparameters are described, too.
132              
133             =head2 Internal data
134              
135             Every module that @IS-A App::Modular::Module will be a blessed hash reference.
136             In this hash, you will find some default data, too.
137              
138             =over 4
139              
140             =item $self->{'module_name'} -> name of Module (= package name without
141             App::Modular::Module::)
142              
143             =item $self->{'modularizer'} -> instance of App::Modular
144              
145             =back
146              
147             =head2 Methods
148              
149             =over 4
150              
151             =item module_init
152              
153             Initialize a module (and create a blessed object for it).
154              
155             Return value: (ref) reference to the module object
156              
157             =item module_name
158              
159             Returns the internal module name.
160              
161             Return value: (string) name of the current module
162              
163             =item modularizer
164              
165             Returns the reference to the modularizer object.
166              
167             Return value: (ref) instance of App::Module
168              
169             =item DESTROY
170              
171             The standard destructor for modules (log the destruction, no
172             other action taken).
173              
174             =item module_depends
175              
176             Returns the module dependencies (none by default).
177              
178             Return value: (array of strings) names of the modules I depend on
179              
180             =back
181              
182             =head1 AUTHOR and COPYRIGHT
183              
184             (c) 2004 Baltasar Cevc
185              
186             This code is released under the L Perl Artistic
187             License, which can should be accessible via the C
188             perlartistic> command and the file COPYING provided with this
189             package.
190              
191             =head1 SEE ALSO
192              
193             L
194              
195             =cut
196             1;