digestr 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS +3 -0
- data/LICENSE +20 -0
- data/README +136 -0
- data/Rakefile +420 -0
- data/TODO +10 -0
- data/install.rb +35 -0
- data/lib/xml/digester.rb +10 -0
- data/lib/xml/digestr.rb +810 -0
- data/tests/runner.rb +5 -0
- metadata +66 -0
data/CONTRIBUTORS
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c)2006 Ross Bamford (and contributors). All rights reserved.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
20
|
+
|
data/README
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
= DigestR - Fast XML Digester for Ruby
|
2
|
+
|
3
|
+
== What is this?
|
4
|
+
|
5
|
+
DigestR is a fast rules-based XML processor (similar to the Jakarta
|
6
|
+
Commons Digester) for Ruby, based upon the libxml-ruby Libxml2 binding.
|
7
|
+
It's SAX-based rules engine allows code to be executed based on patterns
|
8
|
+
and individual elements in the source XML.
|
9
|
+
|
10
|
+
For the whys and wherefores of this kind of thing, see:
|
11
|
+
|
12
|
+
http://jakarta.apache.org/commons/digester
|
13
|
+
|
14
|
+
== Prerequisites
|
15
|
+
|
16
|
+
DigestR requires Libxml-Ruby (http://libxml.rubyforge.org) version 0.3.7
|
17
|
+
(2005/4/14, developmental) / 0.3.8 (release) or later. If not installing
|
18
|
+
via Rubygems (or if you do not wish to auto-install dependencies) you
|
19
|
+
will need to install it prior to installing DigestR.
|
20
|
+
|
21
|
+
== Installation ...
|
22
|
+
|
23
|
+
=== ... with RubyGems?
|
24
|
+
|
25
|
+
If you have RubyGems, you can install DigestR by simply issuing the command:
|
26
|
+
|
27
|
+
gem install -r digestr
|
28
|
+
|
29
|
+
Which should download the latest version and install it. If you experience
|
30
|
+
problems, or wish to perform an offline installation, then simply download
|
31
|
+
the .gem file from the FRS, and execute the gem command from within the same
|
32
|
+
directory.
|
33
|
+
|
34
|
+
*Note* if auto-installing dependencies: The libxml-ruby gem includes native
|
35
|
+
extensions, and will require a sane build environment on the installation
|
36
|
+
machine. If you experience problems with the libxml install you may need to
|
37
|
+
install manually with additional extconf options - see the libxml-ruby
|
38
|
+
guide (http://libxml.rubyforge.org/install.html) for more information.
|
39
|
+
|
40
|
+
=== ... with install.rb?
|
41
|
+
|
42
|
+
If you don't have RubyGems, you can install from one of the tarball or zip
|
43
|
+
packages, using the following command:
|
44
|
+
|
45
|
+
ruby install.rb
|
46
|
+
|
47
|
+
from the unpacked root directory. This will copy the libaries to the
|
48
|
+
appropriate place for your ruby installation.
|
49
|
+
|
50
|
+
=== Did it work?
|
51
|
+
|
52
|
+
With that done, you should be able to run:
|
53
|
+
|
54
|
+
ruby [-rubygems] -rxml/digestr -e 'puts XML::Digester::VERSION'
|
55
|
+
|
56
|
+
to verify that the installation succeeded and the library can be loaded
|
57
|
+
by ruby.
|
58
|
+
|
59
|
+
== How do I use it?
|
60
|
+
|
61
|
+
Please see the API reference for usage information. The latest version can be
|
62
|
+
found online at http://digestr.rubyforge.org/ , and documentation source for
|
63
|
+
a specific release is included in the release package.
|
64
|
+
|
65
|
+
The RDoc can be built by running 'rake doc' in the source directory.
|
66
|
+
|
67
|
+
== How fast is 'fast'?
|
68
|
+
|
69
|
+
Currently, 'fast' is a relative term - there is certainly room for improvement
|
70
|
+
in DigestR itself, though the fact that it's based on the (native) libxml2
|
71
|
+
ruby binding gives a good burst of speed and I think DigestR should be fast
|
72
|
+
enough for most uses. To give an idea, here are some informal benchmarks run
|
73
|
+
against the REXML-based xmldigester
|
74
|
+
(http://rubyforge.org/projects/xmldigester/) using the addressbook example
|
75
|
+
included with that package (over 500 runs):
|
76
|
+
|
77
|
+
###### ORIGINAL TWO-PERSON ADDRESSBOOK ######
|
78
|
+
###### XMLDIGESTER ######
|
79
|
+
user system total real
|
80
|
+
2.860000 0.170000 3.030000 ( 3.097948)
|
81
|
+
user system total real
|
82
|
+
2.820000 0.160000 2.980000 ( 3.061908)
|
83
|
+
|
84
|
+
###### DIGESTR ######
|
85
|
+
user system total real
|
86
|
+
0.980000 0.070000 1.050000 ( 1.118739)
|
87
|
+
user system total real
|
88
|
+
0.970000 0.060000 1.030000 ( 1.089957)
|
89
|
+
|
90
|
+
|
91
|
+
###### TWENTY-PERSON ADDRESSBOOK ######
|
92
|
+
###### XMLDIGESTER ######
|
93
|
+
user system total real
|
94
|
+
23.000000 0.990000 23.990000 ( 24.265204)
|
95
|
+
user system total real
|
96
|
+
22.610000 1.010000 23.620000 ( 23.936342)
|
97
|
+
|
98
|
+
###### DIGESTR ######
|
99
|
+
user system total real
|
100
|
+
8.880000 0.140000 9.020000 ( 9.144904)
|
101
|
+
user system total real
|
102
|
+
8.930000 0.140000 9.070000 ( 9.227588)
|
103
|
+
|
104
|
+
== Notes
|
105
|
+
=== A note about version numbers
|
106
|
+
|
107
|
+
DigestR uses odd/even numbers for development/release versions. When the final
|
108
|
+
version component is odd, the package is an 'unofficial' build - generally
|
109
|
+
this means built manually from source, during development. These will never
|
110
|
+
be distributed, and there's no guarantee that any two packages with the same
|
111
|
+
development version will actually be the same. These packages will have no
|
112
|
+
corresponding SCM tag.
|
113
|
+
|
114
|
+
Even numbers always denote 'official' releases, which are released on
|
115
|
+
RubyForge and tagged as such in SCM. These packages can be trusted to exhibit
|
116
|
+
version consistency.
|
117
|
+
|
118
|
+
If you are bundling DigestR with your product, please ensure you use an
|
119
|
+
official release version whenever possible. If you must use a developmental
|
120
|
+
version, please modify the package version to reflect the fact that it is a
|
121
|
+
custom build (e.g. 0.1.3-mycompany-20051021) to prevent inconsistent
|
122
|
+
development packages from escaping into the wild.
|
123
|
+
|
124
|
+
=== Further information
|
125
|
+
|
126
|
+
DigestR is developed by Ross Bamford (rosco <at> roscopeco.co.uk), with help
|
127
|
+
from the developers listed in CONTRIBUTORS. Any bugs are probably all his own.
|
128
|
+
|
129
|
+
* Homepage - http://digestr.rubyforge.org/
|
130
|
+
* Project - http://rubyforge.org/projects/digestr
|
131
|
+
|
132
|
+
As you may have guessed, DigestR's hosting and development services are
|
133
|
+
provided by http://RubyForge.org - many thanks to Tom Copeland and all concerned.
|
134
|
+
|
135
|
+
Thanks also to Yukihiro Matsumoto for a consistently amazing platform, and all
|
136
|
+
those who write and contribute to the libraries DigestR depends on.
|
data/Rakefile
ADDED
@@ -0,0 +1,420 @@
|
|
1
|
+
# DigestR Rakefile (run with 'rake' command)
|
2
|
+
#
|
3
|
+
# Copyright 2006 Ross Bamford (and contributors). All rights reserved.
|
4
|
+
# Distributed under an MIT style license. See LICENSE for details.
|
5
|
+
#
|
6
|
+
# $Id: Rakefile 4 2006-04-17 19:05:32Z roscopeco $
|
7
|
+
#
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'rubygems'
|
11
|
+
require 'rake/gempackagetask'
|
12
|
+
rescue Exception
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'rake/clean'
|
17
|
+
require 'rake/testtask'
|
18
|
+
require 'rake/rdoctask'
|
19
|
+
# This needs to go at the front of the libpath
|
20
|
+
# Otherwise, any pre-installed lib gets found,
|
21
|
+
# and used from there. This is only necessary
|
22
|
+
# for DigestR's build, to make sure we always unit-
|
23
|
+
# test and build doc with the working copy.
|
24
|
+
$LOAD_PATH.unshift 'lib'
|
25
|
+
require 'xml/digestr'
|
26
|
+
|
27
|
+
CLEAN.include('tidy.log')
|
28
|
+
CLOBBER.include('TAGS')
|
29
|
+
CLOBBER.include('html')
|
30
|
+
|
31
|
+
def announce(msg='')
|
32
|
+
STDERR.puts msg
|
33
|
+
end
|
34
|
+
|
35
|
+
# Determine the current version of the software
|
36
|
+
CURRENT_VERSION = XML::Digester::VERSION || "0.0.0"
|
37
|
+
|
38
|
+
if ENV['REL']
|
39
|
+
PKG_VERSION = ENV['REL']
|
40
|
+
else
|
41
|
+
PKG_VERSION = CURRENT_VERSION
|
42
|
+
end
|
43
|
+
|
44
|
+
SRC_RB = FileList['lib/**/*.rb']
|
45
|
+
|
46
|
+
# The default task is run if rake is given no explicit arguments.
|
47
|
+
|
48
|
+
desc "Default Task (All tests)"
|
49
|
+
task :default => :alltests
|
50
|
+
|
51
|
+
# Test Tasks ---------------------------------------------------------
|
52
|
+
|
53
|
+
task :ta => :alltests
|
54
|
+
#task :tf => :funtests
|
55
|
+
task :tu => :unittests
|
56
|
+
task :test => :unittests
|
57
|
+
|
58
|
+
Rake::TestTask.new(:alltests) do |t|
|
59
|
+
t.test_files = FileList[
|
60
|
+
'tests/tc_*.rb',
|
61
|
+
'tests/contrib/tc_*.rb',
|
62
|
+
'tests/fun_*.rb'
|
63
|
+
]
|
64
|
+
t.warning = true
|
65
|
+
t.verbose = true
|
66
|
+
end
|
67
|
+
|
68
|
+
Rake::TestTask.new(:unittests) do |t|
|
69
|
+
t.test_files = FileList['tests/tc_*.rb']
|
70
|
+
t.warning = true
|
71
|
+
t.verbose = false
|
72
|
+
end
|
73
|
+
|
74
|
+
# Rake::TestTask.new(:funtests) do |t|
|
75
|
+
# t.test_files = FileList['test/fun*.rb']
|
76
|
+
# t.warning = true
|
77
|
+
# t.warning = true
|
78
|
+
# end
|
79
|
+
|
80
|
+
# directory 'testdata'
|
81
|
+
# [:alltests, :unittests].each do |t|
|
82
|
+
# task t => ['testdata']
|
83
|
+
# end
|
84
|
+
|
85
|
+
# CVS Tasks ----------------------------------------------------------
|
86
|
+
|
87
|
+
# Install using the standard install.rb script.
|
88
|
+
desc "Install the application"
|
89
|
+
task :install do
|
90
|
+
ruby "install.rb"
|
91
|
+
end
|
92
|
+
|
93
|
+
# Website / Doc tasks ------------------------------------------------
|
94
|
+
|
95
|
+
# Create a task to build the RDOC documentation tree.
|
96
|
+
rd = Rake::RDocTask.new(:doc) { |rdoc|
|
97
|
+
rdoc.rdoc_dir = 'html'
|
98
|
+
# rdoc.template = 'kilmer'
|
99
|
+
# rdoc.template = 'css2'
|
100
|
+
#rdoc.template = 'doc/jamis.rb'
|
101
|
+
rdoc.title = "DigestR"
|
102
|
+
rdoc.options << '--main' << 'README'
|
103
|
+
rdoc.rdoc_files.include('README', 'LICENSE', 'TODO', 'CONTRIBUTORS')
|
104
|
+
rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
|
105
|
+
rdoc.rdoc_files.exclude(/\bcontrib\b/)
|
106
|
+
}
|
107
|
+
|
108
|
+
desc "Publish the documentation and web site"
|
109
|
+
task :doc_upload => [ :doc ] do
|
110
|
+
if acct = ENV['RUBYFORGE_ACCT']
|
111
|
+
require 'rake/contrib/sshpublisher'
|
112
|
+
Rake::SshDirPublisher.new(
|
113
|
+
"#{acct}@rubyforge.org",
|
114
|
+
"/var/www/gforge-projects/digestr",
|
115
|
+
"html"
|
116
|
+
).upload
|
117
|
+
else
|
118
|
+
$stderr << "Skipping documentation upload - Need to set RUBYFORGE_ACCT to your rubyforge.org user name"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# ====================================================================
|
123
|
+
# Create a task that will package the software into distributable
|
124
|
+
# tar, zip and gem files.
|
125
|
+
|
126
|
+
# don't include rendered website and all that Jazz
|
127
|
+
PKG_FILES = FileList[
|
128
|
+
'install.rb',
|
129
|
+
'[A-Z]*',
|
130
|
+
'lib/**/*.rb',
|
131
|
+
'test/**/*',
|
132
|
+
'doc/**/*'
|
133
|
+
]
|
134
|
+
|
135
|
+
if ! defined?(Gem)
|
136
|
+
puts "Package Target requires RubyGEMs"
|
137
|
+
else
|
138
|
+
spec = Gem::Specification.new do |s|
|
139
|
+
|
140
|
+
#### Basic information.
|
141
|
+
|
142
|
+
s.name = 'digestr'
|
143
|
+
s.version = PKG_VERSION
|
144
|
+
s.summary = "Libxml2-based Commons Digester port for Ruby"
|
145
|
+
s.description = <<-EOF
|
146
|
+
DigestR is a fast rules-based XML processor (similar to the Jakarta
|
147
|
+
Commons Digester) for Ruby, based upon the libxml-ruby Libxml2 binding.
|
148
|
+
EOF
|
149
|
+
|
150
|
+
#### Dependencies and requirements.
|
151
|
+
|
152
|
+
s.add_dependency('libxml-ruby', '>= 0.3.7')
|
153
|
+
#s.requirements << ""
|
154
|
+
|
155
|
+
#### Which files are to be included in this gem?
|
156
|
+
|
157
|
+
s.files = PKG_FILES.to_a
|
158
|
+
|
159
|
+
#### Load-time details: library and application (you will need one or both).
|
160
|
+
|
161
|
+
s.require_path = 'lib' # Use these for libraries.
|
162
|
+
|
163
|
+
#### Documentation and testing.
|
164
|
+
|
165
|
+
s.has_rdoc = true
|
166
|
+
s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
167
|
+
s.rdoc_options <<
|
168
|
+
'--title' << 'DigestR - API' <<
|
169
|
+
'--main' << 'README'
|
170
|
+
|
171
|
+
s.test_files = Dir.glob('tests/runner.rb')
|
172
|
+
|
173
|
+
#### Author and project details.
|
174
|
+
|
175
|
+
s.author = "Ross Bamford"
|
176
|
+
s.email = "rosco@roscopeco.co.uk"
|
177
|
+
s.homepage = "http://digestr.rubyforge.org"
|
178
|
+
s.rubyforge_project = "digestr"
|
179
|
+
# if ENV['CERT_DIR']
|
180
|
+
# s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
|
181
|
+
# s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
|
182
|
+
# end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Quick fix for Ruby 1.8.3 / YAML bug
|
186
|
+
if (RUBY_VERSION == '1.8.3')
|
187
|
+
def spec.to_yaml
|
188
|
+
out = super
|
189
|
+
out = '--- ' + out unless out =~ /^---/
|
190
|
+
out
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
package_task = Rake::GemPackageTask.new(spec) do |pkg|
|
195
|
+
pkg.need_zip = true
|
196
|
+
pkg.need_tar_gz = true
|
197
|
+
pkg.package_dir = 'pkg'
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Misc tasks =========================================================
|
202
|
+
|
203
|
+
def count_lines(filename)
|
204
|
+
lines = 0
|
205
|
+
codelines = 0
|
206
|
+
open(filename) { |f|
|
207
|
+
f.each do |line|
|
208
|
+
lines += 1
|
209
|
+
next if line =~ /^\s*$/
|
210
|
+
next if line =~ /^\s*#/
|
211
|
+
codelines += 1
|
212
|
+
end
|
213
|
+
}
|
214
|
+
[lines, codelines]
|
215
|
+
end
|
216
|
+
|
217
|
+
def show_line(msg, lines, loc)
|
218
|
+
printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
|
219
|
+
end
|
220
|
+
|
221
|
+
desc "Count total lines in source"
|
222
|
+
task :lines do
|
223
|
+
total_lines = 0
|
224
|
+
total_code = 0
|
225
|
+
show_line("File Name", "LINES", "LOC")
|
226
|
+
SRC_RB.each do |fn|
|
227
|
+
lines, codelines = count_lines(fn)
|
228
|
+
show_line(fn, lines, codelines)
|
229
|
+
total_lines += lines
|
230
|
+
total_code += codelines
|
231
|
+
end
|
232
|
+
show_line("TOTAL", total_lines, total_code)
|
233
|
+
end
|
234
|
+
|
235
|
+
ARCHIVEDIR = '/mnt/usb'
|
236
|
+
|
237
|
+
task :archive => [:package] do
|
238
|
+
cp FileList["pkg/*.tar.gz", "pkg/*.zip", "pkg/*.gem"], ARCHIVEDIR
|
239
|
+
end
|
240
|
+
|
241
|
+
# Define an optional publish target in an external file. If the
|
242
|
+
# publish.rf file is not found, the publish targets won't be defined.
|
243
|
+
|
244
|
+
load "publish.rf" if File.exist? "publish.rf"
|
245
|
+
|
246
|
+
# Support Tasks ------------------------------------------------------
|
247
|
+
|
248
|
+
desc "Look for TODO and FIXME tags in the code"
|
249
|
+
task :todo do
|
250
|
+
FileList['**/*.rb'].egrep /#.*(FIXME|TODO|TBD)/
|
251
|
+
end
|
252
|
+
|
253
|
+
desc "Look for Debugging print lines"
|
254
|
+
task :dbg do
|
255
|
+
FileList['**/*.rb'].egrep /\bDBG|\bbreakpoint\b/
|
256
|
+
end
|
257
|
+
|
258
|
+
desc "List all ruby files"
|
259
|
+
task :rubyfiles do
|
260
|
+
puts Dir['**/*.rb'].reject { |fn| fn =~ /^pkg/ }
|
261
|
+
puts Dir['bin/*'].reject { |fn| fn =~ /CVS|(~$)|(\.rb$)/ }
|
262
|
+
end
|
263
|
+
|
264
|
+
desc "Show deprecation notes"
|
265
|
+
task :deprecated do
|
266
|
+
Dir['lib/**/*.r?'].each do |fn|
|
267
|
+
File.open(fn) do |f|
|
268
|
+
[*f].each_with_index do |line,i|
|
269
|
+
if line =~ /#(.*)vv([0-9\.]+)(?:[\s\t]*)v-([0-9\.]+)/
|
270
|
+
cmnt = $~[1].strip
|
271
|
+
cmnt = '<No comment>' if (cmnt.nil? or cmnt.empty?)
|
272
|
+
printf "%s:%d\n%-60s %5s %5s\n\n", fn, i+1, cmnt, $~[2].strip, $~[3].strip
|
273
|
+
end #if splits okay
|
274
|
+
end #each_w_idx
|
275
|
+
end #fopen
|
276
|
+
end #dir
|
277
|
+
end
|
278
|
+
|
279
|
+
desc "Find features deprecated at VER"
|
280
|
+
task :deprecated_by do
|
281
|
+
fail "\nYou must specify the version to check (VER=x.y.z)\n\n" unless ver = ENV['VER']
|
282
|
+
Dir['lib/**/*.r?'].each do |fn|
|
283
|
+
File.open(fn) do |f|
|
284
|
+
[*f].each_with_index do |line,i|
|
285
|
+
if line =~ /vv#{ver}/
|
286
|
+
if line =~ /#(.*)vv([0-9\.]+)(?:[\s\t]*)v-([0-9\.]+)/
|
287
|
+
cmnt = $~[1].strip
|
288
|
+
cmnt = '<No comment>' if (cmnt.nil? or cmnt.empty?)
|
289
|
+
printf "%s:%d\n%-60s %5s %5s\n\n", fn, i+1, cmnt, $~[2].strip, $~[3].strip
|
290
|
+
end #if splits okay
|
291
|
+
end #if line is dep remove
|
292
|
+
end #each_w_idx
|
293
|
+
end #fopen
|
294
|
+
end #dir
|
295
|
+
end
|
296
|
+
|
297
|
+
desc "Find deprecated features to be removed by VER"
|
298
|
+
task :deprecated_due do
|
299
|
+
fail "\nYou must specify the version to check (VER=x.y.z)\n\n" unless ver = ENV['VER']
|
300
|
+
Dir['lib/**/*.r?'].each do |fn|
|
301
|
+
File.open(fn) do |f|
|
302
|
+
[*f].each_with_index do |line,i|
|
303
|
+
if line =~ /v-#{ver}/
|
304
|
+
if line =~ /#(.*)vv([0-9\.]+)(?:[\s\t]*)v-([0-9\.]+)/
|
305
|
+
cmnt = $~[1].strip
|
306
|
+
cmnt = '<No comment>' if (cmnt.nil? or cmnt.empty?)
|
307
|
+
printf "%s:%d\n%-60s %5s %5s\n\n", fn, i+1, cmnt, $~[2].strip, $~[3].strip
|
308
|
+
end #if splits okay
|
309
|
+
end #if line is dep remove
|
310
|
+
end #each_w_idx
|
311
|
+
end #fopen
|
312
|
+
end #dir
|
313
|
+
end
|
314
|
+
|
315
|
+
# --------------------------------------------------------------------
|
316
|
+
# Creating a release
|
317
|
+
|
318
|
+
desc "Make a new release"
|
319
|
+
task :release => [
|
320
|
+
:prerelease,
|
321
|
+
:clobber,
|
322
|
+
:alltests,
|
323
|
+
:update_version,
|
324
|
+
:package,
|
325
|
+
:tag,
|
326
|
+
:doc_upload] do
|
327
|
+
|
328
|
+
announce
|
329
|
+
announce "**************************************************************"
|
330
|
+
announce "* Release #{PKG_VERSION} Complete."
|
331
|
+
announce "* Packages ready to upload."
|
332
|
+
announce "**************************************************************"
|
333
|
+
announce
|
334
|
+
end
|
335
|
+
|
336
|
+
# Validate that everything is ready to go for a release.
|
337
|
+
task :prerelease do
|
338
|
+
announce
|
339
|
+
announce "**************************************************************"
|
340
|
+
announce "* Making RubyGem Release #{PKG_VERSION}"
|
341
|
+
announce "* (current version #{CURRENT_VERSION})"
|
342
|
+
announce "**************************************************************"
|
343
|
+
announce
|
344
|
+
|
345
|
+
# Is a release number supplied?
|
346
|
+
unless ENV['REL']
|
347
|
+
fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
|
348
|
+
end
|
349
|
+
|
350
|
+
# Is the release different than the current release.
|
351
|
+
# (or is REUSE set?)
|
352
|
+
if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
|
353
|
+
fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
|
354
|
+
end
|
355
|
+
|
356
|
+
# Are all source files checked in?
|
357
|
+
if ENV['RELTEST']
|
358
|
+
announce "Release Task Testing, skipping checked-in file test"
|
359
|
+
else
|
360
|
+
announce "Checking for unchecked-in files..."
|
361
|
+
data = `svn status`
|
362
|
+
unless data =~ /^$/
|
363
|
+
fail "SVN status is not clean ... do you have unchecked-in files?"
|
364
|
+
end
|
365
|
+
announce "No outstanding checkins found ... OK"
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
task :update_version => [:prerelease] do
|
370
|
+
if PKG_VERSION == CURRENT_VERSION
|
371
|
+
announce "No version change ... skipping version update"
|
372
|
+
else
|
373
|
+
announce "Updating DigestR version to #{PKG_VERSION}"
|
374
|
+
open("lib/xml/digestr.rb") do |rakein|
|
375
|
+
open("lib/xml/digestr.rb.new", "w") do |rakeout|
|
376
|
+
rakein.each do |line|
|
377
|
+
if line =~ /^VERSION\s*=\s*/
|
378
|
+
rakeout.puts "VERSION = '#{PKG_VERSION}'"
|
379
|
+
else
|
380
|
+
rakeout.puts line
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
mv "lib/xml/digestr.rb.new", "lib/xml/digestr.rb"
|
386
|
+
if ENV['RELTEST']
|
387
|
+
announce "Release Task Testing, skipping commiting of new version"
|
388
|
+
else
|
389
|
+
sh %{svn commit -m "Updated to version #{PKG_VERSION}" lib/xml/digestr.rb}
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
desc "Create a new SVN tag with the latest release number (REL=x.y.z)"
|
395
|
+
task :tag => [:prerelease] do
|
396
|
+
reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
|
397
|
+
reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
|
398
|
+
announce "Tagging CVS with [#{reltag}]"
|
399
|
+
if ENV['RELTEST']
|
400
|
+
announce "Release Task Testing, skipping SVN tagging"
|
401
|
+
else
|
402
|
+
# need to get current base URL
|
403
|
+
s = `svn info`
|
404
|
+
if s =~ /URL:\s*([^\n]*)\n/
|
405
|
+
svnroot = $1
|
406
|
+
if svnroot =~ /^(.*)\/trunk/
|
407
|
+
svnbase = $1
|
408
|
+
sh %{svn cp #{svnroot} #{svnbase}/tags/#{reltag} -m "Release #{PKG_VERSION}"}
|
409
|
+
else
|
410
|
+
fail "Please merge to trunk before making a release"
|
411
|
+
end
|
412
|
+
else
|
413
|
+
fail "Unable to determine repository URL from 'svn info' - is this a working copy?"
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
# Require experimental XForge/Metaproject support.
|
419
|
+
# load 'xforge.rf' if File.exist?('xforge.rf')
|
420
|
+
|