line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::TypeManager; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 All Rights Reserved |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
9
|
|
|
|
|
|
|
# Filename: GooTypeManager.pm |
10
|
|
|
|
|
|
|
# Description: Manage all the different types of Things in The Goo |
11
|
|
|
|
|
|
|
# The type of a Thing is determined by its suffix (e.g., Thing.pm) |
12
|
|
|
|
|
|
|
# All valid types have a corresponding .goo file (e.g., pm.goo) |
13
|
|
|
|
|
|
|
# The .goo files are located in /home/search/goo/things/goo |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# Date Change |
16
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
# 20/06/2005 Auto generated file |
18
|
|
|
|
|
|
|
# 20/06/2005 Need to store global config parameters |
19
|
|
|
|
|
|
|
# 23/08/2005 Added method: isValidThing |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
############################################################################### |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
26
|
1
|
|
|
1
|
|
6
|
use Goo::ConfigFile; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
27
|
1
|
|
|
1
|
|
7
|
use Goo::FileUtilities; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
323
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# load at BEGIN time |
31
|
|
|
|
|
|
|
my @GOO_TYPES; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# where all the config files are stored |
34
|
|
|
|
|
|
|
my $GOO_CONFIG_ROOT = "$ENV{HOME}/.goo/things/goo"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
############################################################################### |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
# get_all_types - return the types of all thangs |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
############################################################################### |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub get_all_types { |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
1
|
|
return @GOO_TYPES; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
############################################################################### |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# get_type_locations - return a list of directories where this thing is located |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
############################################################################### |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_type_locations { |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
1
|
|
my ($type) = @_; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# make sure we have the right type |
61
|
0
|
0
|
|
|
|
|
$type = ($type =~ /\.goo$/) ? $type : $type . ".goo"; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# load the configuration file for this type of Thing |
64
|
0
|
|
|
|
|
|
my $config_file = Goo::ConfigFile->new($type); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# return the locations where Things of this type can be found |
67
|
0
|
|
|
|
|
|
return $config_file->get_locations(); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
############################################################################### |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# is_valid_thing - is this a thing? |
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
############################################################################### |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub is_valid_thing { |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
1
|
|
my ($filename) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
foreach my $type (get_all_types()) { |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
return 1 if ($filename =~ /\.$type/); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return 0; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
############################################################################### |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
# BEGIN - load the configuration for the goo |
95
|
|
|
|
|
|
|
# |
96
|
|
|
|
|
|
|
############################################################################### |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub BEGIN { |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
1
|
|
6
|
my $GOO_CONFIG_ROOT = "$ENV{HOME}/.goo/things/goo"; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# look for all the Goo config files |
103
|
1
|
|
|
|
|
9
|
foreach my $config_filename (Goo::FileUtilities::get_file_list($GOO_CONFIG_ROOT . "/*.goo")) { |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$config_filename =~ /.*\/(.*)\.goo/; |
106
|
0
|
|
|
|
|
|
push(@GOO_TYPES, $1); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#use Goo::Prompter; |
111
|
|
|
|
|
|
|
# Goo::Prompter::prompt("Found these types: " . join(" ", @GOO_TYPES)); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 NAME |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Goo::TypeManager - Manage all the different types of Things in The Goo |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SYNOPSIS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
use Goo::TypeManager; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 METHODS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item get_all_types |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
return the types of all Things |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item get_type_locations |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
return a list of directories where this Thing is located |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item is_valid_thing |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
is this a Thing? |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item BEGIN |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
load the configuration for The Goo |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
159
|
|
|
|
|
|
|
|