pluginfactory 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +26 -0
- data/README +1 -1
- data/Rakefile +82 -22
- data/lib/pluginfactory.rb +77 -39
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +25 -11
- data/rake/helpers.rb +65 -40
- data/rake/manual.rb +464 -64
- data/rake/publishing.rb +30 -16
- data/rake/rdoc.rb +36 -21
- data/rake/svn.rb +166 -25
- data/rake/testing.rb +46 -35
- data/rake/win32.rb +94 -0
- data/spec/lib/helpers.rb +247 -0
- data/spec/pluginfactory_spec.rb +43 -69
- metadata +138 -9
data/spec/pluginfactory_spec.rb
CHANGED
@@ -9,18 +9,11 @@ BEGIN {
|
|
9
9
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
10
10
|
}
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
rescue LoadError
|
16
|
-
unless Object.const_defined?( :Gem )
|
17
|
-
require 'rubygems'
|
18
|
-
retry
|
19
|
-
end
|
20
|
-
raise
|
21
|
-
end
|
22
|
-
|
12
|
+
require 'spec'
|
13
|
+
require 'logger'
|
14
|
+
require 'pluginfactory'
|
23
15
|
|
16
|
+
require 'spec/lib/helpers'
|
24
17
|
|
25
18
|
class Plugin
|
26
19
|
extend PluginFactory
|
@@ -29,56 +22,57 @@ class Plugin
|
|
29
22
|
end
|
30
23
|
end
|
31
24
|
|
32
|
-
|
33
|
-
|
34
25
|
describe PluginFactory do
|
26
|
+
include PluginFactory::SpecHelpers
|
27
|
+
|
28
|
+
before( :each ) do
|
29
|
+
setup_logging( :fatal )
|
30
|
+
end
|
31
|
+
|
35
32
|
|
36
33
|
it "calls its logging callback with the level and joined message if set" do
|
37
34
|
level = nil; msg = nil
|
38
|
-
PluginFactory.logger_callback = lambda {|
|
35
|
+
PluginFactory.logger_callback = lambda {|l, m| level = l; msg = m }
|
36
|
+
PluginFactory.logger.level = Logger::DEBUG
|
39
37
|
|
40
|
-
PluginFactory.log(
|
41
|
-
level.should == :
|
42
|
-
msg.should == '
|
38
|
+
PluginFactory.log.debug( 'message' )
|
39
|
+
level.should == :debug
|
40
|
+
msg.should == 'message'
|
43
41
|
end
|
44
42
|
|
45
43
|
it "doesn't error when its log method is called if no logging callback is set" do
|
46
44
|
PluginFactory.logger_callback = nil
|
47
|
-
lambda { PluginFactory.log(
|
45
|
+
lambda { PluginFactory.log.debug("msg") }.should_not raise_error()
|
48
46
|
end
|
49
47
|
|
50
48
|
end
|
51
49
|
|
50
|
+
|
51
|
+
class SubPlugin < Plugin; end
|
52
|
+
|
52
53
|
describe "A class extended with PluginFactory" do
|
53
|
-
|
54
|
+
include PluginFactory::SpecHelpers
|
55
|
+
|
56
|
+
before( :all ) do
|
57
|
+
setup_logging( :fatal )
|
58
|
+
end
|
59
|
+
|
60
|
+
after( :all ) do
|
61
|
+
reset_logging()
|
62
|
+
end
|
63
|
+
|
54
64
|
before( :each ) do
|
55
|
-
#
|
56
|
-
# the order the examples are run in
|
57
|
-
Plugin.derivatives.clear
|
65
|
+
# Plugin.derivatives.clear
|
58
66
|
end
|
59
67
|
|
60
68
|
|
61
69
|
it "knows about all of its derivatives" do
|
62
|
-
Plugin.derivatives.should be_empty()
|
63
|
-
Plugin.derivatives.should be_an_instance_of( Hash )
|
64
|
-
|
65
|
-
class SubPlugin < Plugin; end
|
66
|
-
|
67
|
-
Plugin.derivatives.should have(4).members
|
68
70
|
Plugin.derivatives.keys.should include( 'sub' )
|
69
71
|
Plugin.derivatives.keys.should include( 'subplugin' )
|
70
72
|
Plugin.derivatives.keys.should include( 'SubPlugin' )
|
71
73
|
Plugin.derivatives.keys.should include( SubPlugin )
|
72
74
|
end
|
73
75
|
|
74
|
-
it "can return an Array of all of its derivative classes" do
|
75
|
-
Plugin.derivative_classes.should be_empty()
|
76
|
-
|
77
|
-
class OtherPlugin < Plugin; end
|
78
|
-
|
79
|
-
Plugin.derivative_classes.should == [OtherPlugin]
|
80
|
-
end
|
81
|
-
|
82
76
|
it "returns derivatives directly if they're already loaded" do
|
83
77
|
class AlreadyLoadedPlugin < Plugin; end
|
84
78
|
Kernel.should_not_receive( :require )
|
@@ -115,31 +109,17 @@ describe "A class extended with PluginFactory" do
|
|
115
109
|
it "will load new plugins from the require path if they're not loaded yet" do
|
116
110
|
loaded_class = nil
|
117
111
|
|
118
|
-
Plugin.should_receive( :require ).and_return
|
119
|
-
loaded_class = Class.new( Plugin )
|
120
|
-
|
121
|
-
|
112
|
+
Plugin.should_receive( :require ).with( 'plugins/dazzle_plugin' ).and_return do |*args|
|
113
|
+
loaded_class = Class.new( Plugin )
|
114
|
+
# Simulate a named class, since we're not really requiring
|
115
|
+
Plugin.derivatives['dazzle'] = loaded_class
|
122
116
|
true
|
123
|
-
|
117
|
+
end
|
124
118
|
|
125
119
|
Plugin.create( 'dazzle' ).should be_an_instance_of( loaded_class )
|
126
120
|
end
|
127
121
|
|
128
122
|
|
129
|
-
it "will #require derivatives that aren't yet loaded" do
|
130
|
-
loaded_class = nil
|
131
|
-
|
132
|
-
Plugin.should_receive( :require ).and_return {|*args|
|
133
|
-
loaded_class = Class.new( Plugin ) do
|
134
|
-
def self::name; "SnazzlePlugin"; end
|
135
|
-
end
|
136
|
-
true
|
137
|
-
}
|
138
|
-
|
139
|
-
Plugin.create( 'snazzle' ).should be_an_instance_of( loaded_class )
|
140
|
-
end
|
141
|
-
|
142
|
-
|
143
123
|
it "will output a sensible description of what it tried to load if requiring a " +
|
144
124
|
"derivative fails" do
|
145
125
|
|
@@ -176,12 +156,10 @@ describe "A class extended with PluginFactory" do
|
|
176
156
|
end
|
177
157
|
|
178
158
|
|
159
|
+
class TestingPlugin < Plugin; end
|
160
|
+
|
179
161
|
describe "A derivative of a class extended with PluginFactory" do
|
180
162
|
|
181
|
-
before( :all ) do
|
182
|
-
class TestingPlugin < Plugin; end
|
183
|
-
end
|
184
|
-
|
185
163
|
it "knows what type of factory loads it" do
|
186
164
|
TestingPlugin.factory_type.should == 'Plugin'
|
187
165
|
end
|
@@ -194,12 +172,10 @@ describe "A derivative of a class extended with PluginFactory" do
|
|
194
172
|
end
|
195
173
|
|
196
174
|
|
175
|
+
class BlackSheep < Plugin; end
|
176
|
+
|
197
177
|
describe "A derivative of a class extended with PluginFactory that isn't named <Something>Plugin" do
|
198
178
|
|
199
|
-
before( :all ) do
|
200
|
-
class BlackSheep < Plugin; end
|
201
|
-
end
|
202
|
-
|
203
179
|
it "is still creatable via its full name" do
|
204
180
|
Plugin.create( 'blacksheep' ).should be_an_instance_of( BlackSheep )
|
205
181
|
end
|
@@ -207,14 +183,12 @@ describe "A derivative of a class extended with PluginFactory that isn't named <
|
|
207
183
|
end
|
208
184
|
|
209
185
|
|
186
|
+
module Test
|
187
|
+
class LoadablePlugin < Plugin; end
|
188
|
+
end
|
189
|
+
|
210
190
|
describe "A derivative of a class extended with PluginFactory in another namespace" do
|
211
191
|
|
212
|
-
before( :all ) do
|
213
|
-
module Test
|
214
|
-
class LoadablePlugin < Plugin; end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
192
|
it "is still creatable via its derivative name" do
|
219
193
|
Plugin.create( 'loadable' ).should be_an_instance_of( Test::LoadablePlugin )
|
220
194
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluginfactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -9,25 +9,148 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-25 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: text-format
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: termios
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rubyforge
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.8.1
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: libxml-ruby
|
67
|
+
type: :development
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.8.3
|
74
|
+
version:
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: ultraviolet
|
77
|
+
type: :development
|
78
|
+
version_requirement:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.10.2
|
84
|
+
version:
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: tmail
|
87
|
+
type: :development
|
88
|
+
version_requirement:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.2.3.1
|
94
|
+
version:
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: amatch
|
97
|
+
type: :development
|
98
|
+
version_requirement:
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.2.3
|
104
|
+
version:
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rcov
|
107
|
+
type: :development
|
108
|
+
version_requirement:
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: "0"
|
114
|
+
version:
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: RedCloth
|
117
|
+
type: :development
|
118
|
+
version_requirement:
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 4.0.3
|
124
|
+
version:
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rcodetools
|
127
|
+
type: :development
|
128
|
+
version_requirement:
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.7.0.0
|
134
|
+
version:
|
16
135
|
description: PluginFactory is a mixin module that turns an including class into a factory for its derivatives, capable of searching for and loading them by name. This is useful when you have an abstract base class which defines an interface and basic functionality for a part of a larger system, and a collection of subclasses which implement the interface for different underlying functionality.
|
17
136
|
email: ged@FaerieMUD.org
|
18
137
|
executables: []
|
19
138
|
|
20
139
|
extensions: []
|
21
140
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
141
|
+
extra_rdoc_files:
|
142
|
+
- ChangeLog
|
143
|
+
- README
|
144
|
+
- LICENSE
|
24
145
|
files:
|
25
146
|
- Rakefile
|
26
147
|
- ChangeLog
|
27
148
|
- README
|
28
149
|
- LICENSE
|
29
150
|
- spec/pluginfactory_spec.rb
|
151
|
+
- spec/lib/helpers.rb
|
30
152
|
- lib/pluginfactory.rb
|
153
|
+
- rake/191_compat.rb
|
31
154
|
- rake/dependencies.rb
|
32
155
|
- rake/helpers.rb
|
33
156
|
- rake/manual.rb
|
@@ -38,8 +161,11 @@ files:
|
|
38
161
|
- rake/svn.rb
|
39
162
|
- rake/testing.rb
|
40
163
|
- rake/verifytask.rb
|
164
|
+
- rake/win32.rb
|
41
165
|
has_rdoc: true
|
42
166
|
homepage: http://deveiate.org/projects/PluginFactory/
|
167
|
+
licenses: []
|
168
|
+
|
43
169
|
post_install_message:
|
44
170
|
rdoc_options:
|
45
171
|
- -w
|
@@ -49,8 +175,10 @@ rdoc_options:
|
|
49
175
|
- .
|
50
176
|
- -m
|
51
177
|
- README
|
178
|
+
- -t
|
179
|
+
- pluginfactory
|
52
180
|
- -W
|
53
|
-
- http://deveiate.org/projects/PluginFactory
|
181
|
+
- http://deveiate.org/projects/PluginFactory/browser/trunk/
|
54
182
|
require_paths:
|
55
183
|
- lib
|
56
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -68,9 +196,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
196
|
requirements: []
|
69
197
|
|
70
198
|
rubyforge_project: pluginfactory
|
71
|
-
rubygems_version: 1.
|
199
|
+
rubygems_version: 1.3.1
|
72
200
|
signing_key:
|
73
|
-
specification_version:
|
201
|
+
specification_version: 3
|
74
202
|
summary: A mixin for making plugin classes
|
75
203
|
test_files:
|
76
204
|
- spec/pluginfactory_spec.rb
|
205
|
+
- spec/lib/helpers.rb
|