pluginfactory 1.0.7 → 1.0.8
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.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/ChangeLog +511 -212
- data/History.rdoc +46 -0
- data/Manifest.txt +8 -0
- data/README.rdoc +237 -0
- data/Rakefile +17 -347
- data/lib/pluginfactory.rb +42 -18
- data/spec/lib/helpers.rb +116 -206
- data/spec/pluginfactory_spec.rb +27 -20
- metadata +157 -97
- metadata.gz.sig +1 -2
- data/LICENSE +0 -27
- data/README +0 -200
- data/rake/191_compat.rb +0 -26
- data/rake/dependencies.rb +0 -76
- data/rake/documentation.rb +0 -115
- data/rake/helpers.rb +0 -502
- data/rake/hg.rb +0 -287
- data/rake/manual.rb +0 -787
- data/rake/packaging.rb +0 -129
- data/rake/publishing.rb +0 -348
- data/rake/style.rb +0 -62
- data/rake/svn.rb +0 -668
- data/rake/testing.rb +0 -187
- data/rake/verifytask.rb +0 -64
data/History.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
== v1.0.8 [2012-02-20] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
Gem update (no code changes).
|
4
|
+
|
5
|
+
|
6
|
+
== v1.0.7 [2010-09-27] Michael Granger <ged@FaerieMUD.org>
|
7
|
+
|
8
|
+
Gemspec update.
|
9
|
+
|
10
|
+
== v1.0.6 [2010-03-23] Michael Granger <ged@FaerieMUD.org>
|
11
|
+
|
12
|
+
Gemspec fixes.
|
13
|
+
|
14
|
+
== v1.0.5 [2009-11-06] Michael Granger <ged@FaerieMUD.org>
|
15
|
+
|
16
|
+
* Fixes for Ruby 1.9.1.
|
17
|
+
* Replace home-grown logger stuff with Logger library
|
18
|
+
|
19
|
+
== v1.0.3 [2008-03-26] Michael Granger <ged@FaerieMUD.org>
|
20
|
+
|
21
|
+
* More packaging/publishing fixes.
|
22
|
+
* Updated documentation.
|
23
|
+
* Converted test::unit tests to RSpec
|
24
|
+
|
25
|
+
== v1.0.2 [2007-03-13] Michael Granger <ged@FaerieMUD.org>
|
26
|
+
|
27
|
+
* Logging enhancements
|
28
|
+
* Converted camelCased methods to under_barred ones.
|
29
|
+
* Fixed tests.
|
30
|
+
|
31
|
+
== v1.0.1 [2005-03-05] Michael Granger <ged@FaerieMUD.org>
|
32
|
+
|
33
|
+
* Made load failures raise FactoryErrors as intended instead of
|
34
|
+
RuntimeErrors.
|
35
|
+
* Gemified
|
36
|
+
|
37
|
+
== v1.0.0 [2004-09-08] Michael Granger <ged@FaerieMUD.org>
|
38
|
+
|
39
|
+
* Stable release
|
40
|
+
* Fixed String =~ String warning
|
41
|
+
* Bugfixes
|
42
|
+
|
43
|
+
== v0.01 [2004-03-10] Michael Granger <ged@FaerieMUD.org>
|
44
|
+
|
45
|
+
First release.
|
46
|
+
|
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
= pluginfactory
|
2
|
+
|
3
|
+
* http://deveiate.org/projects/PluginFactory
|
4
|
+
|
5
|
+
|
6
|
+
== Description
|
7
|
+
|
8
|
+
PluginFactory is a mixin module that turns an including class into a factory for
|
9
|
+
its derivatives, capable of searching for and loading them by name. This is
|
10
|
+
useful when you have an abstract base class which defines an interface and basic
|
11
|
+
functionality for a part of a larger system, and a collection of subclasses
|
12
|
+
which implement the interface for different underlying functionality.
|
13
|
+
|
14
|
+
An example of where this might be useful is in a program which talks to a
|
15
|
+
database. To avoid coupling it to a specific database, you use a Driver class
|
16
|
+
which encapsulates your program's interaction with the database behind a useful
|
17
|
+
interface. Now you can create a concrete implementation of the Driver class for
|
18
|
+
each kind of database you wish to talk to. If you make the base Driver class a
|
19
|
+
PluginFactory, too, you can add new drivers simply by dropping them in a
|
20
|
+
directory and using the Driver's `create` method to instantiate them:
|
21
|
+
|
22
|
+
=== Synopsis
|
23
|
+
|
24
|
+
in driver.rb:
|
25
|
+
|
26
|
+
require "PluginFactory"
|
27
|
+
|
28
|
+
class Driver
|
29
|
+
include PluginFactory
|
30
|
+
def self::derivative_dirs
|
31
|
+
["drivers"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
in drivers/mysql.rb:
|
36
|
+
|
37
|
+
require 'driver'
|
38
|
+
|
39
|
+
class MysqlDriver < Driver
|
40
|
+
...implementation...
|
41
|
+
end
|
42
|
+
|
43
|
+
in /usr/lib/ruby/1.8/PostgresDriver.rb:
|
44
|
+
|
45
|
+
require 'driver'
|
46
|
+
|
47
|
+
class PostgresDriver < Driver
|
48
|
+
...implementation...
|
49
|
+
end
|
50
|
+
|
51
|
+
elsewhere
|
52
|
+
|
53
|
+
require 'driver'
|
54
|
+
|
55
|
+
config[:driver_type] #=> "mysql"
|
56
|
+
driver = Driver.create( config[:driver_type] )
|
57
|
+
driver.class #=> MysqlDriver
|
58
|
+
pgdriver = Driver.create( "PostGresDriver" )
|
59
|
+
|
60
|
+
=== How Plugins Are Loaded
|
61
|
+
|
62
|
+
The +create+ class method added to your class by PluginFactory searches for your
|
63
|
+
module using several different strategies. It tries various permutations of the
|
64
|
+
base class's name in combination with the derivative requested. For example,
|
65
|
+
assume we want to make a +DataDriver+ base class, and then use plugins to define
|
66
|
+
drivers for different kinds of data sources:
|
67
|
+
|
68
|
+
require 'pluginfactory'
|
69
|
+
|
70
|
+
class DataDriver
|
71
|
+
include PluginFactory
|
72
|
+
end
|
73
|
+
|
74
|
+
When you attempt to load the 'socket' data-driver class like so:
|
75
|
+
|
76
|
+
DataDriver.create( 'socket' )
|
77
|
+
|
78
|
+
PluginFactory searches for modules with the following names:
|
79
|
+
|
80
|
+
'socketdatadriver'
|
81
|
+
'socket_datadriver'
|
82
|
+
'socketDataDriver'
|
83
|
+
'socket_DataDriver'
|
84
|
+
'SocketDataDriver'
|
85
|
+
'Socket_DataDriver'
|
86
|
+
'socket'
|
87
|
+
'Socket'
|
88
|
+
|
89
|
+
Obviously the last one will load something other than what is intended, so you
|
90
|
+
can also tell PluginFactory that plugins should be loaded from a subdirectory by
|
91
|
+
declaring a class method called `derivative_dirs` in the base class. It should
|
92
|
+
return an Array that contains a list of subdirectories to try:
|
93
|
+
|
94
|
+
class DataDriver
|
95
|
+
include PluginFactory
|
96
|
+
|
97
|
+
def self::derivative_dirs
|
98
|
+
['drivers']
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
This will change the list that is required to:
|
103
|
+
|
104
|
+
'drivers/socketdatadriver'
|
105
|
+
'drivers/socket_datadriver'
|
106
|
+
'drivers/socketDataDriver'
|
107
|
+
'drivers/socket_DataDriver'
|
108
|
+
'drivers/SocketDataDriver'
|
109
|
+
'drivers/Socket_DataDriver'
|
110
|
+
'drivers/socket'
|
111
|
+
'drivers/Socket'
|
112
|
+
|
113
|
+
If you return more than one subdirectory, each of them will be tried in turn:
|
114
|
+
|
115
|
+
class DataDriver
|
116
|
+
include PluginFactory
|
117
|
+
|
118
|
+
def self::derivative_dirs
|
119
|
+
['drivers', 'datadriver']
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
will change the search to include:
|
124
|
+
|
125
|
+
'drivers/socketdatadriver'
|
126
|
+
'drivers/socket_datadriver'
|
127
|
+
'drivers/socketDataDriver'
|
128
|
+
'drivers/socket_DataDriver'
|
129
|
+
'drivers/SocketDataDriver'
|
130
|
+
'drivers/Socket_DataDriver'
|
131
|
+
'drivers/socket'
|
132
|
+
'drivers/Socket'
|
133
|
+
'datadriver/socketdatadriver'
|
134
|
+
'datadriver/socket_datadriver'
|
135
|
+
'datadriver/socketDataDriver'
|
136
|
+
'datadriver/socket_DataDriver'
|
137
|
+
'datadriver/SocketDataDriver'
|
138
|
+
'datadriver/Socket_DataDriver'
|
139
|
+
'datadriver/socket'
|
140
|
+
'datadriver/Socket'
|
141
|
+
|
142
|
+
If the plugin is not found, a FactoryError is raised, and the message will list
|
143
|
+
all the permutations that were tried.
|
144
|
+
|
145
|
+
=== Logging
|
146
|
+
|
147
|
+
If you need a little more insight into what's going on, PluginFactory uses
|
148
|
+
'Logger' from the standard library. Just set its logger to your own to include
|
149
|
+
log messages about plugins being loaded:
|
150
|
+
|
151
|
+
|
152
|
+
require 'pluginfactory'
|
153
|
+
require 'logger'
|
154
|
+
|
155
|
+
class DataDriver
|
156
|
+
include PluginFactory
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
$logger = Logger.new( $stderr )
|
161
|
+
$logger.level = Logger::DEBUG
|
162
|
+
PluginFactory.logger = $logger
|
163
|
+
|
164
|
+
DataDriver.create( 'ringbuffer' )
|
165
|
+
|
166
|
+
this might generate a log that looks like:
|
167
|
+
|
168
|
+
D, [...] DEBUG -- : Loading derivative ringbuffer
|
169
|
+
D, [...] DEBUG -- : Subdirs are: [""]
|
170
|
+
D, [...] DEBUG -- : Path is: ["ringbufferdatadriver", "ringbufferDataDriver",
|
171
|
+
"ringbuffer"]...
|
172
|
+
D, [...] DEBUG -- : Trying ringbufferdatadriver...
|
173
|
+
D, [...] DEBUG -- : No module at 'ringbufferdatadriver', trying the next
|
174
|
+
alternative: 'no such file to load -- ringbufferdatadriver'
|
175
|
+
D, [...] DEBUG -- : Trying ringbufferDataDriver...
|
176
|
+
D, [...] DEBUG -- : No module at 'ringbufferDataDriver', trying the next
|
177
|
+
alternative: 'no such file to load -- ringbufferDataDriver'
|
178
|
+
D, [...] DEBUG -- : Trying ringbuffer...
|
179
|
+
D, [...] DEBUG -- : No module at 'ringbuffer', trying the next alternative:
|
180
|
+
'no such file to load -- ringbuffer'
|
181
|
+
D, [...] DEBUG -- : fatals = []
|
182
|
+
E, [...] ERROR -- : Couldn't find a DataDriver named 'ringbuffer':
|
183
|
+
tried ["ringbufferdatadriver", "ringbufferDataDriver", "ringbuffer"]
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
== Installation
|
188
|
+
|
189
|
+
gem install pluginfactory
|
190
|
+
|
191
|
+
|
192
|
+
== Contributing
|
193
|
+
|
194
|
+
You can check out the current development source with Mercurial via its
|
195
|
+
{Mercurial repo}[http://repo.deveiate.org/PluginFactory]. Or if you prefer
|
196
|
+
Git, via {its Github mirror}[https://github.com/ged/pluginfactory].
|
197
|
+
|
198
|
+
After checking out the source, run:
|
199
|
+
|
200
|
+
$ rake newb
|
201
|
+
|
202
|
+
This task will install any missing dependencies, run the tests/specs,
|
203
|
+
and generate the API documentation.
|
204
|
+
|
205
|
+
|
206
|
+
== License
|
207
|
+
|
208
|
+
Copyright (c) 2008-2012, Michael Granger and Martin Chase
|
209
|
+
All rights reserved.
|
210
|
+
|
211
|
+
Redistribution and use in source and binary forms, with or without
|
212
|
+
modification, are permitted provided that the following conditions are met:
|
213
|
+
|
214
|
+
* Redistributions of source code must retain the above copyright notice,
|
215
|
+
this list of conditions and the following disclaimer.
|
216
|
+
|
217
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
218
|
+
this list of conditions and the following disclaimer in the documentation
|
219
|
+
and/or other materials provided with the distribution.
|
220
|
+
|
221
|
+
* Neither the name of the author/s, nor the names of the project's
|
222
|
+
contributors may be used to endorse or promote products derived from this
|
223
|
+
software without specific prior written permission.
|
224
|
+
|
225
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
226
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
227
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
228
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
229
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
230
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
231
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
232
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
233
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
234
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
235
|
+
|
236
|
+
|
237
|
+
|
data/Rakefile
CHANGED
@@ -1,358 +1,28 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# PluginFactory rakefile
|
4
|
-
#
|
5
|
-
# Based on various other Rakefiles, especially one by Ben Bleything
|
6
|
-
#
|
7
|
-
# Copyright (c) 2007-2010 The FaerieMUD Consortium
|
8
|
-
#
|
9
|
-
# Authors:
|
10
|
-
# * Michael Granger <ged@FaerieMUD.org>
|
11
|
-
#
|
1
|
+
#!/usr/bin/env rake
|
12
2
|
|
13
|
-
|
14
|
-
require 'rbconfig'
|
15
|
-
require 'pathname'
|
16
|
-
basedir = Pathname.new( __FILE__ ).dirname
|
3
|
+
require 'hoe'
|
17
4
|
|
18
|
-
|
19
|
-
|
5
|
+
Hoe.plugin :deveiate
|
6
|
+
Hoe.plugin :mercurial
|
7
|
+
Hoe.plugin :signing
|
20
8
|
|
21
|
-
|
22
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
23
|
-
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
|
24
|
-
}
|
9
|
+
Hoe.plugins.delete :rubyforge
|
25
10
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# Fall back to a plain prompt
|
31
|
-
def readline( text )
|
32
|
-
$stderr.print( text.chomp )
|
33
|
-
return $stdin.gets
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
begin
|
38
|
-
require 'rubygems'
|
39
|
-
rescue LoadError
|
40
|
-
module Gem
|
41
|
-
class Specification; end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
require 'rbconfig'
|
46
|
-
require 'rake'
|
47
|
-
require 'rake/testtask'
|
48
|
-
require 'rake/packagetask'
|
49
|
-
require 'rake/clean'
|
50
|
-
# require 'rake/191_compat.rb'
|
51
|
-
|
52
|
-
$dryrun = false
|
53
|
-
|
54
|
-
### Config constants
|
55
|
-
BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
|
56
|
-
BINDIR = BASEDIR + 'bin'
|
57
|
-
LIBDIR = BASEDIR + 'lib'
|
58
|
-
EXTDIR = BASEDIR + 'ext'
|
59
|
-
DOCSDIR = BASEDIR + 'docs'
|
60
|
-
PKGDIR = BASEDIR + 'pkg'
|
61
|
-
DATADIR = BASEDIR + 'data'
|
62
|
-
|
63
|
-
MANUALDIR = DOCSDIR + 'manual'
|
64
|
-
|
65
|
-
PROJECT_NAME = 'PluginFactory'
|
66
|
-
PKG_NAME = PROJECT_NAME.downcase
|
67
|
-
PKG_SUMMARY = 'A mixin for making plugin classes'
|
68
|
-
|
69
|
-
# Cruisecontrol stuff
|
70
|
-
CC_BUILD_LABEL = ENV['CC_BUILD_LABEL']
|
71
|
-
CC_BUILD_ARTIFACTS = ENV['CC_BUILD_ARTIFACTS'] || 'artifacts'
|
72
|
-
|
73
|
-
VERSION_FILE = LIBDIR + 'pluginfactory.rb'
|
74
|
-
if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
|
75
|
-
PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
|
76
|
-
elsif VERSION_FILE.exist?
|
77
|
-
PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
|
78
|
-
end
|
79
|
-
|
80
|
-
PKG_VERSION = '0.0.0' unless defined?( PKG_VERSION ) && !PKG_VERSION.nil?
|
81
|
-
|
82
|
-
PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
|
83
|
-
GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
|
84
|
-
|
85
|
-
# Universal VCS constants
|
86
|
-
DEFAULT_EDITOR = 'vi'
|
87
|
-
COMMIT_MSG_FILE = 'commit-msg.txt'
|
88
|
-
FILE_INDENT = " " * 12
|
89
|
-
LOG_INDENT = " " * 3
|
90
|
-
|
91
|
-
EXTCONF = EXTDIR + 'extconf.rb'
|
92
|
-
|
93
|
-
ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
|
94
|
-
|
95
|
-
TEXT_FILES = Rake::FileList.new( %w[Rakefile ChangeLog README* LICENSE] )
|
96
|
-
BIN_FILES = Rake::FileList.new( "#{BINDIR}/*" )
|
97
|
-
LIB_FILES = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
|
98
|
-
EXT_FILES = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
|
99
|
-
DATA_FILES = Rake::FileList.new( "#{DATADIR}/**/*" )
|
100
|
-
|
101
|
-
SPECDIR = BASEDIR + 'spec'
|
102
|
-
SPECLIBDIR = SPECDIR + 'lib'
|
103
|
-
SPEC_FILES = Rake::FileList.new( "#{SPECDIR}/**/*_spec.rb", "#{SPECLIBDIR}/**/*.rb" )
|
104
|
-
|
105
|
-
TESTDIR = BASEDIR + 'tests'
|
106
|
-
TEST_FILES = Rake::FileList.new( "#{TESTDIR}/**/*.tests.rb" )
|
107
|
-
|
108
|
-
RAKE_TASKDIR = BASEDIR + 'rake'
|
109
|
-
RAKE_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/*.rb" )
|
110
|
-
PKG_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/{191_compat,helpers,packaging,rdoc,testing}.rb" )
|
111
|
-
PKG_TASKLIBS.include( "#{RAKE_TASKDIR}/manual.rb" ) if MANUALDIR.exist?
|
112
|
-
|
113
|
-
RAKE_TASKLIBS_URL = 'http://repo.deveiate.org/rake-tasklibs'
|
114
|
-
|
115
|
-
LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
|
116
|
-
|
117
|
-
EXTRA_PKGFILES = Rake::FileList.new
|
118
|
-
|
119
|
-
RELEASE_FILES = TEXT_FILES +
|
120
|
-
SPEC_FILES +
|
121
|
-
TEST_FILES +
|
122
|
-
BIN_FILES +
|
123
|
-
LIB_FILES +
|
124
|
-
EXT_FILES +
|
125
|
-
DATA_FILES +
|
126
|
-
RAKE_TASKLIBS +
|
127
|
-
EXTRA_PKGFILES
|
128
|
-
|
129
|
-
|
130
|
-
RELEASE_FILES << LOCAL_RAKEFILE.to_s if LOCAL_RAKEFILE.exist?
|
131
|
-
|
132
|
-
RELEASE_ANNOUNCE_ADDRESSES = [
|
133
|
-
]
|
134
|
-
|
135
|
-
COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
|
136
|
-
RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
|
137
|
-
RCOV_OPTS = [
|
138
|
-
'--exclude', RCOV_EXCLUDES,
|
139
|
-
'--xrefs',
|
140
|
-
'--save',
|
141
|
-
'--callsites',
|
142
|
-
#'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0
|
143
|
-
]
|
144
|
-
|
145
|
-
|
146
|
-
### Load some task libraries that need to be loaded early
|
147
|
-
if !RAKE_TASKDIR.exist?
|
148
|
-
$stderr.puts "It seems you don't have the build task directory. Shall I fetch it "
|
149
|
-
ans = readline( "for you? [y]" )
|
150
|
-
ans = 'y' if !ans.nil? && ans.empty?
|
151
|
-
|
152
|
-
if ans =~ /^y/i
|
153
|
-
$stderr.puts "Okay, fetching #{RAKE_TASKLIBS_URL} into #{RAKE_TASKDIR}..."
|
154
|
-
system 'hg', 'clone', RAKE_TASKLIBS_URL, "./#{RAKE_TASKDIR}"
|
155
|
-
if ! $?.success?
|
156
|
-
fail "Damn. That didn't work. Giving up; maybe try manually fetching?"
|
157
|
-
end
|
158
|
-
else
|
159
|
-
$stderr.puts "Then I'm afraid I can't continue. Best of luck."
|
160
|
-
fail "Rake tasklibs not present."
|
161
|
-
end
|
162
|
-
|
163
|
-
RAKE_TASKLIBS.include( "#{RAKE_TASKDIR}/*.rb" )
|
164
|
-
end
|
165
|
-
|
166
|
-
require RAKE_TASKDIR + 'helpers.rb'
|
167
|
-
include RakefileHelpers
|
11
|
+
hoespec = Hoe.spec 'pluginfactory' do
|
12
|
+
self.readme_file = 'README.rdoc'
|
13
|
+
self.history_file = 'History.rdoc'
|
14
|
+
self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
|
168
15
|
|
169
|
-
|
170
|
-
|
171
|
-
id = `#{hg} id -n`.chomp
|
172
|
-
PKG_BUILD = "pre%03d" % [(id.chomp[ /^[[:xdigit:]]+/ ] || '1')]
|
173
|
-
else
|
174
|
-
PKG_BUILD = 'pre000'
|
175
|
-
end
|
176
|
-
SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
|
177
|
-
SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
|
178
|
-
|
179
|
-
# Documentation constants
|
180
|
-
API_DOCSDIR = DOCSDIR + 'api'
|
181
|
-
README_FILE = TEXT_FILES.find {|path| path =~ /^README/ } || 'README'
|
182
|
-
RDOC_OPTIONS = [
|
183
|
-
'--tab-width=4',
|
184
|
-
'--show-hash',
|
185
|
-
'--include', BASEDIR.to_s,
|
186
|
-
"--main=#{README_FILE}",
|
187
|
-
"--title=#{PKG_NAME}",
|
188
|
-
]
|
189
|
-
YARD_OPTIONS = [
|
190
|
-
'--use-cache',
|
191
|
-
'--no-private',
|
192
|
-
'--protected',
|
193
|
-
'-r', README_FILE,
|
194
|
-
'--exclude', 'extconf\\.rb',
|
195
|
-
'--files', 'ChangeLog,LICENSE',
|
196
|
-
'--output-dir', API_DOCSDIR.to_s,
|
197
|
-
'--title', "#{PKG_NAME} #{PKG_VERSION}",
|
198
|
-
]
|
199
|
-
|
200
|
-
# Release constants
|
201
|
-
SMTP_HOST = "mail.faeriemud.org"
|
202
|
-
SMTP_PORT = 465 # SMTP + SSL
|
203
|
-
|
204
|
-
# Project constants
|
205
|
-
PROJECT_HOST = 'deveiate'
|
206
|
-
PROJECT_PUBDIR = '/usr/local/www/public/code'
|
207
|
-
PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
|
208
|
-
PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
|
209
|
-
PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
|
210
|
-
|
211
|
-
GEM_PUBHOST = 'rubygems.org'
|
212
|
-
|
213
|
-
# Gem dependencies: gemname => version
|
214
|
-
DEPENDENCIES = {
|
215
|
-
}
|
216
|
-
|
217
|
-
# Developer Gem dependencies: gemname => version
|
218
|
-
DEVELOPMENT_DEPENDENCIES = {
|
219
|
-
'rake' => '>= 0.8.7',
|
220
|
-
'rcodetools' => '>= 0.7.0.0',
|
221
|
-
'rcov' => '>= 0.8.1.2.0',
|
222
|
-
'rdoc' => '>= 2.4.3',
|
223
|
-
'RedCloth' => '>= 4.0.3',
|
224
|
-
'rspec' => '>= 1.2.6',
|
225
|
-
'ruby-termios' => '>= 0.9.6',
|
226
|
-
'text-format' => '>= 1.0.0',
|
227
|
-
'tmail' => '>= 1.2.3.1',
|
228
|
-
'diff-lcs' => '>= 1.1.2',
|
229
|
-
}
|
230
|
-
|
231
|
-
# Non-gem requirements: packagename => version
|
232
|
-
REQUIREMENTS = {
|
233
|
-
}
|
234
|
-
|
235
|
-
# RubyGem specification
|
236
|
-
GEMSPEC = Gem::Specification.new do |gem|
|
237
|
-
gem.name = PKG_NAME.downcase
|
238
|
-
gem.version = PKG_VERSION
|
239
|
-
|
240
|
-
gem.summary = PKG_SUMMARY
|
241
|
-
gem.description = [
|
242
|
-
"PluginFactory is a mixin module that turns an including class into a factory for",
|
243
|
-
"its derivatives, capable of searching for and loading them by name. This is",
|
244
|
-
"useful when you have an abstract base class which defines an interface and basic",
|
245
|
-
"functionality for a part of a larger system, and a collection of subclasses",
|
246
|
-
"which implement the interface for different underlying functionality.",
|
247
|
-
].join( "\n" )
|
248
|
-
|
249
|
-
gem.authors = "Martin Chase, Michael Granger"
|
250
|
-
gem.email = ["stillflame@FaerieMUD.org", "ged@FaerieMUD.org"]
|
251
|
-
gem.homepage = 'http://deveiate.org/projects/PluginFactory/'
|
252
|
-
|
253
|
-
gem.has_rdoc = true
|
254
|
-
gem.rdoc_options = RDOC_OPTIONS
|
255
|
-
gem.extra_rdoc_files = TEXT_FILES - [ 'Rakefile' ]
|
256
|
-
|
257
|
-
gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
|
258
|
-
gem.executables = BIN_FILES.select {|pn| File.executable?(pn) }.
|
259
|
-
collect {|pn| File.basename(pn) }
|
260
|
-
gem.require_paths << EXTDIR.relative_path_from( BASEDIR ).to_s if EXTDIR.exist?
|
261
|
-
|
262
|
-
if EXTCONF.exist?
|
263
|
-
gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
|
264
|
-
end
|
265
|
-
|
266
|
-
gem.files = RELEASE_FILES
|
267
|
-
gem.test_files = SPEC_FILES
|
268
|
-
|
269
|
-
# signing key and certificate chain
|
270
|
-
gem.signing_key = '/Volumes/Keys/ged-private_gem_key.pem'
|
271
|
-
gem.cert_chain = [File.expand_path('~/.gem/ged-public_gem_cert.pem')]
|
272
|
-
|
273
|
-
DEPENDENCIES.each do |name, version|
|
274
|
-
version = '>= 0' if version.length.zero?
|
275
|
-
gem.add_runtime_dependency( name, version )
|
276
|
-
end
|
16
|
+
self.developer 'Martin Chase', 'stillflame@FaerieMUD.org'
|
17
|
+
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
277
18
|
|
278
|
-
|
279
|
-
gem.requirements << [ name, version ].compact.join(' ')
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
$trace = Rake.application.options.trace ? true : false
|
284
|
-
$dryrun = Rake.application.options.dryrun ? true : false
|
285
|
-
$include_dev_dependencies = false
|
19
|
+
self.dependency 'hoe-deveiate', '~> 0.0', :development
|
286
20
|
|
287
|
-
|
288
|
-
|
289
|
-
next if tasklib.to_s =~ %r{/helpers\.rb$}
|
290
|
-
begin
|
291
|
-
trace " loading tasklib %s" % [ tasklib ]
|
292
|
-
import tasklib
|
293
|
-
rescue ScriptError => err
|
294
|
-
fail "Task library '%s' failed to load: %s: %s" %
|
295
|
-
[ tasklib, err.class.name, err.message ]
|
296
|
-
trace "Backtrace: \n " + err.backtrace.join( "\n " )
|
297
|
-
rescue => err
|
298
|
-
log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
|
299
|
-
[ tasklib, err.class.name, err.message ]
|
300
|
-
trace "Backtrace: \n " + err.backtrace.join( "\n " )
|
301
|
-
end
|
21
|
+
self.spec_extras[:licenses] = ["BSD"]
|
22
|
+
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
302
23
|
end
|
303
24
|
|
304
|
-
|
305
|
-
import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
|
306
|
-
|
307
|
-
|
308
|
-
#####################################################################
|
309
|
-
### T A S K S
|
310
|
-
#####################################################################
|
311
|
-
|
312
|
-
### Default task
|
313
|
-
task :default => [:clean, :local, :spec, :apidocs, :package]
|
25
|
+
ENV['VERSION'] ||= hoespec.spec.version.to_s
|
314
26
|
|
315
|
-
|
316
|
-
task :local
|
317
|
-
|
318
|
-
### Task: clean
|
319
|
-
CLEAN.include 'coverage', '**/*.orig', '**/*.rej'
|
320
|
-
CLOBBER.include 'artifacts', 'coverage.info', 'ChangeLog', PKGDIR
|
321
|
-
|
322
|
-
### Task: changelog
|
323
|
-
file 'ChangeLog' do |task|
|
324
|
-
log "Updating #{task.name}"
|
325
|
-
|
326
|
-
changelog = make_changelog()
|
327
|
-
File.open( task.name, 'w' ) do |fh|
|
328
|
-
fh.print( changelog )
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
|
333
|
-
### Task: cruise (Cruisecontrol task)
|
334
|
-
desc "Cruisecontrol build"
|
335
|
-
task :cruise => [:clean, 'spec:quiet', :package] do |task|
|
336
|
-
raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
|
337
|
-
artifact_dir = ARTIFACTS_DIR.cleanpath + (CC_BUILD_LABEL || Time.now.strftime('%Y%m%d-%T'))
|
338
|
-
artifact_dir.mkpath
|
339
|
-
|
340
|
-
coverage = BASEDIR + 'coverage'
|
341
|
-
if coverage.exist? && coverage.directory?
|
342
|
-
$stderr.puts "Copying coverage stats..."
|
343
|
-
FileUtils.cp_r( 'coverage', artifact_dir )
|
344
|
-
end
|
345
|
-
|
346
|
-
$stderr.puts "Copying packages..."
|
347
|
-
FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
|
348
|
-
end
|
349
|
-
|
350
|
-
|
351
|
-
desc "Update the build system to the latest version"
|
352
|
-
task :update_build do
|
353
|
-
log "Updating the build system"
|
354
|
-
run 'hg', '-R', RAKE_TASKDIR, 'pull', '-u'
|
355
|
-
log "Updating the Rakefile"
|
356
|
-
sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
|
357
|
-
end
|
27
|
+
task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
|
358
28
|
|