line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::DatabaseThing::Profiler; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2004 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::DatabaseThing::Profiler.pm |
11
|
|
|
|
|
|
|
# Description: Provide a profile of a database Thing |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 17/10/2005 Version 1 |
16
|
|
|
|
|
|
|
# 17/10/2005 Added method: getRow |
17
|
|
|
|
|
|
|
# 18/10/2005 Created test file: TableProfilerTest.tpm |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
############################################################################### |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
4614
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
7
|
use Goo::List; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
24
|
1
|
|
|
1
|
|
8
|
use Goo::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
25
|
1
|
|
|
1
|
|
6
|
use Goo::Header; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
26
|
1
|
|
|
1
|
|
7
|
use Goo::Profile; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
27
|
1
|
|
|
1
|
|
7
|
use Goo::Prompter; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
28
|
1
|
|
|
1
|
|
8
|
use Text::FormatTable; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
5
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
421
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# get_row_table - return the object in a table |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
############################################################################### |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get_row_table { |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
|
my ($this, $profile, $thing) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $table = Text::FormatTable->new('4l 20l 77l'); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$table->head('', 'Columns', ''); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$table->rule('-'); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $dbo = $thing->get_database_object(); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
foreach my $column ($thing->get_columns()) { |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $index_key = $profile->get_next_index_key(); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$profile->add_option($index_key, $column, "Goo::DatabaseProfileOption"); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# print "addin conter === $counter \n"; |
58
|
0
|
|
|
|
|
|
$table->row("[$index_key]", $column, $dbo->{$column}); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return Goo::Prompter::highlight_options($table->render()); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
############################################################################### |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# run - return a table of methods |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
############################################################################### |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub run { |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
my ($this, $thing) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $profile = Goo::Profile->new($thing); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
while (1) { |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$profile->clear(); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$profile->show_header(ucfirst($thing->{table}) . " Profile", |
84
|
|
|
|
|
|
|
$thing->get_filename(), |
85
|
|
|
|
|
|
|
"database"); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# profile the database object |
88
|
0
|
|
|
|
|
|
my $table_row = $this->get_row_table($profile, $thing); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# render a table of method signatures and descriptions |
91
|
0
|
|
|
|
|
|
$profile->add_rendered_table($table_row); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# add a list of Things found in this Thing |
94
|
0
|
|
|
|
|
|
$profile->add_things_table($table_row); |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
$profile->display(); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# show the profile and all the rendered tables |
99
|
|
|
|
|
|
|
# $profile->display(); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# prompt the user for the next command |
102
|
0
|
|
|
|
|
|
$profile->get_command(); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 NAME |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Goo::DatabaseThing::Profiler - Show a profile of a database Thing |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SYNOPSIS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
use Goo::DatabaseThing::Profiler; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DESCRIPTION |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 METHODS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item get_row_table |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
return the object in a table |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item run |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
return a table of methods |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SEE ALSO |
147
|
|
|
|
|
|
|
|