pluginfactory 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +293 -70
- data/LICENSE +27 -0
- data/README +189 -24
- data/Rakefile +252 -0
- data/lib/pluginfactory.rb +126 -128
- data/rake/dependencies.rb +62 -0
- data/rake/helpers.rb +382 -0
- data/rake/manual.rb +384 -0
- data/rake/packaging.rb +112 -0
- data/rake/publishing.rb +303 -0
- data/rake/rdoc.rb +30 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +461 -0
- data/rake/testing.rb +191 -0
- data/rake/verifytask.rb +64 -0
- data/spec/pluginfactory_spec.rb +223 -0
- metadata +62 -43
- data/COPYRIGHT +0 -131
- data/install.rb +0 -172
- data/test.rb +0 -72
- data/tests/dir/deepsubofmybase.rb +0 -3
- data/tests/mybase.rb +0 -11
- data/tests/othersub.rb +0 -5
- data/tests/subofmybase.rb +0 -5
- data/utils.rb +0 -672
data/ChangeLog
CHANGED
@@ -1,102 +1,325 @@
|
|
1
|
-
|
1
|
+
-- Wed, 13 Aug 2008 21:58:41 -0000 by deveiant (r52) -----
|
2
|
+
Changed: lib/pluginfactory.rb
|
3
|
+
Rakefile
|
4
|
+
utils.rb
|
5
|
+
spec/pluginfactory_spec.rb
|
2
6
|
|
3
|
-
|
4
|
-
docs/CATALOG (1.1), docs/makedocs.rb (1.1):
|
7
|
+
Updating tags on new files.
|
5
8
|
|
6
|
-
Initial checkin.
|
7
|
-
|
8
|
-
2004-03-08 00:07 Michael Granger <ged@FaerieMUD.org>
|
9
9
|
|
10
|
-
|
10
|
+
-- Wed, 13 Aug 2008 21:57:47 -0000 by deveiant (r51) -----
|
11
|
+
Deleted: rake
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
2004-03-08 00:06 Michael Granger <ged@FaerieMUD.org>
|
13
|
+
Removing old rake tasklib dir
|
15
14
|
|
16
|
-
* tests/mybase.rb (1.2):
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
-- Wed, 13 Aug 2008 21:57:18 -0000 by deveiant (r50) -----
|
17
|
+
Added: project.yml (new)
|
18
|
+
Changed: README
|
19
|
+
/trunk
|
20
|
+
LICENSE
|
21
|
+
Rakefile
|
21
22
|
|
22
|
-
|
23
|
+
Converting to the new build system
|
23
24
|
|
24
|
-
- Documentation additions
|
25
|
-
|
26
|
-
- Refactored path-search code
|
27
|
-
|
28
|
-
2004-03-07 21:30 Michael Granger <ged@FaerieMUD.org>
|
29
25
|
|
30
|
-
|
26
|
+
-- Wed, 26 Mar 2008 16:01:36 -0000 by deveiant (r48) -----
|
27
|
+
Changed: Rakefile
|
28
|
+
rake/publishing.rb
|
29
|
+
rake/svn.rb
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
2004-03-07 19:13 Martin Chase <stillflame@FaerieMUD.org>
|
31
|
+
* More packaging/publishing fixes.
|
35
32
|
|
36
|
-
* README (1.4):
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
-- Tue, 25 Mar 2008 21:17:07 -0000 by deveiant (r46) -----
|
35
|
+
Changed: /trunk
|
36
|
+
Rakefile
|
37
|
+
rake/publishing.rb
|
41
38
|
|
42
|
-
|
39
|
+
* Fixed announcement-sending task to use SMTP+SSL via a monkeypatch to net/smtp. (Maybe package it
|
40
|
+
up and upstream later?)
|
43
41
|
|
44
|
-
FactoryError now inherits from RuntimeError
|
45
|
-
|
46
|
-
2004-03-07 19:06 Martin Chase <stillflame@FaerieMUD.org>
|
47
42
|
|
48
|
-
|
43
|
+
-- Tue, 25 Mar 2008 19:36:11 -0000 by deveiant (r45) -----
|
44
|
+
Added: experiments (new)
|
45
|
+
experiments/logger_output.rb (new)
|
46
|
+
rake/publishing.rb (new)
|
47
|
+
Changed: README
|
48
|
+
lib/pluginfactory.rb
|
49
|
+
/trunk
|
50
|
+
MANIFEST
|
51
|
+
LICENSE
|
52
|
+
Rakefile (and 4 other/s)
|
53
|
+
Deleted: .gemspec
|
54
|
+
makedist.rb
|
55
|
+
install.rb
|
56
|
+
.cvsignore
|
57
|
+
docs
|
49
58
|
|
50
|
-
|
51
|
-
|
52
|
-
2004-03-07 19:05 Martin Chase <stillflame@FaerieMUD.org>
|
59
|
+
* Packaging and publication tasks updated.
|
60
|
+
* Updated documentation.
|
53
61
|
|
54
|
-
* tests/: mybase.rb (1.1), othersub.rb (1.1), subofmybase.rb (1.1),
|
55
|
-
dir/deepsubofmybase.rb (1.1):
|
56
62
|
|
57
|
-
|
58
|
-
|
59
|
-
2004-03-07 15:42 Martin Chase <stillflame@FaerieMUD.org>
|
63
|
+
-- Fri, 27 Jul 2007 06:53:27 -0000 by deveiant (r43) -----
|
64
|
+
Deleted: test.rb
|
60
65
|
|
61
|
-
|
66
|
+
Removed test runner script
|
62
67
|
|
63
|
-
reformatted
|
64
|
-
|
65
|
-
2004-03-07 15:41 Martin Chase <stillflame@FaerieMUD.org>
|
66
68
|
|
67
|
-
|
69
|
+
-- Fri, 27 Jul 2007 06:50:56 -0000 by deveiant (r42) -----
|
70
|
+
Added: LICENSE
|
71
|
+
-> renamed from /trunk/COPYRIGHT@r41
|
72
|
+
Rakefile (new)
|
73
|
+
rake (new)
|
74
|
+
rake/helpers.rb (new)
|
75
|
+
spec/spec.opts (new)
|
76
|
+
rake/svn.rb (new) (and 4 other/s)
|
77
|
+
Changed: lib/pluginfactory.rb
|
78
|
+
/trunk
|
79
|
+
test.rb
|
80
|
+
Deleted: tests
|
81
|
+
COPYRIGHT
|
68
82
|
|
69
|
-
|
70
|
-
|
71
|
-
2004-03-07 14:36 Martin Chase <stillflame@FaerieMUD.org>
|
83
|
+
Converted test::unit tests to RSpec
|
72
84
|
|
73
|
-
* COPYRIGHT (1.2), README (1.2):
|
74
85
|
|
75
|
-
|
76
|
-
|
77
|
-
|
86
|
+
-- Tue, 13 Mar 2007 18:34:19 -0000 by deveiant (r40) -----
|
87
|
+
Changed: /trunk
|
88
|
+
makedist.rb
|
78
89
|
|
79
|
-
|
90
|
+
Bumping project-version and fixing makedist problems.
|
80
91
|
|
81
|
-
cleaned out ties to other modules
|
82
|
-
|
83
|
-
2004-03-07 09:33 Martin Chase <stillflame@FaerieMUD.org>
|
84
92
|
|
85
|
-
|
93
|
+
-- Tue, 13 Mar 2007 18:20:58 -0000 by deveiant (r38) -----
|
94
|
+
Changed: lib/pluginfactory.rb
|
86
95
|
|
87
|
-
|
88
|
-
|
89
|
-
2004-03-07 09:31 Martin Chase <stillflame@FaerieMUD.org>
|
96
|
+
* Log list of candidate subdirs
|
90
97
|
|
91
|
-
* COPYRIGHT (1.1), README (1.1), install.rb (1.1), test.rb (1.1),
|
92
|
-
lib/factory.rb (1.1):
|
93
98
|
|
94
|
-
|
95
|
-
|
96
|
-
|
99
|
+
-- Thu, 22 Feb 2007 23:03:05 -0000 by deveiant (r37) -----
|
100
|
+
Changed: lib/pluginfactory.rb
|
101
|
+
|
102
|
+
|
103
|
+
* Support #derivative_dirs method as well as the camelCased variant.
|
104
|
+
|
105
|
+
|
106
|
+
-- Sat, 01 Jul 2006 18:50:52 -0000 by ged (r36) -----
|
107
|
+
Changed: lib/pluginfactory.rb
|
108
|
+
docs/makedocs.rb
|
109
|
+
test.rb
|
110
|
+
|
111
|
+
|
112
|
+
* Converted camelCased methods to under_barred ones.
|
113
|
+
|
114
|
+
* Fixed tests.
|
115
|
+
|
116
|
+
|
117
|
+
-- Sat, 05 Mar 2005 00:32:10 -0000 by ged (r35) -----
|
118
|
+
Changed: /trunk
|
119
|
+
|
120
|
+
Incremented project version attribute
|
121
|
+
|
122
|
+
|
123
|
+
-- Sat, 05 Mar 2005 00:25:54 -0000 by ged (r33) -----
|
124
|
+
Changed: makedist.rb
|
125
|
+
|
126
|
+
Merged changes from project-utils version
|
127
|
+
|
128
|
+
|
129
|
+
-- Sat, 05 Mar 2005 00:21:05 -0000 by ged (r32) -----
|
130
|
+
Changed: lib/pluginfactory.rb
|
131
|
+
|
132
|
+
- Made load failures raise FactoryErrors as intended instead of RuntimeErrors.
|
133
|
+
|
134
|
+
|
135
|
+
-- Sun, 21 Nov 2004 17:14:13 -0000 by ged (r31) -----
|
136
|
+
Changed: utils.rb
|
137
|
+
install.rb
|
138
|
+
|
139
|
+
-- Updated project-utils files
|
140
|
+
|
141
|
+
|
142
|
+
-- Sun, 21 Nov 2004 17:02:59 -0000 by ged (r30) -----
|
143
|
+
Added: .gemspec (new)
|
144
|
+
Changed: /trunk
|
145
|
+
MANIFEST
|
146
|
+
|
147
|
+
-- Gemified
|
148
|
+
-- Fixed missing utils.rb in MANIFEST
|
149
|
+
-- Added project-spec properties to the root dir.
|
150
|
+
|
151
|
+
|
152
|
+
-- Wed, 08 Sep 2004 04:51:57 -0000 by ged (r28) -----
|
153
|
+
Added: docs/makedocs.rb (new)
|
154
|
+
utils.rb (new)
|
155
|
+
makedist.rb (new)
|
156
|
+
install.rb (new)
|
157
|
+
|
158
|
+
- Hmmm... that didn't work. Copying over new versions of the util scripts until
|
159
|
+
I figure out how the hell to do what I want.
|
160
|
+
|
161
|
+
|
162
|
+
-- Wed, 08 Sep 2004 04:27:06 -0000 by ged (r27) -----
|
163
|
+
Deleted: docs/makedocs.rb
|
164
|
+
utils.rb
|
165
|
+
makedist.rb
|
166
|
+
install.rb
|
167
|
+
|
168
|
+
- Replacing with versions from project-utils (experimental -- may just have to
|
169
|
+
re-check them in)
|
170
|
+
|
171
|
+
|
172
|
+
-- Tue, 24 Aug 2004 01:38:10 -0000 by ged (r26) -----
|
173
|
+
Changed: lib/pluginfactory.rb
|
174
|
+
|
175
|
+
- Added a very important property
|
176
|
+
|
177
|
+
|
178
|
+
-- Tue, 24 Aug 2004 01:36:11 -0000 by ged (r25) -----
|
179
|
+
Changed: lib/pluginfactory.rb
|
180
|
+
|
181
|
+
- Added keywords property to lib/pluginfactory.rb
|
182
|
+
|
183
|
+
|
184
|
+
-- Tue, 24 Aug 2004 01:35:26 -0000 by ged (r24) -----
|
185
|
+
Changed: install.rb
|
186
|
+
|
187
|
+
- Fixed String =~ String warning
|
188
|
+
|
189
|
+
|
190
|
+
-- Tue, 24 Aug 2004 01:34:13 -0000 by ged (r23) -----
|
191
|
+
Changed: install.rb
|
192
|
+
|
193
|
+
- Added bangheader
|
194
|
+
|
195
|
+
|
196
|
+
-- Tue, 24 Aug 2004 01:33:14 -0000 by ged (r22) -----
|
197
|
+
Changed: test.rb
|
198
|
+
|
199
|
+
- Easyified bangheader
|
200
|
+
|
201
|
+
|
202
|
+
-- Wed, 10 Mar 2004 06:36:15 -0000 by deveiant (r20) -----
|
203
|
+
Changed: ChangeLog
|
204
|
+
|
205
|
+
Updated for tag release_0_01
|
206
|
+
|
207
|
+
|
208
|
+
-- Wed, 10 Mar 2004 06:34:00 -0000 by deveiant (r19) -----
|
209
|
+
Added: .cvsignore (new)
|
210
|
+
.irbrc (new)
|
211
|
+
docs/makedocs.rb (new)
|
212
|
+
docs/CATALOG (new)
|
213
|
+
utils.rb (new)
|
214
|
+
makedist.rb (new) (and 5 other/s)
|
215
|
+
Changed: /trunk
|
216
|
+
|
217
|
+
Initial checkin.
|
218
|
+
|
219
|
+
|
220
|
+
-- Mon, 08 Mar 2004 08:07:38 -0000 by deveiant (r18) -----
|
221
|
+
Changed: tests/dir/deepsubofmybase.rb
|
222
|
+
tests/othersub.rb
|
223
|
+
|
224
|
+
- Fixed class/file agreement.
|
225
|
+
|
226
|
+
|
227
|
+
-- Mon, 08 Mar 2004 08:06:24 -0000 by deveiant (r17) -----
|
228
|
+
Changed: tests/mybase.rb
|
229
|
+
|
230
|
+
- Fixed derivativeDirs method.
|
231
|
+
|
232
|
+
|
233
|
+
-- Mon, 08 Mar 2004 08:05:38 -0000 by deveiant (r16) -----
|
234
|
+
Changed: lib/pluginfactory.rb
|
235
|
+
|
236
|
+
- Documentation additions
|
237
|
+
- Refactored path-search code
|
238
|
+
|
239
|
+
|
240
|
+
-- Mon, 08 Mar 2004 05:30:01 -0000 by deveiant (r15) -----
|
241
|
+
Changed: test.rb
|
242
|
+
|
243
|
+
- Added a hook into -d that turns on logging.
|
244
|
+
|
245
|
+
|
246
|
+
-- Mon, 08 Mar 2004 03:13:38 -0000 by stillflame (r14) -----
|
247
|
+
Changed: README
|
248
|
+
|
249
|
+
no, this is not using the default install.rb installation process
|
250
|
+
|
251
|
+
|
252
|
+
-- Mon, 08 Mar 2004 03:07:27 -0000 by stillflame (r13) -----
|
253
|
+
Changed: lib/pluginfactory.rb
|
254
|
+
|
255
|
+
FactoryError now inherits from RuntimeError
|
256
|
+
|
257
|
+
|
258
|
+
-- Mon, 08 Mar 2004 03:06:05 -0000 by stillflame (r12) -----
|
259
|
+
Changed: test.rb
|
260
|
+
|
261
|
+
filling in
|
262
|
+
|
263
|
+
|
264
|
+
-- Mon, 08 Mar 2004 03:05:36 -0000 by stillflame (r11) -----
|
265
|
+
Added: tests/dir/deepsubofmybase.rb (new)
|
266
|
+
tests/othersub.rb (new)
|
267
|
+
tests/dir (new)
|
268
|
+
tests (new)
|
269
|
+
tests/subofmybase.rb (new)
|
270
|
+
tests/mybase.rb (new) (and 1 other/s)
|
271
|
+
|
272
|
+
initial import
|
273
|
+
|
274
|
+
|
275
|
+
-- Sun, 07 Mar 2004 23:42:11 -0000 by stillflame (r10) -----
|
276
|
+
Changed: README
|
277
|
+
|
278
|
+
reformatted
|
279
|
+
|
280
|
+
|
281
|
+
-- Sun, 07 Mar 2004 23:41:51 -0000 by stillflame (r9) -----
|
282
|
+
Changed: install.rb
|
283
|
+
|
284
|
+
filled in
|
285
|
+
|
286
|
+
|
287
|
+
-- Sun, 07 Mar 2004 22:36:44 -0000 by stillflame (r8) -----
|
288
|
+
Changed: README
|
289
|
+
COPYRIGHT
|
290
|
+
|
291
|
+
filled in
|
292
|
+
|
293
|
+
|
294
|
+
-- Sun, 07 Mar 2004 18:49:23 -0000 by stillflame (r7) -----
|
295
|
+
Changed: lib/pluginfactory.rb
|
296
|
+
|
297
|
+
cleaned out ties to other modules
|
298
|
+
|
299
|
+
|
300
|
+
-- Sun, 07 Mar 2004 17:33:10 -0000 by stillflame (r6) -----
|
301
|
+
Added: lib/pluginfactory.rb (new)
|
302
|
+
Deleted: lib/factory.rb
|
303
|
+
|
304
|
+
renaming
|
305
|
+
|
306
|
+
|
307
|
+
-- Sun, 07 Mar 2004 17:31:18 -0000 by stillflame (r2) -----
|
308
|
+
Added: README (new)
|
309
|
+
lib/factory.rb (new)
|
310
|
+
test.rb (new)
|
311
|
+
lib (new)
|
312
|
+
COPYRIGHT (new)
|
313
|
+
install.rb (new) (and 1 other/s)
|
314
|
+
|
315
|
+
Initial revision
|
316
|
+
|
317
|
+
|
318
|
+
-- Sun, 07 Mar 2004 17:31:18 -0000 by unknown (r1) -----
|
319
|
+
Added: /trunk (new)
|
320
|
+
/branches (new)
|
321
|
+
/tags (new)
|
322
|
+
|
323
|
+
New repository initialized by cvs2svn.
|
97
324
|
|
98
|
-
* COPYRIGHT (1.1.1.1), README (1.1.1.1), install.rb (1.1.1.1),
|
99
|
-
test.rb (1.1.1.1), lib/factory.rb (1.1.1.1) (utags: release):
|
100
325
|
|
101
|
-
initial stripping out of Arrow/MUES
|
102
|
-
|
data/LICENSE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2008, Michael Granger
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of the author/s, nor the names of the project's
|
15
|
+
contributors may be used to endorse or promote products derived from this
|
16
|
+
software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README
CHANGED
@@ -1,39 +1,204 @@
|
|
1
|
-
= The PluginFactory mixin
|
2
1
|
|
3
|
-
|
4
|
-
request.
|
2
|
+
= PluginFactory
|
5
3
|
|
6
|
-
|
4
|
+
PluginFactory is a mixin module that turns an including class into a factory for
|
5
|
+
its derivatives, capable of searching for and loading them by name. This is
|
6
|
+
useful when you have an abstract base class which defines an interface and basic
|
7
|
+
functionality for a part of a larger system, and a collection of subclasses
|
8
|
+
which implement the interface for different underlying functionality.
|
7
9
|
|
8
|
-
|
10
|
+
An example of where this might be useful is in a program which talks to a
|
11
|
+
database. To avoid coupling it to a specific database, you use a Driver class
|
12
|
+
which encapsulates your program's interaction with the database behind a useful
|
13
|
+
interface. Now you can create a concrete implementation of the Driver class for
|
14
|
+
each kind of database you wish to talk to. If you make the base Driver class a
|
15
|
+
PluginFactory, too, you can add new drivers simply by dropping them in a
|
16
|
+
directory and using the Driver's <tt>create</tt> method to instantiate them:
|
9
17
|
|
10
|
-
==
|
18
|
+
== Synopsis
|
11
19
|
|
12
|
-
|
20
|
+
in driver.rb:
|
13
21
|
|
14
|
-
|
22
|
+
require "PluginFactory"
|
23
|
+
|
24
|
+
class Driver
|
25
|
+
include PluginFactory
|
26
|
+
def self::derivative_dirs
|
27
|
+
["drivers"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
in drivers/mysql.rb:
|
32
|
+
|
33
|
+
require 'driver'
|
34
|
+
|
35
|
+
class MysqlDriver < Driver
|
36
|
+
...implementation...
|
37
|
+
end
|
38
|
+
|
39
|
+
in /usr/lib/ruby/1.8/PostgresDriver.rb:
|
40
|
+
|
41
|
+
require 'driver'
|
42
|
+
|
43
|
+
class PostgresDriver < Driver
|
44
|
+
...implementation...
|
45
|
+
end
|
46
|
+
|
47
|
+
elsewhere
|
48
|
+
|
49
|
+
require 'driver'
|
50
|
+
|
51
|
+
config[:driver_type] #=> "mysql"
|
52
|
+
driver = Driver.create( config[:driver_type] )
|
53
|
+
driver.class #=> MysqlDriver
|
54
|
+
pgdriver = Driver.create( "PostGresDriver" )
|
55
|
+
|
56
|
+
== How Plugins Are Loaded
|
57
|
+
|
58
|
+
The +create+ class method added to your class by PluginFactory searches for your
|
59
|
+
module using several different strategies. It tries various permutations of the
|
60
|
+
base class's name in combination with the derivative requested. For example,
|
61
|
+
assume we want to make a +DataDriver+ base class, and then use plugins to define
|
62
|
+
drivers for different kinds of data sources:
|
63
|
+
|
64
|
+
require 'pluginfactory'
|
65
|
+
|
66
|
+
class DataDriver
|
67
|
+
include PluginFactory
|
68
|
+
end
|
69
|
+
|
70
|
+
When you attempt to load the 'socket' data-driver class like so:
|
71
|
+
|
72
|
+
DataDriver.create( 'socket' )
|
73
|
+
|
74
|
+
PluginFactory searches for modules with the following names:
|
15
75
|
|
16
|
-
|
76
|
+
'socketdatadriver'
|
77
|
+
'socket_datadriver'
|
78
|
+
'socketDataDriver'
|
79
|
+
'socket_DataDriver'
|
80
|
+
'SocketDataDriver'
|
81
|
+
'Socket_DataDriver'
|
82
|
+
'socket'
|
83
|
+
'Socket'
|
17
84
|
|
18
|
-
|
85
|
+
Obviously the last one will load something other than what is intended, so you
|
86
|
+
can also tell PluginFactory that plugins should be loaded from a subdirectory by
|
87
|
+
declaring a class method called `derivative_dirs` in the base class. It should
|
88
|
+
return an Array that contains a list of subdirectories to try:
|
19
89
|
|
20
|
-
|
90
|
+
class DataDriver
|
91
|
+
include PluginFactory
|
92
|
+
|
93
|
+
def self::derivative_dirs
|
94
|
+
['drivers']
|
95
|
+
end
|
96
|
+
end
|
21
97
|
|
22
|
-
|
98
|
+
This will change the list that is required to:
|
99
|
+
|
100
|
+
'drivers/socketdatadriver'
|
101
|
+
'drivers/socket_datadriver'
|
102
|
+
'drivers/socketDataDriver'
|
103
|
+
'drivers/socket_DataDriver'
|
104
|
+
'drivers/SocketDataDriver'
|
105
|
+
'drivers/Socket_DataDriver'
|
106
|
+
'drivers/socket'
|
107
|
+
'drivers/Socket'
|
108
|
+
|
109
|
+
If you return more than one subdirectory, each of them will be tried in turn:
|
110
|
+
|
111
|
+
class DataDriver
|
112
|
+
include PluginFactory
|
113
|
+
|
114
|
+
def self::derivative_dirs
|
115
|
+
['drivers', 'datadriver']
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
will change the search to include:
|
120
|
+
|
121
|
+
'drivers/socketdatadriver'
|
122
|
+
'drivers/socket_datadriver'
|
123
|
+
'drivers/socketDataDriver'
|
124
|
+
'drivers/socket_DataDriver'
|
125
|
+
'drivers/SocketDataDriver'
|
126
|
+
'drivers/Socket_DataDriver'
|
127
|
+
'drivers/socket'
|
128
|
+
'drivers/Socket'
|
129
|
+
'datadriver/socketdatadriver'
|
130
|
+
'datadriver/socket_datadriver'
|
131
|
+
'datadriver/socketDataDriver'
|
132
|
+
'datadriver/socket_DataDriver'
|
133
|
+
'datadriver/SocketDataDriver'
|
134
|
+
'datadriver/Socket_DataDriver'
|
135
|
+
'datadriver/socket'
|
136
|
+
'datadriver/Socket'
|
137
|
+
|
138
|
+
If the plugin is not found, a FactoryError is raised, and the message will list
|
139
|
+
all the permutations that were tried.
|
140
|
+
|
141
|
+
== Logging
|
142
|
+
|
143
|
+
If you need a little more insight into what's going on, PluginFactory exposes a
|
144
|
+
logging callback which will be called at various points in the process, and will
|
145
|
+
include details on what's being attempted.
|
146
|
+
|
147
|
+
You can activate logging by setting PluginFactory.logger_callback to something
|
148
|
+
that responds to the #call message. It will be called with two arguments, a
|
149
|
+
severity level and a message:
|
150
|
+
|
151
|
+
callback.call( :info, "Something happened" )
|
152
|
+
|
153
|
+
This is intended to make it easy to hook up to Logger or anything with a similar
|
154
|
+
interface:
|
155
|
+
|
156
|
+
require 'pluginfactory'
|
157
|
+
require 'logger'
|
158
|
+
|
159
|
+
class DataDriver
|
160
|
+
include PluginFactory
|
161
|
+
|
162
|
+
@logger = Logger.new( $stderr )
|
163
|
+
@logger.level = Logger::DEBUG
|
164
|
+
PluginFactory.logger_callback = lambda do |severity, msg|
|
165
|
+
@logger.send(severity, msg)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
DataDriver.create( 'ringbuffer' )
|
170
|
+
|
171
|
+
this might generate a log that looks like:
|
172
|
+
|
173
|
+
D, [...] DEBUG -- : Loading derivative ringbuffer
|
174
|
+
D, [...] DEBUG -- : Subdirs are: [""]
|
175
|
+
D, [...] DEBUG -- : Path is: ["ringbufferdatadriver", "ringbufferDataDriver",
|
176
|
+
"ringbuffer"]...
|
177
|
+
D, [...] DEBUG -- : Trying ringbufferdatadriver...
|
178
|
+
D, [...] DEBUG -- : No module at 'ringbufferdatadriver', trying the next
|
179
|
+
alternative: 'no such file to load -- ringbufferdatadriver'
|
180
|
+
D, [...] DEBUG -- : Trying ringbufferDataDriver...
|
181
|
+
D, [...] DEBUG -- : No module at 'ringbufferDataDriver', trying the next
|
182
|
+
alternative: 'no such file to load -- ringbufferDataDriver'
|
183
|
+
D, [...] DEBUG -- : Trying ringbuffer...
|
184
|
+
D, [...] DEBUG -- : No module at 'ringbuffer', trying the next alternative:
|
185
|
+
'no such file to load -- ringbuffer'
|
186
|
+
D, [...] DEBUG -- : fatals = []
|
187
|
+
E, [...] ERROR -- : Couldn't find a DataDriver named 'ringbuffer':
|
188
|
+
tried ["ringbufferdatadriver", "ringbufferDataDriver", "ringbuffer"]
|
189
|
+
|
190
|
+
== Subversion ID
|
191
|
+
|
192
|
+
$Id: README 50 2008-08-13 21:57:18Z deveiant $
|
193
|
+
|
194
|
+
== Authors
|
23
195
|
|
24
|
-
|
25
|
-
|
196
|
+
* Martin Chase <stillflame@FaerieMUD.org>
|
197
|
+
* Michael Granger <ged@FaerieMUD.org>
|
26
198
|
|
27
|
-
|
28
|
-
Perl Artistic License, a copy of which should have been included in this
|
29
|
-
distribution (See the file COPYRIGHT). If it was not, a copy of it may be
|
30
|
-
obtained from http://language.perl.com/misc/Artistic.html or
|
31
|
-
http://www.faeriemud.org/artistic.html).
|
199
|
+
:include: LICENSE
|
32
200
|
|
33
|
-
|
34
|
-
INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
|
35
|
-
FITNESS FOR A PARTICULAR PURPOSE.
|
201
|
+
--
|
36
202
|
|
37
|
-
|
203
|
+
Please see the file LICENSE for licensing details.
|
38
204
|
|
39
|
-
$Id: README 14 2004-03-08 03:13:38Z stillflame $
|