core_ex 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/SPEC.dyn.yml +4 -3
- data/SPEC.yml +1 -1
- data/lib/core_ex/rakefile_base.rf +500 -0
- metadata +2 -1
data/SPEC.dyn.yml
CHANGED
data/SPEC.yml
CHANGED
@@ -0,0 +1,500 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: rakefile_base.rf 262 2005-06-01 02:58:29Z ertai $
|
5
|
+
|
6
|
+
require 'core_ex'
|
7
|
+
require 'ostruct'
|
8
|
+
require 'date'
|
9
|
+
require 'rbconfig'
|
10
|
+
require 'rake/testtask'
|
11
|
+
require 'rake/packagetask'
|
12
|
+
require 'rake/rdoctask'
|
13
|
+
require 'rake/gempackagetask'
|
14
|
+
require 'rake/contrib/rubyforgepublisher'
|
15
|
+
require 'rubygems'
|
16
|
+
require_gem 'highline'
|
17
|
+
require 'highline/import'
|
18
|
+
|
19
|
+
|
20
|
+
AUTHORS = Pathname.new('AUTHORS')
|
21
|
+
SPEC_YML = Pathname.new('SPEC.yml')
|
22
|
+
SPEC_DYN_YML = Pathname.new('SPEC.dyn.yml')
|
23
|
+
GEM_SPEC = Pathname.new("SPEC.gem.yml")
|
24
|
+
RakefileBase = __FILE__
|
25
|
+
EDITOR = ENV['EDITOR'] || 'vi'
|
26
|
+
|
27
|
+
#
|
28
|
+
# Some little extensions.
|
29
|
+
#
|
30
|
+
|
31
|
+
def edit ( aPathname )
|
32
|
+
sh EDITOR, aPathname.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
class MiniSvn
|
36
|
+
def method_missing ( meth, *args )
|
37
|
+
sh 'svn', meth.to_s, *args
|
38
|
+
end
|
39
|
+
end
|
40
|
+
svn = MiniSvn.new
|
41
|
+
|
42
|
+
|
43
|
+
def clean_task ( arg, &block )
|
44
|
+
if arg.is_a? Hash
|
45
|
+
name = :"clobber_#{arg.keys.first}"
|
46
|
+
task(name => arg.values.first, &block)
|
47
|
+
else
|
48
|
+
name = :"clobber_#{arg}"
|
49
|
+
task(name, &block)
|
50
|
+
end
|
51
|
+
task :clobber => name
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
class Task
|
56
|
+
alias enhance_old enhance
|
57
|
+
def enhance(deps=nil, &block)
|
58
|
+
deps.each { |dep| @prerequisites << dep } if deps
|
59
|
+
@actions << block if block_given?
|
60
|
+
self
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
#
|
66
|
+
# Rake tasks
|
67
|
+
#
|
68
|
+
|
69
|
+
|
70
|
+
desc 'Default Task (check)'
|
71
|
+
task :default => [ :check ]
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
# desc 'Setup the ttk command'
|
76
|
+
task :ttk do
|
77
|
+
# FIXME search a valid ttk
|
78
|
+
def ttk ( *a )
|
79
|
+
sh 'ttk', *a
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
desc 'Launch all test suites'
|
86
|
+
task :check => [ :ttk, :spec, :dyn_spec ] do
|
87
|
+
ttk '-l', 'check-log.yml', '-S', 'url: file://<<pwd>>', '-C',
|
88
|
+
SPEC.root_test_suite
|
89
|
+
end
|
90
|
+
clean_task :check do
|
91
|
+
'check-log.yml'.to_path.rm_f
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
desc 'Check generated packages'
|
97
|
+
task :distcheck => [ :ttk, :package ] do
|
98
|
+
urls = []
|
99
|
+
Pathname.glob('pkg/*') do |path|
|
100
|
+
next unless path.file?
|
101
|
+
next if path.to_s =~ /\.gem$/ # FIXME
|
102
|
+
urls << "file://#{path.expand_path}"
|
103
|
+
end
|
104
|
+
inp = { # FIXME use a Each strategy
|
105
|
+
'Check generated packages' => {
|
106
|
+
'strategy' => 'Suite',
|
107
|
+
'attributes' => {
|
108
|
+
'strategy' => 'Import',
|
109
|
+
'import' => SPEC.root_test_suite
|
110
|
+
},
|
111
|
+
'contents' => urls.map { |url| { url => { 'symbols' => {'url'=>url} } } }
|
112
|
+
}
|
113
|
+
}
|
114
|
+
TempPath.new do |tmp|
|
115
|
+
tmp.open('w') { |f| f.write inp.to_yaml }
|
116
|
+
ttk '-l', 'distcheck-log.yml', tmp
|
117
|
+
end
|
118
|
+
end
|
119
|
+
clean_task :distcheck do
|
120
|
+
'distcheck-log.yml'.to_path.rm_f
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
# desc "Load the #{SPEC_YML} file"
|
126
|
+
task :spec => [ SPEC_YML.to_s ] do
|
127
|
+
Kernel.const_set(:SPEC, OpenStruct.new(YAML.load(SPEC_YML.read)))
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
def update_dyn_spec
|
133
|
+
svn_info = YAML::load(`svn info`)
|
134
|
+
revision = svn_info['Revision']
|
135
|
+
if SPEC_DYN_YML.exist?
|
136
|
+
SPEC.dyn = YAML::load(SPEC_DYN_YML.read)
|
137
|
+
SPEC.dyn.version.revision = revision
|
138
|
+
else
|
139
|
+
SPEC.dyn = OpenStruct.new('version' => Version.new(0, 0, 0, revision))
|
140
|
+
end
|
141
|
+
SPEC.dyn.date = /\((.*)\)/.match(svn_info['Last Changed Date'])[1]
|
142
|
+
SPEC_DYN_YML.open('w') do |out|
|
143
|
+
out.puts(SPEC.dyn.to_yaml)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
# desc "Update the #{SPEC_DYN_YML} file"
|
150
|
+
file SPEC_DYN_YML.to_s => [ :spec ] do
|
151
|
+
update_dyn_spec
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
task :update_dyn_spec => [ SPEC_DYN_YML.to_s ] do
|
157
|
+
update_dyn_spec
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
task :dyn_spec => [ SPEC_DYN_YML.to_s ] do
|
163
|
+
SPEC.dyn = YAML::load(SPEC_DYN_YML.read)
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
desc 'Generate the full documentation'
|
169
|
+
task :doc => [ :rdoc_spec, :rdoc_real ]
|
170
|
+
clean_task :doc => [ :rdoc_spec, :clobber_rdoc_real ]
|
171
|
+
task :redoc => [ :clobber_doc, :doc ]
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
desc 'Generate all packages'
|
176
|
+
task :package => [ :gem_spec, :gem ]
|
177
|
+
clean_task :package => [ :gem_spec ]
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
desc 'Re-generate all packages'
|
182
|
+
task :repackage => [ :gem_spec ]
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
desc 'Generate a GEM package'
|
187
|
+
task :gem => [ :gem_spec ]
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
desc 'Re-generate a GEM package'
|
192
|
+
task :regem => [ :clobber_gem, :gem ]
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
task :rdoc_spec => [ :spec ] do
|
197
|
+
SPEC.rdoc = Rake::RDocTask.new(:rdoc_real) do |rdoc|
|
198
|
+
rdoc.title = SPEC.title
|
199
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
200
|
+
rdoc.rdoc_dir = SPEC.rdoc_dir
|
201
|
+
rdoc.options << '--inline-source'
|
202
|
+
rdoc.main = SPEC.rdoc_files.first
|
203
|
+
tail = SPEC.rdoc_tail_files || []
|
204
|
+
fl = SPEC.rdoc_files - tail + tail
|
205
|
+
rdoc.rdoc_files.include(fl)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
# desc 'Update the Gem specification'
|
212
|
+
file GEM_SPEC.to_s => [ :spec, :dyn_spec, :rdoc_spec ] do
|
213
|
+
spec = Gem::Specification.new do |s|
|
214
|
+
s.platform = Gem::Platform::RUBY
|
215
|
+
s.name = SPEC.name
|
216
|
+
s.version = SPEC.dyn.version.to_s
|
217
|
+
s.summary = SPEC.summary
|
218
|
+
s.description = SPEC.description
|
219
|
+
bin = 'bin'.to_path
|
220
|
+
s.bindir = bin.to_s
|
221
|
+
s.executables = Pathname.glob(bin + '*').select do |path|
|
222
|
+
path.executable? and not path.directory?
|
223
|
+
end.map { |path| path.basename.to_s }
|
224
|
+
s.files = SPEC.pkg_files.to_a
|
225
|
+
s.require_path = 'lib'
|
226
|
+
|
227
|
+
if SPEC.dependencies
|
228
|
+
SPEC.dependencies.each do |name, version|
|
229
|
+
s.add_dependency(name, version)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
s.has_rdoc = true
|
234
|
+
s.extra_rdoc_files = SPEC.rdoc.rdoc_files
|
235
|
+
s.rdoc_options = SPEC.rdoc.option_list.map { |x| x.sub(/^'?(.*?)'?$/, '\1') }
|
236
|
+
|
237
|
+
authors_file = YAML::load(AUTHORS.read).values.first
|
238
|
+
list = authors_file.map { |x| /^(.*?)\s*<(.*)>/.match(x.keys.first)[1..2] }
|
239
|
+
s.authors = list.map { |x| x.first }
|
240
|
+
s.email = list.map { |x| x.last }
|
241
|
+
s.homepage = SPEC.homepage
|
242
|
+
s.rubyforge_project = s.name
|
243
|
+
end
|
244
|
+
GEM_SPEC.open('w') { |out| out.puts spec.to_yaml }
|
245
|
+
end
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
# desc "Remove the #{GEM_SPEC} file"
|
250
|
+
clean_task :gem_spec do
|
251
|
+
GEM_SPEC.rm_f
|
252
|
+
end
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
# desc 'Load the GEM spec and create tasks for packages'
|
257
|
+
task :gem_spec => [ GEM_SPEC.to_s ] do
|
258
|
+
spec = YAML::load(GEM_SPEC.read)
|
259
|
+
|
260
|
+
gtask = Rake::GemPackageTask.new(spec) do |p|
|
261
|
+
p.gem_spec = spec
|
262
|
+
p.need_tar_gz = true
|
263
|
+
p.need_tar_bz2 = true
|
264
|
+
p.package_files = SPEC.pkg_files.to_a
|
265
|
+
end
|
266
|
+
gtask.instance_eval { $gem = 'pkg'.to_path + gem_file }
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
# desc 'Remove the GEM package file'
|
272
|
+
clean_task :gem => [ :gem_spec ] do
|
273
|
+
$gem.rm_f
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
# desc 'Make an Svn tag'
|
279
|
+
task :tag => [ :spec, :dyn_spec ] do
|
280
|
+
tag_name = (SPEC.release)? SPEC.release : "#{SPEC.name}-#{SPEC.dyn.version}"
|
281
|
+
tags = (SPEC.tags_dir || '../tags').to_path.expand_path.cleanpath
|
282
|
+
if agree "Make the SVN tag (#{tags/tag_name}) (y/n)", true
|
283
|
+
svn.copy(Pathname.pwd, tags/tag_name)
|
284
|
+
svn.commit(Pathname.pwd, tags, '-m', "'Releasing #{tag_name}'")
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
desc 'Publish to RubyForge'
|
291
|
+
task :publish_doc => [ :spec ] do
|
292
|
+
user = SPEC.user || ENV['USER']
|
293
|
+
Rake::SshDirPublisher.new(
|
294
|
+
# "#{user}@rubyforge.org",
|
295
|
+
# "/var/www/gforge-projects/#{SPEC.name}/test",
|
296
|
+
"#{user}@ssh.feydakins.org",
|
297
|
+
"/var/www/api.feydakins.org/public/#{SPEC.name}/",
|
298
|
+
SPEC.rdoc_dir
|
299
|
+
).upload
|
300
|
+
end
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
# desc 'Common tasks for a release'
|
305
|
+
task :common_release =>
|
306
|
+
[
|
307
|
+
:release_confirm,
|
308
|
+
:check,
|
309
|
+
:doc,
|
310
|
+
:package,
|
311
|
+
:distcheck,
|
312
|
+
:tag,
|
313
|
+
:publish_doc,
|
314
|
+
:publish_package
|
315
|
+
]
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
task :release_confirm => [ :spec, :dyn_spec ] do
|
320
|
+
SPEC.release = SPEC.name + '-' + SPEC.dyn.version.to_s
|
321
|
+
SPEC.release += '-' + SPEC.dyn.version_id unless SPEC.dyn.version_id.empty?
|
322
|
+
say "Release that: #{SPEC.release}."
|
323
|
+
exit unless agree 'Are you sure? (y/n)', true
|
324
|
+
end
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
[:major, :minor, :build].each do |release_mode|
|
329
|
+
name = :"#{release_mode}_release"
|
330
|
+
desc "Make a new #{release_mode} release"
|
331
|
+
task name => [ :update_dyn_spec ] do
|
332
|
+
SPEC.dyn.version.send(name)
|
333
|
+
q = 'Specify an identifier for this version (or press return): '
|
334
|
+
SPEC.dyn.version_id = ask(q)
|
335
|
+
SPEC_DYN_YML.open('w') do |out|
|
336
|
+
out.puts(SPEC.dyn.to_yaml)
|
337
|
+
end
|
338
|
+
begin
|
339
|
+
sh 'rake', 'clobber'
|
340
|
+
sh 'rake', 'common_release'
|
341
|
+
rescue
|
342
|
+
SPEC_DYN_YML.unlink
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
desc "Publish the release files to RubyForge."
|
350
|
+
task :publish_package => [ :spec, :package ] do
|
351
|
+
type_map = {
|
352
|
+
'.deb' => 1000,
|
353
|
+
'.rpm' => 2000,
|
354
|
+
'.zip' => 3000,
|
355
|
+
'.bz2' => 3100,
|
356
|
+
'.tbz2' => 3100,
|
357
|
+
'.gz' => 3110,
|
358
|
+
'.tgz' => 3110,
|
359
|
+
'.jpg' => 8000,
|
360
|
+
'.text' => 8100,
|
361
|
+
'.html' => 8200,
|
362
|
+
'.pdf' => 8300,
|
363
|
+
'.ebuild' => 1300,
|
364
|
+
'.exe' => 1100,
|
365
|
+
'.dmg' => 1200,
|
366
|
+
'.gem' => 1400,
|
367
|
+
'.sig' => 8150,
|
368
|
+
# 'Source .zip' => 5000,
|
369
|
+
# 'Source .bz2' => 5010,
|
370
|
+
# 'Source .gz' => 5020,
|
371
|
+
# 'Source .rpm' => 5100,
|
372
|
+
# 'Other Source File' => 5900,
|
373
|
+
}
|
374
|
+
type_map.default = 9999
|
375
|
+
|
376
|
+
pkg = 'pkg'.to_path
|
377
|
+
files = FileList[pkg/"*{#{type_map.keys.join(',')}}"]
|
378
|
+
|
379
|
+
rubyforge_user = SPEC.rubyforge_user || SPEC.user || ENV['USER']
|
380
|
+
rubyforge_project = SPEC.rubyforge_project || SPEC.name
|
381
|
+
default = (SPEC.release)? SPEC.release : "#{SPEC.name}-#{SPEC.dyn.version}"
|
382
|
+
release_name = ask("Release name: ") { |q| q.default = default }
|
383
|
+
|
384
|
+
require 'net/http'
|
385
|
+
require 'open-uri'
|
386
|
+
|
387
|
+
project_uri = "http://rubyforge.org/projects/#{rubyforge_project}/"
|
388
|
+
project_data = open(project_uri) { |data| data.read }
|
389
|
+
group_id = project_data[/[?&]group_id=(\d+)/, 1]
|
390
|
+
raise "Couldn't get group id" unless group_id
|
391
|
+
|
392
|
+
if ENV['RUBY_FORGE_PASSWORD']
|
393
|
+
password = ENV['RUBY_FORGE_PASSWORD']
|
394
|
+
else
|
395
|
+
password = ask("#{rubyforge_user}@rubyforge.org's password: ") do |q|
|
396
|
+
q.echo = false
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
login_response = Net::HTTP.start('rubyforge.org', 80) do |http|
|
401
|
+
data = [
|
402
|
+
'login=1',
|
403
|
+
"form_loginname=#{rubyforge_user}",
|
404
|
+
"form_pw=#{password}"
|
405
|
+
].join('&')
|
406
|
+
http.post('/account/login.php', data)
|
407
|
+
end
|
408
|
+
|
409
|
+
cookie = login_response['set-cookie']
|
410
|
+
raise 'Login failed' unless cookie
|
411
|
+
headers = { 'Cookie' => cookie }
|
412
|
+
|
413
|
+
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
414
|
+
release_data = open(release_uri, headers) { |data| data.read }
|
415
|
+
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
416
|
+
raise "Couldn't get package id" unless package_id
|
417
|
+
|
418
|
+
first_file = true
|
419
|
+
release_id = ''
|
420
|
+
|
421
|
+
files.each do |path|
|
422
|
+
path = path.to_path # FIXME
|
423
|
+
basename = path.basename
|
424
|
+
file_ext = path.extname
|
425
|
+
file_data = path.read
|
426
|
+
|
427
|
+
say "Releasing #{basename}..."
|
428
|
+
next unless agree 'Agree? (y/n)', true
|
429
|
+
|
430
|
+
release_response = Net::HTTP.start('rubyforge.org', 80) do |http|
|
431
|
+
release_date = Time.now.strftime('%Y-%m-%d %H:%M')
|
432
|
+
type = type_map[file_ext].to_s
|
433
|
+
boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
434
|
+
|
435
|
+
if first_file then
|
436
|
+
release = {
|
437
|
+
:notes => ',release_notes'.to_path,
|
438
|
+
:changes => ',release_changes'.to_path
|
439
|
+
}
|
440
|
+
[:notes, :changes].each do |x|
|
441
|
+
while not release[x].exist?
|
442
|
+
say "No release #{x} (editing...)"
|
443
|
+
edit release[x]
|
444
|
+
say "Publish these release #{x}:"
|
445
|
+
say release[x].read
|
446
|
+
exit unless agree 'Agree? (y/n) ', true
|
447
|
+
end
|
448
|
+
end
|
449
|
+
query_hash = {
|
450
|
+
'group_id' => group_id,
|
451
|
+
'package_id' => package_id,
|
452
|
+
'release_name' => release_name,
|
453
|
+
'release_date' => release_date,
|
454
|
+
'type_id' => type,
|
455
|
+
'processor_id' => '8000', # Any
|
456
|
+
'release_notes' => release[:notes].read,
|
457
|
+
'release_changes' => release[:changes].read,
|
458
|
+
'preformatted' => '1',
|
459
|
+
'submit' => '1'
|
460
|
+
}
|
461
|
+
else
|
462
|
+
query_hash = {
|
463
|
+
'group_id' => group_id,
|
464
|
+
'release_id' => release_id,
|
465
|
+
'package_id' => package_id,
|
466
|
+
'step2' => '1',
|
467
|
+
'type_id' => type,
|
468
|
+
'processor_id' => '8000', # Any
|
469
|
+
'submit' => 'Add This File'
|
470
|
+
}
|
471
|
+
end
|
472
|
+
|
473
|
+
query = "?" + query_hash.map do |name, value|
|
474
|
+
[name, URI.encode(value)].join("=")
|
475
|
+
end.join("&")
|
476
|
+
|
477
|
+
data = [
|
478
|
+
'--' + boundary,
|
479
|
+
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
480
|
+
'Content-Type: application/octet-stream',
|
481
|
+
'Content-Transfer-Encoding: binary',
|
482
|
+
'', file_data, ''
|
483
|
+
].join("\x0D\x0A")
|
484
|
+
|
485
|
+
release_headers = headers.merge(
|
486
|
+
'Content-Type' => "multipart/form-data; boundary=#{boundary}"
|
487
|
+
)
|
488
|
+
|
489
|
+
target = first_file ? '/frs/admin/qrs.php' : '/frs/admin/editrelease.php'
|
490
|
+
http.post(target + query, data, release_headers)
|
491
|
+
end
|
492
|
+
|
493
|
+
if first_file then
|
494
|
+
release_id = release_response.body[/release_id=(\d+)/, 1]
|
495
|
+
raise("Couldn't get release id") unless release_id
|
496
|
+
end
|
497
|
+
|
498
|
+
first_file = false
|
499
|
+
end
|
500
|
+
end
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: core_ex
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
6
|
+
version: 0.1.1
|
7
7
|
date: 2005-06-01
|
8
8
|
summary: CoreEx is a proposal for a standard library extension.
|
9
9
|
require_paths:
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/core_ex/filelist.rb
|
45
45
|
- lib/core_ex/fileutils.rb
|
46
46
|
- lib/core_ex/pathname.rb
|
47
|
+
- lib/core_ex/rakefile_base.rf
|
47
48
|
- lib/core_ex/require.rb
|
48
49
|
- lib/core_ex/string.rb
|
49
50
|
- lib/core_ex/temp_path.rb
|