line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::Loader; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::Loader.pm |
11
|
|
|
|
|
|
|
# Description: Load a Thing from Goo Space |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 28/06/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 28/06/2005 Need a simple loader |
17
|
|
|
|
|
|
|
# 17/10/2005 Added method: get_maker |
18
|
|
|
|
|
|
|
# 17/10/2005 Added method: get_suffix |
19
|
|
|
|
|
|
|
# 12/11/2005 Needed to make the loader be more specifc |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
############################################################################### |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
4
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
563
|
use Goo::Database; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
28
|
1
|
|
|
1
|
|
785
|
use Goo::Prompter; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
31
|
|
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
651
|
use Goo::FileThing; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
30
|
|
31
|
1
|
|
|
1
|
|
562
|
use Goo::ConfigFile; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
32
|
1
|
|
|
1
|
|
588
|
use Goo::DatabaseThing; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
33
|
1
|
|
|
1
|
|
487
|
use Goo::FileThing::Finder; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
694
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
############################################################################### |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# load - return a thang |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
############################################################################### |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub load { |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
1
|
|
my ($filename) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# special allowance for the mighty perl! |
47
|
|
|
|
|
|
|
# map packages to filenames |
48
|
0
|
|
|
|
|
|
$filename =~ s/::/\//g; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# grab the config file for this type of Thing |
51
|
0
|
|
|
|
|
|
my $config_file = Goo::ConfigFile->new(get_suffix($filename) . ".goo"); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# need to return a Thing |
54
|
0
|
|
|
|
|
|
my $thing; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# it must be a file based Thing |
57
|
0
|
0
|
|
|
|
|
if ($config_file->has_locations()) { |
|
|
0
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $full_path; |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if (-e $filename) { |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# is the filename relative or absolute? return the path |
64
|
0
|
0
|
|
|
|
|
$full_path = |
65
|
|
|
|
|
|
|
($filename =~ /^\//) |
66
|
|
|
|
|
|
|
? $filename |
67
|
|
|
|
|
|
|
: getcwd() . "/" . $filename; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} else { |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# file doesn't exist in current location - lets go looking |
72
|
0
|
|
|
|
|
|
$full_path = Goo::FileFinder::find($filename, $config_file->get_locations()); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# we have a full_path to this FileThing |
76
|
0
|
|
|
|
|
|
$thing = Goo::FileThing->new($full_path); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} elsif ($config_file->has_table()) { |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# this is a DatabaseThing look it up in the database |
81
|
|
|
|
|
|
|
# for example grab a bug (e.g., 12.bug) |
82
|
0
|
|
|
|
|
|
$thing = Goo::DatabaseThing->new($filename); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} else { |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# this is a GooThing with no location |
87
|
|
|
|
|
|
|
# for example: care.goo - base it on the .goo file |
88
|
|
|
|
|
|
|
# this enables us to have controller Things without |
89
|
|
|
|
|
|
|
# a location - [Z]one, Care[O]Meter etc. |
90
|
0
|
|
|
|
|
|
$thing = Goo::Thing->new($filename); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
unless ($thing->isa("Goo::Thing")) { |
95
|
0
|
|
|
|
|
|
die("Unable to load Thing for $filename."); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $thing; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
############################################################################### |
104
|
|
|
|
|
|
|
# |
105
|
|
|
|
|
|
|
# get_maker - things must be made first! |
106
|
|
|
|
|
|
|
# |
107
|
|
|
|
|
|
|
############################################################################### |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub get_maker { |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
0
|
1
|
|
my ($filename) = @_; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
print "FILENAME: $filename\n"; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# get the config file for this Thing! |
116
|
0
|
|
|
|
|
|
my $config_file = Goo::ConfigFile->new(get_suffix($filename) . '.goo'); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# get the Maker that creates this Thing |
119
|
0
|
|
|
|
|
|
my $maker = $config_file->get_program('M'); |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if ($maker ne '') { |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# dynamically load the maker - remove absolute path later |
124
|
0
|
|
|
|
|
|
my $require_filename = $maker; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# convert package to directories |
127
|
0
|
|
|
|
|
|
$require_filename =~ s/::/\//g; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
require "$require_filename"; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# strip any .pm off the end |
132
|
0
|
|
|
|
|
|
$maker =~ s/.pm$//; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# return the maker object |
135
|
0
|
|
|
|
|
|
return $maker->new(); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
############################################################################### |
141
|
|
|
|
|
|
|
# |
142
|
|
|
|
|
|
|
# get_prefix - return the goo prefix |
143
|
|
|
|
|
|
|
# |
144
|
|
|
|
|
|
|
############################################################################### |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub get_prefix { |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
0
|
1
|
|
my ($filename) = @_; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# strip the path if there is one |
151
|
0
|
|
|
|
|
|
$filename =~ s!.*/!!; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# match the suffix |
154
|
0
|
|
|
|
|
|
$filename =~ m/(.*)\.*$/; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# match the suffix (.pm) or the whole Thing (task) |
157
|
0
|
|
0
|
|
|
|
return $1 || $filename; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
############################################################################### |
163
|
|
|
|
|
|
|
# |
164
|
|
|
|
|
|
|
# get_suffix - return the goo prefix |
165
|
|
|
|
|
|
|
# |
166
|
|
|
|
|
|
|
############################################################################### |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub get_suffix { |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
0
|
1
|
|
my ($filename) = @_; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# strip the path if there is one |
173
|
0
|
|
|
|
|
|
$filename =~ s!.*/!!; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# match the suffix |
176
|
0
|
|
|
|
|
|
$filename =~ m/.*\.(.*)$/; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# match the suffix (.pm) or the whole Thing (task) |
179
|
0
|
|
0
|
|
|
|
return $1 || $filename; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
############################################################################### |
185
|
|
|
|
|
|
|
# |
186
|
|
|
|
|
|
|
# run_driver - drive the module from the command line |
187
|
|
|
|
|
|
|
# |
188
|
|
|
|
|
|
|
############################################################################### |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub run_driver { |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
0
|
1
|
|
my $thing = load("care.goo"); |
193
|
0
|
|
|
|
|
|
print $thing->to_string(); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# called from the command line |
198
|
|
|
|
|
|
|
run_driver(@ARGV) unless (caller()); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
1; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
__END__ |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 NAME |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Goo::Loader - Load a Thing from Goo space |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 SYNOPSIS |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
use Goo::Loader; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 DESCRIPTION |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Look for a Thing, load it and return it. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 METHODS |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=over |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item load |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
return a Thing |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item get_maker |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Some Things must be made first! Return a maker for a Thing. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item get_prefix |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
return the goo prefix |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item get_suffix |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
return the goo prefix |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item run_driver |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
drive this module from the command line |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=back |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 AUTHOR |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 SEE ALSO |
249
|
|
|
|
|
|
|
|