reap 9.3.5 → 9.4.0
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/CHANGES +10 -0
- data/MANIFEST +37 -21
- data/NOTES +13 -11
- data/bin/reap-announce +40 -2
- data/bin/reap-check-load +20 -2
- data/bin/reap-check-syntax +20 -2
- data/bin/reap-clean +24 -2
- data/bin/reap-clobber +17 -2
- data/bin/reap-doc +12 -2
- data/bin/reap-doc-rdoc +17 -2
- data/bin/reap-doc-ri +16 -2
- data/bin/reap-doc-spec +18 -0
- data/bin/reap-init +9 -0
- data/bin/reap-inspect +20 -2
- data/bin/reap-install +13 -2
- data/bin/reap-install-gem +14 -2
- data/bin/reap-log +15 -2
- data/bin/reap-log-changes +15 -2
- data/bin/reap-log-notes +20 -2
- data/bin/reap-make +16 -2
- data/bin/reap-make-clean +10 -2
- data/bin/reap-make-distclean +18 -2
- data/bin/reap-make-extconf +14 -2
- data/bin/reap-make-static +14 -2
- data/bin/reap-package +25 -2
- data/bin/reap-package-gem +14 -2
- data/bin/reap-package-tgz +14 -2
- data/bin/reap-package-zip +14 -2
- data/bin/reap-prepare +21 -2
- data/bin/reap-publish +25 -2
- data/bin/reap-release +22 -2
- data/bin/reap-rollout +32 -2
- data/bin/reap-scaffold +16 -2
- data/bin/reap-scm-branch +13 -2
- data/bin/reap-scm-tag +13 -2
- data/bin/reap-spec +14 -2
- data/bin/reap-stats +21 -2
- data/bin/reap-test +14 -2
- data/bin/reap-test-cross +23 -2
- data/bin/reap-test-load +17 -2
- data/bin/reap-test-solo +19 -2
- data/bin/reap-uninstall +14 -2
- data/bin/reap-uninstall-gem +17 -2
- data/bin/reap-version +10 -2
- data/lib/reap/announcement.rb +136 -0
- data/lib/reap/application.rb +3 -1
- data/lib/reap/default.yaml +12 -12
- data/lib/reap/defaults.rb +49 -0
- data/lib/reap/emailer.rb +189 -0
- data/lib/reap/extensions.rb +1 -2
- data/lib/reap/hosts.rb +4 -0
- data/lib/reap/hosts/host.rb +69 -0
- data/lib/reap/hosts/mailinglist.rb +83 -0
- data/lib/reap/{systems → hosts}/rubyforge.rb +72 -60
- data/lib/reap/hosts/rubytalk.rb +39 -0
- data/lib/reap/iobject.rb +5 -3
- data/lib/reap/metadata.rb +31 -4
- data/lib/reap/project.rb +101 -41
- data/lib/reap/project/announce.rb +50 -180
- data/lib/reap/project/check.rb +1 -1
- data/lib/reap/project/gem.rb +32 -68
- data/lib/reap/project/log.rb +12 -7
- data/lib/reap/project/make.rb +0 -1
- data/lib/reap/project/package.rb +228 -75
- data/lib/reap/project/rdoc.rb +9 -8
- data/lib/reap/project/release.rb +52 -6
- data/lib/reap/project/scm.rb +40 -25
- data/lib/reap/project/spec.rb +3 -3
- data/lib/reap/project/test.rb +1 -2
- data/lib/reap/project/version.rb +18 -4
- data/lib/reap/runmodes.rb +24 -0
- data/lib/reap/settings.rb +3 -14
- data/lib/reap/systems.rb +4 -0
- data/lib/reap/systems/git.rb +0 -0
- data/lib/reap/systems/hg.rb +0 -0
- data/lib/reap/systems/{subversion.rb → svn.rb} +47 -16
- data/lib/reap/systems/system.rb +53 -0
- data/lib/reap/tool.rb +38 -0
- data/lib/reap/utilities.rb +43 -86
- data/log/{Changelog.txt → changelog.rdoc} +56 -0
- data/log/fixme.rdoc +25 -0
- data/log/todo.rdoc +85 -0
- data/meta/project.yaml +13 -2
- data/meta/version +1 -0
- data/setup.rb +74 -64
- data/task/allshare.rb +109 -0
- data/task/clean +13 -0
- data/task/compile +28 -0
- data/task/configure +372 -0
- data/task/install +1481 -0
- data/test/case/test_init.rb +32 -0
- data/test/case/test_scaffold.rb +32 -0
- data/test/data/scaffold/meta/project.yaml +28 -0
- data/test/lib/case_testable.rb +23 -0
- metadata +64 -31
- data/bin/reap-spec-doc +0 -8
- data/demo/README +0 -15
- data/demo/lib/foo/foo.rb +0 -7
- data/demo/meta/VERSION +0 -1
- data/demo/meta/project.yaml +0 -21
- data/lib/reap/project/rubyforge.rb +0 -71
- data/lib/reap/project/svn.rb +0 -76
- data/log/Fixme.txt +0 -22
- data/log/Todo.txt +0 -84
- data/meta/VERSION +0 -1
data/meta/version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
9.4.0 beta (2008-04-02)
|
data/setup.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
|
2
3
|
# Setup.rb v3.5.0
|
3
4
|
# Copyright (c) 2008 Minero Aoki, Trans
|
4
5
|
#
|
@@ -6,9 +7,11 @@
|
|
6
7
|
# You can distribute/modify this program under the terms of
|
7
8
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
8
9
|
|
9
|
-
# Need the package name
|
10
|
-
|
11
|
-
|
10
|
+
# Need the package name. This is used to install docs in system doc/ruby-{name}/ location.
|
11
|
+
PACKAGE_NAME = File.read(Dir.glob('{.,meta/}unixname{,.txt}', File::FNM_CASEFOLD).first).strip
|
12
|
+
|
13
|
+
# Generate rdocs? Package developer may want to deactivate this.
|
14
|
+
GENERATE_RDOC = true
|
12
15
|
|
13
16
|
require 'optparse'
|
14
17
|
require 'rbconfig'
|
@@ -19,6 +22,9 @@ class SetupError < StandardError; end
|
|
19
22
|
#
|
20
23
|
# $ ./setup.rb
|
21
24
|
#
|
25
|
+
# Which is the same al
|
26
|
+
#
|
27
|
+
#
|
22
28
|
# -- or --
|
23
29
|
#
|
24
30
|
# $ ./setup.rb config
|
@@ -33,7 +39,8 @@ class SetupError < StandardError; end
|
|
33
39
|
# TODO: Make cleaning more comprehensive (?)
|
34
40
|
|
35
41
|
module Setup
|
36
|
-
|
42
|
+
|
43
|
+
Version = "3.5.1"
|
37
44
|
|
38
45
|
Copyright = "Copyright (c) 2000,2008 Minero Aoki, Trans"
|
39
46
|
|
@@ -252,6 +259,7 @@ module Setup
|
|
252
259
|
|
253
260
|
parameterize = lambda do |path|
|
254
261
|
val = RBCONFIG[path]
|
262
|
+
raise "Unknown path -- #{path}" if val.nil?
|
255
263
|
val.sub(/\A#{Regexp.quote(prefix)}/, '$prefix')
|
256
264
|
end
|
257
265
|
|
@@ -321,8 +329,15 @@ module Setup
|
|
321
329
|
OPTIONS.each do |name|
|
322
330
|
value = self[name]
|
323
331
|
reslv = __send__(name)
|
324
|
-
|
325
|
-
|
332
|
+
case reslv
|
333
|
+
when String
|
334
|
+
reslv = "(none)" if reslv.empty?
|
335
|
+
when false, nil
|
336
|
+
reslv = "no"
|
337
|
+
when true
|
338
|
+
reslv = "yes"
|
339
|
+
end
|
340
|
+
printf fmt, name, reslv
|
326
341
|
end
|
327
342
|
end
|
328
343
|
|
@@ -373,15 +388,15 @@ module Setup
|
|
373
388
|
[ 'config', 'saves your configurations' ],
|
374
389
|
[ 'show', 'shows current configuration' ],
|
375
390
|
[ 'setup', 'compiles ruby extentions and others' ],
|
376
|
-
[ '
|
377
|
-
[ '
|
391
|
+
[ 'rdoc', 'generate rdoc documentation' ],
|
392
|
+
[ 'ri', 'generate ri documentation' ],
|
378
393
|
[ 'install', 'installs files' ],
|
379
394
|
[ 'test', 'run all tests in test/' ],
|
380
395
|
[ 'clean', "does `make clean' for each extention" ],
|
381
396
|
[ 'distclean',"does `make distclean' for each extention" ]
|
382
397
|
]
|
383
398
|
|
384
|
-
TASKS = %w(all config show setup test install uninstall
|
399
|
+
TASKS = %w(all config show setup test install uninstall rdoc ri clean distclean)
|
385
400
|
|
386
401
|
# Configuration
|
387
402
|
attr :config
|
@@ -447,11 +462,11 @@ module Setup
|
|
447
462
|
desc 'Runs unit tests'
|
448
463
|
task :test do exec_test end
|
449
464
|
|
450
|
-
desc 'Generate
|
451
|
-
task :
|
465
|
+
desc 'Generate rdoc documentation'
|
466
|
+
task :rdoc do exec_rdoc end
|
452
467
|
|
453
|
-
desc 'Generate
|
454
|
-
task :
|
468
|
+
desc 'Generate ri documentation'
|
469
|
+
task :ri do exec_ri end
|
455
470
|
|
456
471
|
desc 'Installs files'
|
457
472
|
task :install do exec_install end
|
@@ -509,8 +524,9 @@ module Setup
|
|
509
524
|
def exec_all
|
510
525
|
exec_config
|
511
526
|
exec_setup
|
512
|
-
exec_test
|
513
|
-
|
527
|
+
exec_test # TODO: we need to stop here if tests fail (how?)
|
528
|
+
exec_rdoc unless config.without_doc? if GENERATE_RDOC
|
529
|
+
exec_ri unless config.without_doc?
|
514
530
|
exec_install
|
515
531
|
end
|
516
532
|
|
@@ -706,12 +722,12 @@ module Setup
|
|
706
722
|
#end
|
707
723
|
|
708
724
|
#
|
709
|
-
# TASK
|
725
|
+
# TASK rdoc
|
710
726
|
#
|
711
727
|
|
712
|
-
def
|
713
|
-
output = File.join('doc',
|
714
|
-
title = (
|
728
|
+
def exec_rdoc
|
729
|
+
output = File.join('doc', 'rdoc')
|
730
|
+
title = (PACKAGE_NAME.capitalize + " API").strip
|
715
731
|
main = Dir.glob("README{,.txt}", File::FNM_CASEFOLD).first
|
716
732
|
template = config.doctemplate || 'html'
|
717
733
|
|
@@ -744,57 +760,49 @@ module Setup
|
|
744
760
|
end
|
745
761
|
end
|
746
762
|
|
747
|
-
#
|
748
|
-
# TASK index
|
749
|
-
#
|
750
|
-
# TODO: Totally deprecate stadard ri support in favor of fastri.
|
763
|
+
# TASK ri
|
751
764
|
|
752
|
-
def
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
765
|
+
def exec_ri
|
766
|
+
case config.installdirs
|
767
|
+
when 'std'
|
768
|
+
output = "--ri-system"
|
769
|
+
when 'site'
|
770
|
+
output = "--ri-site"
|
771
|
+
when 'home'
|
772
|
+
output = "--ri"
|
773
|
+
else
|
774
|
+
abort "bad config: sould not be possible -- installdirs = #{config.installdirs}"
|
758
775
|
end
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
end
|
776
|
+
|
777
|
+
if File.exist?('.document')
|
778
|
+
files = File.read('.document').split("\n")
|
779
|
+
files.reject!{ |l| l =~ /^\s*[#]/ || l !~ /\S/ }
|
780
|
+
files.collect!{ |f| f.strip }
|
765
781
|
else
|
766
|
-
|
767
|
-
|
768
|
-
output = "--ri-system"
|
769
|
-
when 'site'
|
770
|
-
output = "--ri-site"
|
771
|
-
when 'home'
|
772
|
-
output = "--ri"
|
773
|
-
else
|
774
|
-
abort "bad config: sould not be possible -- installdirs = #{config.installdirs}"
|
775
|
-
end
|
782
|
+
files = ["lib", "ext"]
|
783
|
+
end
|
776
784
|
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
files = ["lib", "ext"]
|
783
|
-
end
|
785
|
+
opt = []
|
786
|
+
opt << "-U"
|
787
|
+
opt << output
|
788
|
+
opt << files
|
789
|
+
opt = opt.flatten
|
784
790
|
|
791
|
+
if no_harm?
|
792
|
+
puts "rdoc #{opt.join(' ').strip}"
|
793
|
+
else
|
794
|
+
# Generate in system location specified
|
795
|
+
#sh "rdoc #{opt.join(' ').strip}"
|
796
|
+
require 'rdoc/rdoc'
|
797
|
+
::RDoc::RDoc.new.document(opt)
|
798
|
+
|
799
|
+
# Now in local directory
|
785
800
|
opt = []
|
786
801
|
opt << "-U"
|
787
|
-
opt <<
|
802
|
+
opt << "--ri --op 'doc/ri'"
|
788
803
|
opt << files
|
789
804
|
opt = opt.flatten
|
790
|
-
|
791
|
-
if no_harm?
|
792
|
-
puts "rdoc #{opt.join(' ').strip}"
|
793
|
-
else
|
794
|
-
#sh "rdoc #{opt.join(' ').strip}"
|
795
|
-
require 'rdoc/rdoc'
|
796
|
-
::RDoc::RDoc.new.document(opt)
|
797
|
-
end
|
805
|
+
::RDoc::RDoc.new.document(opt)
|
798
806
|
end
|
799
807
|
end
|
800
808
|
|
@@ -836,9 +844,11 @@ module Setup
|
|
836
844
|
install_files targetfiles(), "#{config.mandir}/#{rel}", 0644
|
837
845
|
end
|
838
846
|
|
847
|
+
# doc installs to directory named: "ruby-#{package}"
|
839
848
|
def install_dir_doc(rel)
|
840
849
|
return if config.without_doc?
|
841
|
-
|
850
|
+
dir = "#{config.docdir}/ruby-#{PACKAGE_NAME}/#{rel}" # "#{config.docdir}/#{rel}"
|
851
|
+
install_files targetfiles(), dir, 0644
|
842
852
|
end
|
843
853
|
|
844
854
|
def install_files(list, dest, mode)
|
@@ -861,7 +871,7 @@ module Setup
|
|
861
871
|
end
|
862
872
|
|
863
873
|
def dllext
|
864
|
-
RBCONFIG['DLEXT']
|
874
|
+
ConfigTable::RBCONFIG['DLEXT']
|
865
875
|
end
|
866
876
|
|
867
877
|
def targetfiles
|
@@ -994,7 +1004,7 @@ module Setup
|
|
994
1004
|
alias distclean_dir_man noop
|
995
1005
|
|
996
1006
|
def distclean_dir_doc(rel)
|
997
|
-
if
|
1007
|
+
if GENERATE_RDOC
|
998
1008
|
rm_rf('rdoc') if File.directory?('rdoc')
|
999
1009
|
end
|
1000
1010
|
end
|
data/task/allshare.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Need the package name, and whether to generate documentation.
|
2
|
+
PACKAGE = File.read(Dir.glob('{.,meta/}unixname{,.txt}', File::FNM_CASEFOLD).first).strip
|
3
|
+
GENERATE_RDOCS = true # package developer may need to deactivate
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'rbconfig'
|
7
|
+
|
8
|
+
class SetupError < StandardError; end
|
9
|
+
|
10
|
+
#
|
11
|
+
|
12
|
+
module Setup
|
13
|
+
|
14
|
+
#
|
15
|
+
# CLI runner
|
16
|
+
#
|
17
|
+
|
18
|
+
def self.run_cli(task)
|
19
|
+
opts = OptionParser.new
|
20
|
+
|
21
|
+
opts.banner = "Usage: #{File.basename($0)} [options]"
|
22
|
+
|
23
|
+
if task == 'config' or task == 'all'
|
24
|
+
opts.separator ""
|
25
|
+
opts.separator "Config options:"
|
26
|
+
Setup::ConfigTable::DESCRIPTIONS.each do |name, type, desc|
|
27
|
+
opts.on("--#{name} #{type.to_s.upcase}", desc) do |val|
|
28
|
+
ENV[name.to_s] = val.to_s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if task == 'install'
|
34
|
+
opts.separator ""
|
35
|
+
opts.separator "Install options:"
|
36
|
+
|
37
|
+
opts.on("--prefix PATH", "Installation prefix") do |val|
|
38
|
+
installer.install_prefix = val
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if task == 'test'
|
43
|
+
opts.separator ""
|
44
|
+
opts.separator "Install options:"
|
45
|
+
|
46
|
+
opts.on("--runner TYPE", "Test runner (auto|console|gtk|gtk2|tk)") do |val|
|
47
|
+
installer.config.testrunner = val
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# common options
|
52
|
+
opts.separator ""
|
53
|
+
opts.separator "General options:"
|
54
|
+
|
55
|
+
opts.on("-q", "--quiet", "Silence output") do |val|
|
56
|
+
installer.quiet = val
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("--verbose", "Provide verbose output") do |val|
|
60
|
+
installer.verbose = val
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on("-n", "--no-write", "Do not write to disk") do |val|
|
64
|
+
installer.no_harm = !val
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on("--dryrun", "Same as --no-write") do |val|
|
68
|
+
installer.no_harm = val
|
69
|
+
end
|
70
|
+
|
71
|
+
# common options
|
72
|
+
opts.separator ""
|
73
|
+
opts.separator "Inform options:"
|
74
|
+
|
75
|
+
# Tail options (eg. commands in option form)
|
76
|
+
opts.on_tail("-h", "--help", "display this help information") do
|
77
|
+
puts Setup.help
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
|
81
|
+
opts.on_tail("--version", "Show version") do
|
82
|
+
puts File.basename($0) + ' v' + Setup::Version.join('.')
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
|
86
|
+
opts.on_tail("--copyright", "Show copyright") do
|
87
|
+
puts Setup::Copyright
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
|
91
|
+
begin
|
92
|
+
opts.parse!(ARGV)
|
93
|
+
rescue OptionParser::InvalidOption
|
94
|
+
$stderr.puts $!.to_s.capitalize
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
|
98
|
+
begin
|
99
|
+
installer.__send__("exec_#{task}")
|
100
|
+
rescue SetupError
|
101
|
+
raise if $DEBUG
|
102
|
+
$stderr.puts $!.message
|
103
|
+
$stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
data/task/clean
ADDED
data/task/compile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Setup
|
2
|
+
|
3
|
+
def self.compile
|
4
|
+
makefiles = Dir['ext/**/Makefile')
|
5
|
+
makefiles.each do |makefile|
|
6
|
+
cd File.dirname(extconf) do
|
7
|
+
system "make"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
#
|
16
|
+
# Runners
|
17
|
+
#
|
18
|
+
|
19
|
+
if $0 == __FILE__
|
20
|
+
|
21
|
+
Setup::ConfigTable.run_cli(:compile)
|
22
|
+
|
23
|
+
elsif defined?(Rake)
|
24
|
+
|
25
|
+
Setup::ConfigTable.run_rake
|
26
|
+
|
27
|
+
end
|
28
|
+
|
data/task/configure
ADDED
@@ -0,0 +1,372 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Setup.rb v3.5.0
|
3
|
+
# Copyright (c) 2008 Minero Aoki, Trans
|
4
|
+
#
|
5
|
+
# This program is free software.
|
6
|
+
# You can distribute/modify this program under the terms of
|
7
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
8
|
+
|
9
|
+
require File.dirname(__FILE__) + "/common.rb"
|
10
|
+
|
11
|
+
# Typical installation procedure:
|
12
|
+
#
|
13
|
+
# $ ./setup.rb
|
14
|
+
#
|
15
|
+
# -- or --
|
16
|
+
#
|
17
|
+
# $ ./setup.rb config
|
18
|
+
# $ ./setup.rb setup
|
19
|
+
# $ ./setup.rb install
|
20
|
+
#
|
21
|
+
# @all@ and @install@ may require root privileges.
|
22
|
+
#
|
23
|
+
# This update only works with Ruby 1.6.3 and above.
|
24
|
+
#
|
25
|
+
# TODO: Update shebangs on install of binaries.
|
26
|
+
# TODO: Make cleaning more comprehensive (?)
|
27
|
+
|
28
|
+
module Setup
|
29
|
+
|
30
|
+
# ConfigTable stores platform information.
|
31
|
+
|
32
|
+
class ConfigTable
|
33
|
+
|
34
|
+
RBCONFIG = ::Config::CONFIG
|
35
|
+
|
36
|
+
CONFIGFILE = '.config'
|
37
|
+
|
38
|
+
DESCRIPTIONS = [
|
39
|
+
[:prefix , :path, 'path prefix of target environment'],
|
40
|
+
[:bindir , :path, 'directory for commands'],
|
41
|
+
[:libdir , :path, 'directory for libraries'],
|
42
|
+
[:datadir , :path, 'directory for shared data'],
|
43
|
+
[:mandir , :path, 'directory for man pages'],
|
44
|
+
[:docdir , :path, 'Directory for documentation'],
|
45
|
+
[:sysconfdir , :path, 'directory for system configuration files'],
|
46
|
+
[:localstatedir , :path, 'directory for local state data'],
|
47
|
+
[:libruby , :path, 'directory for ruby libraries'],
|
48
|
+
[:librubyver , :path, 'directory for standard ruby libraries'],
|
49
|
+
[:librubyverarch , :path, 'directory for standard ruby extensions'],
|
50
|
+
[:siteruby , :path, 'directory for version-independent aux ruby libraries'],
|
51
|
+
[:siterubyver , :path, 'directory for aux ruby libraries'],
|
52
|
+
[:siterubyverarch , :path, 'directory for aux ruby binaries'],
|
53
|
+
[:rbdir , :path, 'directory for ruby scripts'],
|
54
|
+
[:sodir , :path, 'directory for ruby extentions'],
|
55
|
+
[:rubypath , :prog, 'path to set to #! line'],
|
56
|
+
[:rubyprog , :prog, 'ruby program using for installation'],
|
57
|
+
[:makeprog , :prog, 'make program to compile ruby extentions'],
|
58
|
+
[:extconfopt , :name, 'options to pass-thru to extconf.rb'],
|
59
|
+
[:without_ext , :bool, 'do not compile/install ruby extentions'],
|
60
|
+
[:without_doc , :bool, 'do not generate html documentation'],
|
61
|
+
[:shebang , :pick, 'shebang line (#!) editing mode (all,ruby,never)'],
|
62
|
+
[:doctemplate , :pick, 'document template to use (html|xml)'],
|
63
|
+
[:testrunner , :pick, 'Runner to use for testing (auto|console|tk|gtk|gtk2)'],
|
64
|
+
[:installdirs , :pick, 'install location mode (std,site,home :: libruby,site_ruby,$HOME)']
|
65
|
+
]
|
66
|
+
|
67
|
+
# List of configurable options.
|
68
|
+
OPTIONS = DESCRIPTIONS.collect{ |(k,t,v)| k.to_s }
|
69
|
+
|
70
|
+
# Pathname attribute. Pathnames are automatically expanded
|
71
|
+
# unless they start with '$', a path variable.
|
72
|
+
def self.attr_pathname(name)
|
73
|
+
class_eval %{
|
74
|
+
def #{name}
|
75
|
+
@#{name}.gsub(%r<\\$([^/]+)>){ self[$1] }
|
76
|
+
end
|
77
|
+
def #{name}=(path)
|
78
|
+
raise SetupError, "bad config: #{name.to_s.upcase} requires argument" unless path
|
79
|
+
@#{name} = (path[0,1] == '$' ? path : File.expand_path(path))
|
80
|
+
end
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
# List of pathnames. These are not expanded though.
|
85
|
+
def self.attr_pathlist(name)
|
86
|
+
class_eval %{
|
87
|
+
def #{name}
|
88
|
+
@#{name}
|
89
|
+
end
|
90
|
+
def #{name}=(pathlist)
|
91
|
+
case pathlist
|
92
|
+
when Array
|
93
|
+
@#{name} = pathlist
|
94
|
+
else
|
95
|
+
@#{name} = pathlist.to_s.split(/[:;,]/)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
# Adds boolean support.
|
102
|
+
def self.attr_accessor(*names)
|
103
|
+
bools, attrs = names.partition{ |name| name.to_s =~ /\?$/ }
|
104
|
+
attr_boolean *bools
|
105
|
+
super *attrs
|
106
|
+
end
|
107
|
+
|
108
|
+
# Boolean attribute. Can be assigned true, false, nil, or
|
109
|
+
# a string matching yes|true|y|t or no|false|n|f.
|
110
|
+
def self.attr_boolean(*names)
|
111
|
+
names.each do |name|
|
112
|
+
name = name.to_s.chomp('?')
|
113
|
+
attr_reader name # MAYBE: Deprecate
|
114
|
+
code = %{
|
115
|
+
def #{name}?; @#{name}; end
|
116
|
+
def #{name}=(val)
|
117
|
+
case val
|
118
|
+
when true, false, nil
|
119
|
+
@#{name} = val
|
120
|
+
else
|
121
|
+
case val.to_s.downcase
|
122
|
+
when 'y', 'yes', 't', 'true'
|
123
|
+
@#{name} = true
|
124
|
+
when 'n', 'no', 'f', 'false'
|
125
|
+
@#{name} = false
|
126
|
+
else
|
127
|
+
raise SetupError, "bad config: use #{name.upcase}=(yes|no) [\#{val}]"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
}
|
132
|
+
class_eval code
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
DESCRIPTIONS.each do |k,t,d|
|
137
|
+
case t
|
138
|
+
when :path
|
139
|
+
attr_pathname k
|
140
|
+
when :bool
|
141
|
+
attr_boolean k
|
142
|
+
else
|
143
|
+
attr_accessor k
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# # provide verbosity (default is true)
|
148
|
+
# attr_accessor :verbose?
|
149
|
+
|
150
|
+
# # don't actually write files to system
|
151
|
+
# attr_accessor :no_harm?
|
152
|
+
|
153
|
+
# shebang has only three options.
|
154
|
+
def shebang=(val)
|
155
|
+
if %w(all ruby never).include?(val)
|
156
|
+
@shebang = val
|
157
|
+
else
|
158
|
+
raise SetupError, "bad config: use SHEBANG=(all|ruby|never) [#{val}]"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# installdirs has only three options; and it has side-effects.
|
163
|
+
def installdirs=(val)
|
164
|
+
@installdirs = val
|
165
|
+
case val.to_s
|
166
|
+
when 'std'
|
167
|
+
self.rbdir = '$librubyver'
|
168
|
+
self.sodir = '$librubyverarch'
|
169
|
+
when 'site'
|
170
|
+
self.rbdir = '$siterubyver'
|
171
|
+
self.sodir = '$siterubyverarch'
|
172
|
+
when 'home'
|
173
|
+
raise SetupError, 'HOME is not set.' unless ENV['HOME']
|
174
|
+
self.prefix = ENV['HOME']
|
175
|
+
self.rbdir = '$libdir/ruby'
|
176
|
+
self.sodir = '$libdir/ruby'
|
177
|
+
else
|
178
|
+
raise SetupError, "bad config: use INSTALLDIRS=(std|site|home|local) [#{val}]"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# New ConfigTable
|
183
|
+
def initialize(values=nil)
|
184
|
+
initialize_defaults
|
185
|
+
if values
|
186
|
+
values.each{ |k,v| __send__("#{k}=", v) }
|
187
|
+
end
|
188
|
+
yeild(self) if block_given?
|
189
|
+
load_config if File.file?(CONFIGFILE)
|
190
|
+
end
|
191
|
+
|
192
|
+
# Assign CONFIG defaults
|
193
|
+
#
|
194
|
+
# TODO: Does this handle 'nmake' on windows?
|
195
|
+
def initialize_defaults
|
196
|
+
prefix = RBCONFIG['prefix']
|
197
|
+
|
198
|
+
rubypath = File.join(RBCONFIG['bindir'], RBCONFIG['ruby_install_name'] + RBCONFIG['EXEEXT'])
|
199
|
+
|
200
|
+
major = RBCONFIG['MAJOR'].to_i
|
201
|
+
minor = RBCONFIG['MINOR'].to_i
|
202
|
+
teeny = RBCONFIG['TEENY'].to_i
|
203
|
+
version = "#{major}.#{minor}"
|
204
|
+
|
205
|
+
# ruby ver. >= 1.4.4?
|
206
|
+
newpath_p = ((major >= 2) or
|
207
|
+
((major == 1) and
|
208
|
+
((minor >= 5) or
|
209
|
+
((minor == 4) and (teeny >= 4)))))
|
210
|
+
|
211
|
+
if RBCONFIG['rubylibdir']
|
212
|
+
# V > 1.6.3
|
213
|
+
libruby = "#{prefix}/lib/ruby"
|
214
|
+
librubyver = RBCONFIG['rubylibdir']
|
215
|
+
librubyverarch = RBCONFIG['archdir']
|
216
|
+
siteruby = RBCONFIG['sitedir']
|
217
|
+
siterubyver = RBCONFIG['sitelibdir']
|
218
|
+
siterubyverarch = RBCONFIG['sitearchdir']
|
219
|
+
elsif newpath_p
|
220
|
+
# 1.4.4 <= V <= 1.6.3
|
221
|
+
libruby = "#{prefix}/lib/ruby"
|
222
|
+
librubyver = "#{prefix}/lib/ruby/#{version}"
|
223
|
+
librubyverarch = "#{prefix}/lib/ruby/#{version}/#{c['arch']}"
|
224
|
+
siteruby = RBCONFIG['sitedir']
|
225
|
+
siterubyver = "$siteruby/#{version}"
|
226
|
+
siterubyverarch = "$siterubyver/#{RBCONFIG['arch']}"
|
227
|
+
else
|
228
|
+
# V < 1.4.4
|
229
|
+
libruby = "#{prefix}/lib/ruby"
|
230
|
+
librubyver = "#{prefix}/lib/ruby/#{version}"
|
231
|
+
librubyverarch = "#{prefix}/lib/ruby/#{version}/#{c['arch']}"
|
232
|
+
siteruby = "#{prefix}/lib/ruby/#{version}/site_ruby"
|
233
|
+
siterubyver = siteruby
|
234
|
+
siterubyverarch = "$siterubyver/#{RBCONFIG['arch']}"
|
235
|
+
end
|
236
|
+
|
237
|
+
if arg = RBCONFIG['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
|
238
|
+
makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
|
239
|
+
else
|
240
|
+
makeprog = 'make'
|
241
|
+
end
|
242
|
+
|
243
|
+
parameterize = lambda do |path|
|
244
|
+
val = RBCONFIG[path]
|
245
|
+
val.sub(/\A#{Regexp.quote(prefix)}/, '$prefix')
|
246
|
+
end
|
247
|
+
|
248
|
+
self.prefix = prefix
|
249
|
+
self.bindir = parameterize['bindir']
|
250
|
+
self.libdir = parameterize['libdir']
|
251
|
+
self.datadir = parameterize['datadir']
|
252
|
+
self.mandir = parameterize['mandir']
|
253
|
+
self.docdir = File.dirname(parameterize['docdir']) # b/c of trailing $(PACKAGE)
|
254
|
+
self.sysconfdir = parameterize['sysconfdir']
|
255
|
+
self.localstatedir = parameterize['localstatedir']
|
256
|
+
self.libruby = libruby
|
257
|
+
self.librubyver = librubyver
|
258
|
+
self.librubyverarch = librubyverarch
|
259
|
+
self.siteruby = siteruby
|
260
|
+
self.siterubyver = siterubyver
|
261
|
+
self.siterubyverarch = siterubyverarch
|
262
|
+
self.rbdir = '$siterubyver'
|
263
|
+
self.sodir = '$siterubyverarch'
|
264
|
+
self.rubypath = rubypath
|
265
|
+
self.rubyprog = rubypath
|
266
|
+
self.makeprog = makeprog
|
267
|
+
self.extconfopt = ''
|
268
|
+
self.shebang = 'ruby'
|
269
|
+
self.without_ext = 'no'
|
270
|
+
self.without_doc = 'yes'
|
271
|
+
self.doctemplate = 'html'
|
272
|
+
self.testrunner = 'auto'
|
273
|
+
self.installdirs = 'site'
|
274
|
+
end
|
275
|
+
|
276
|
+
# Get configuration from environment.
|
277
|
+
def env_config
|
278
|
+
OPTIONS.each do |name|
|
279
|
+
if value = ENV[name]
|
280
|
+
__send__("#{name}=",value)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
# Load configuration.
|
286
|
+
def load_config
|
287
|
+
#if File.file?(CONFIGFILE)
|
288
|
+
begin
|
289
|
+
File.foreach(CONFIGFILE) do |line|
|
290
|
+
k, v = *line.split(/=/, 2)
|
291
|
+
__send__("#{k}=",v.strip) #self[k] = v.strip
|
292
|
+
end
|
293
|
+
rescue Errno::ENOENT
|
294
|
+
raise SetupError, $!.message + "\n#{File.basename($0)} config first"
|
295
|
+
end
|
296
|
+
#end
|
297
|
+
end
|
298
|
+
|
299
|
+
# Save configuration.
|
300
|
+
def save_config
|
301
|
+
File.open(CONFIGFILE, 'w') do |f|
|
302
|
+
OPTIONS.each do |name|
|
303
|
+
val = self[name]
|
304
|
+
f << "#{name}=#{val}\n"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def show
|
310
|
+
fmt = "%-20s %s\n"
|
311
|
+
OPTIONS.each do |name|
|
312
|
+
value = self[name]
|
313
|
+
reslv = __send__(name)
|
314
|
+
case reslv
|
315
|
+
when String
|
316
|
+
reslv = "(none)" if reslv.empty?
|
317
|
+
when false, nil
|
318
|
+
reslv = "no"
|
319
|
+
when true
|
320
|
+
reslv = "yes"
|
321
|
+
end
|
322
|
+
printf fmt, name, reslv
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
#
|
327
|
+
|
328
|
+
def extconfs
|
329
|
+
@extconfs ||= Dir['ext/**/extconf.rb']
|
330
|
+
end
|
331
|
+
|
332
|
+
def extensions
|
333
|
+
@extensions ||= extconfs.collect{ |f| File.dirname(f) }
|
334
|
+
end
|
335
|
+
|
336
|
+
def compiles?
|
337
|
+
!extensions.empty?
|
338
|
+
end
|
339
|
+
|
340
|
+
private
|
341
|
+
|
342
|
+
# Get unresloved attribute.
|
343
|
+
def [](name)
|
344
|
+
instance_variable_get("@#{name}")
|
345
|
+
end
|
346
|
+
|
347
|
+
# Set attribute.
|
348
|
+
def []=(name, value)
|
349
|
+
instance_variable_set("@#{name}", value)
|
350
|
+
end
|
351
|
+
|
352
|
+
# Resolved attribute. (for paths)
|
353
|
+
#def resolve(name)
|
354
|
+
# self[name].gsub(%r<\\$([^/]+)>){ self[$1] }
|
355
|
+
#end
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
#
|
364
|
+
# Runners
|
365
|
+
#
|
366
|
+
|
367
|
+
if $0 == __FILE__
|
368
|
+
Setup::ConfigTable.run_cli
|
369
|
+
elsif defined?(Rake)
|
370
|
+
Setup::ConfigTable.run_rake
|
371
|
+
end
|
372
|
+
|