]> git.donarmstrong.com Git - biopieces.git/blob - code_perl/Maasha/DumpFunc.pm
migrated count_records
[biopieces.git] / code_perl / Maasha / DumpFunc.pm
1 package Maasha::DumpFunc;
2
3 # Copyright (C) 2003 Martin A. Hansen.
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 # http://www.gnu.org/copyleft/gpl.html
20
21
22 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
23
24
25 # Routines to inspect objects and their inheritance.
26
27
28 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
29
30
31 use strict;
32 use Class::Inspector;
33 use vars qw ( @ISA @EXPORT );
34 use Exporter;
35
36 use Data::Dumper;
37
38 @ISA = qw( Exporter );
39
40
41 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
42
43
44 sub dump_func
45 {
46     # Martin A. Hansen, August 2003.
47
48     # given an object, the cognate functions are returned as a list
49
50     my ( $obj,   # incomming object
51        ) = @_;
52
53     my ( $ref, $methods );
54
55     $ref     = ref $obj;
56     $methods = Class::Inspector->methods( $ref, 'full', 'public' );
57
58 #    @{ $methods } = grep /$ref/, @{ $methods };
59
60     return wantarray ? @{ $methods } : $methods;
61 }
62
63
64 sub dump_test
65 {
66     # Martin A. Hansen, August 2003.
67
68     # given an object, returns the cognate function run with default values
69
70     my ( $obj ,    # incomming object
71        ) = @_;
72
73     # returns a list of test lines to be printed
74
75     my ( $methods, $method, $function, @lines );
76     
77     $methods = dump_func( $obj );
78     
79     foreach $method ( @{ $methods } )
80     {
81         $method   =~ /::(\w+)$/;
82         $function = $1;
83         next if not eval { $obj->$function };
84         
85         # push @lines, "Testing $function from $method --- Returns -> " . $obj->$function;
86         print "TESTING $function FROM $method: RETURNS->" . $obj->$function . "\n";
87     }
88
89     return wantarray ? @lines : \@lines;
90 }
91
92
93 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<