| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Goo::Thing; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
|
4
|
|
|
|
|
|
|
# Nigel Hamilton |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
|
7
|
|
|
|
|
|
|
# All Rights Reserved |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
|
10
|
|
|
|
|
|
|
# Filename: Goo::Thing.pm |
|
11
|
|
|
|
|
|
|
# Description: A new generic type of "Thing" in The Goo based on global config |
|
12
|
|
|
|
|
|
|
# files. A Thing is a handle on an underlying Thing. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# Date Change |
|
15
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
16
|
|
|
|
|
|
|
# 15/06/2005 Auto generated file |
|
17
|
|
|
|
|
|
|
# 15/06/2005 Needed a generic thing |
|
18
|
|
|
|
|
|
|
# 01/08/2005 Simplified action handling |
|
19
|
|
|
|
|
|
|
# 11/10/2005 Added method: getLocation |
|
20
|
|
|
|
|
|
|
# 18/10/2005 Added method: getDatabaseRow |
|
21
|
|
|
|
|
|
|
# 19/10/2005 Added method: getColumns |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
############################################################################### |
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
6
|
use Cwd; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
77
|
|
|
28
|
1
|
|
|
1
|
|
6
|
use Goo::Object; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
29
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
48
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# use Smart::Comments; |
|
32
|
1
|
|
|
1
|
|
582
|
use Goo::TrailManager; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
8
|
use base qw(Goo::Object); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
614
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
############################################################################### |
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
# new - construct a Thing |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
############################################################################### |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
|
my ($class, $filename) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $this = $class->SUPER::new(); |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
unless ($filename) { |
|
50
|
0
|
|
|
|
|
|
die("Can't find Thing. No filename found at: " . caller()); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# extract the prefix and suffix |
|
54
|
0
|
0
|
|
|
|
|
if ($filename =~ /(.*)\.(.*)$/) { |
|
55
|
0
|
|
|
|
|
|
$this->{prefix} = $1; |
|
56
|
0
|
|
|
|
|
|
$this->{suffix} = $2; |
|
57
|
|
|
|
|
|
|
} else { |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# it may be all suffix, example: goo -m goo |
|
60
|
0
|
|
|
|
|
|
$this->{suffix} = $filename; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# remember the filename |
|
64
|
0
|
|
|
|
|
|
$this->{filename} = $filename; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# load the config_file |
|
67
|
0
|
|
|
|
|
|
my $config_file = Goo::ConfigFile->new($this->{suffix} . ".goo"); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
### The config file should contain the actions |
|
70
|
|
|
|
|
|
|
### $config_file->to_string() |
|
71
|
0
|
0
|
|
|
|
|
unless ($config_file) { |
|
72
|
0
|
|
|
|
|
|
die("Can't create Thing. No config file found for $this->{suffix}."); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# merge all the config fields with this object |
|
76
|
0
|
|
|
|
|
|
%$this = (%$this, %$config_file); |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $this; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
############################################################################### |
|
84
|
|
|
|
|
|
|
# |
|
85
|
|
|
|
|
|
|
# get_filename - all Things must have a "filename" - even database Things! |
|
86
|
|
|
|
|
|
|
# |
|
87
|
|
|
|
|
|
|
############################################################################### |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub get_filename { |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# this is the ID of the handle on the Thing! |
|
94
|
0
|
|
|
|
|
|
return $this->{filename}; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
############################################################################### |
|
100
|
|
|
|
|
|
|
# |
|
101
|
|
|
|
|
|
|
# get_suffix - return the Thing suffix |
|
102
|
|
|
|
|
|
|
# |
|
103
|
|
|
|
|
|
|
############################################################################### |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_suffix { |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return $this->{suffix}; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
############################################################################### |
|
115
|
|
|
|
|
|
|
# |
|
116
|
|
|
|
|
|
|
# get_prefix - get the full contents of the file |
|
117
|
|
|
|
|
|
|
# |
|
118
|
|
|
|
|
|
|
############################################################################### |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_prefix { |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return $this->{prefix}; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
############################################################################### |
|
130
|
|
|
|
|
|
|
# |
|
131
|
|
|
|
|
|
|
# can_do_action - can this thing do the action? |
|
132
|
|
|
|
|
|
|
# |
|
133
|
|
|
|
|
|
|
############################################################################### |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub can_do_action { |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
0
|
1
|
|
my ($this, $action) = @_; |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return exists $this->{actions}->{$action}; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
############################################################################### |
|
145
|
|
|
|
|
|
|
# |
|
146
|
|
|
|
|
|
|
# get_commands - return a list of commands |
|
147
|
|
|
|
|
|
|
# |
|
148
|
|
|
|
|
|
|
############################################################################### |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub get_commands { |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my @commands; |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
foreach my $letter (sort { $a cmp $b } keys %{ $this->{actions} }) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
push(@commands, $this->{actions}->{$letter}->{command}); |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
return @commands; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
############################################################################### |
|
168
|
|
|
|
|
|
|
# |
|
169
|
|
|
|
|
|
|
# do_action - execute action |
|
170
|
|
|
|
|
|
|
# |
|
171
|
|
|
|
|
|
|
############################################################################### |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub do_action { |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
0
|
1
|
|
my ($this, $action_letter, @parameters) = @_; |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
0
|
|
|
|
|
unless ($this->isa("Goo::Thing")) { |
|
178
|
0
|
|
|
|
|
|
print("Invalid Thing."); |
|
179
|
0
|
|
|
|
|
|
print Dumper($this); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
#unless ($action_letter eq "B") { |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# this is a new step in the trail - record it |
|
186
|
0
|
|
|
|
|
|
Goo::TrailManager::save_goo_action($this, $this->{actions}->{$action_letter}->{command}); |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# reset the trail position |
|
189
|
|
|
|
|
|
|
#Goo::TrailManager::reset_last_action(); |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $module = $this->{actions}->{$action_letter}->{action}; |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# strip action handler of .pm suffix |
|
194
|
0
|
|
|
|
|
|
$module =~ s/\.pm$//; |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# Goo::Prompter::trace("about to require this $module"); |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
### $this->{actions}->{E}->{action} = "ProgramEditor"; |
|
199
|
0
|
|
|
|
|
|
eval "require $module;"; |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
|
if ($@) { |
|
202
|
0
|
|
|
|
|
|
die("Evaled failed $@"); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
### $this->{actions}->{E}->{action} = "ProgramEditor"; |
|
206
|
0
|
|
|
|
|
|
my $actor = $module->new(); |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
$actor->run($this, @parameters); |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
__END__ |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 NAME |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Goo::Thing - A "Thing" in your working environment that you can do actions to |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
use Goo::Thing; |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
A "Thing" is something you perform actions on in your working environment. It could be a file, a database entity or |
|
228
|
|
|
|
|
|
|
configuration file. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Everytime you perform an action on a Thing it is recorded in the Goo Trail. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
The Goo Trail records all your temporal associations between Things in your environment. |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 METHODS |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=over |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item new |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
construct a Thing |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item get_filename |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
all Things must have a "filename" or "handle" - even database Things! |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item get_suffix |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
return the Thing suffix |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item get_prefix |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
get the full contents of the file |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item can_do_action |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
can this Thing do the action? |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item get_commands |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
return a list of commands |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=item do_action |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
execute the action |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=back |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 AUTHOR |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Tour http://thegoo.org/goo-tour.pdf (big) |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Web http://thegoo.org |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Blog http://blog.thegoo.org |
|
279
|
|
|
|
|
|
|
|