rant 0.5.0 → 0.5.2
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/NEWS +30 -0
- data/README +4 -1
- data/Rantfile +28 -8
- data/doc/advanced.rdoc +19 -70
- data/doc/filelist.rdoc +963 -0
- data/doc/homepage/index.html +8 -2
- data/doc/rantfile.rdoc +7 -25
- data/doc/rubylib.rdoc +27 -0
- data/doc/sys.rdoc +15 -2
- data/doc/sys_filelist.rdoc +118 -0
- data/lib/rant.rb +1 -1
- data/lib/rant/cs_compiler.rb +4 -4
- data/lib/rant/filelist.rb +8 -0
- data/lib/rant/import/archive.rb +6 -6
- data/lib/rant/import/filelist/core.rb +429 -0
- data/lib/rant/import/filelist/inspect.rb +57 -0
- data/lib/rant/import/filelist/std.rb +64 -0
- data/lib/rant/import/nodes/default.rb +6 -2
- data/lib/rant/import/rubypackage.rb +10 -0
- data/lib/rant/init.rb +200 -0
- data/lib/rant/rantlib.rb +98 -111
- data/lib/rant/rantsys.rb +86 -455
- data/lib/rant/rantvar.rb +1 -7
- data/test/import/directedrule/Rantfile +1 -1
- data/test/lib/test_filelist.rb +481 -0
- data/test/test_filelist.rb +135 -13
- data/test/test_sys.rb +4 -0
- data/test/test_sys_methods.rb +9 -0
- data/test/tutil.rb +37 -15
- metadata +18 -7
- data/lib/rant/rantenv.rb +0 -184
- data/test/deprecated/test_0_5_2.rb +0 -61
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
# inspect.rb - Custom inspect method for Rant::FileList instances.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
|
5
|
+
|
6
|
+
module Rant
|
7
|
+
class FileList
|
8
|
+
# Note that the default Object#inspect implementation is
|
9
|
+
# available as +object_inspect+.
|
10
|
+
def inspect
|
11
|
+
# empirisch ermittelt ;)
|
12
|
+
s = "#<#{self.class}:0x%x " % (object_id << 1)
|
13
|
+
|
14
|
+
s << "glob:" << (glob_dotfiles? ? "all" : "unix") << " "
|
15
|
+
if ix = ignore_rx
|
16
|
+
is = ix.source.dup
|
17
|
+
is.gsub!(/ +/, ' ')
|
18
|
+
is.gsub!(/\n/, '\n')
|
19
|
+
is.gsub!(/\t/, '\t')
|
20
|
+
is[10..-1] = "..." if is.length > 12
|
21
|
+
s << "i:#{is} "
|
22
|
+
end
|
23
|
+
|
24
|
+
if @pending
|
25
|
+
s << "res:#{@actions.size} "
|
26
|
+
end
|
27
|
+
|
28
|
+
unless @keep.empty?
|
29
|
+
s << "keep:#{@keep.size} "
|
30
|
+
end
|
31
|
+
|
32
|
+
s << "entries:#{items.size}"
|
33
|
+
if @items.size > 0
|
34
|
+
s << "["
|
35
|
+
if @items.size == 1
|
36
|
+
is = @items.first.dup
|
37
|
+
is[15..-1] = "..." if is.length > 16
|
38
|
+
is = '"' << is << '"'
|
39
|
+
else
|
40
|
+
fs = @items.first.dup
|
41
|
+
fs[11..-1] = "..." if fs.length > 12
|
42
|
+
fs = '"' << fs << '"'
|
43
|
+
ls = @items.last.dup
|
44
|
+
ls[0..-11] = "..." if ls.length > 12
|
45
|
+
ls = '"' << ls << '"'
|
46
|
+
if @items.size == 2
|
47
|
+
is = "#{fs}, #{ls}"
|
48
|
+
else
|
49
|
+
is = "#{fs}, ..., #{ls}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
s << "#{is}]"
|
53
|
+
end
|
54
|
+
s << ">"
|
55
|
+
end
|
56
|
+
end # class FileList
|
57
|
+
end # module Rant
|
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
# std.rb - Additional set of Rant::FileList instance methods.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
|
5
|
+
|
6
|
+
# What should this file be used for:
|
7
|
+
#
|
8
|
+
# Place <code>import "filelist/std"</code> in an Rantfile to get all
|
9
|
+
# functionality as defined after <code>require "rant/filelist"</code>
|
10
|
+
# (for use as library). Read doc/filelist.rdoc.
|
11
|
+
|
12
|
+
require 'rant/import/filelist/inspect'
|
13
|
+
|
14
|
+
module Rant
|
15
|
+
class FileList
|
16
|
+
# Remove all entries which contain a directory with the
|
17
|
+
# given name.
|
18
|
+
# If no argument or +nil+ given, remove all directories.
|
19
|
+
#
|
20
|
+
# Example:
|
21
|
+
# file_list.no_dir "CVS"
|
22
|
+
# would remove the following entries from file_list:
|
23
|
+
# CVS/
|
24
|
+
# src/CVS/lib.c
|
25
|
+
# CVS/foo/bar/
|
26
|
+
def no_dir(name = nil)
|
27
|
+
@actions << [:apply_no_dir, name]
|
28
|
+
@pending = true
|
29
|
+
self
|
30
|
+
end
|
31
|
+
def apply_no_dir(name)
|
32
|
+
entry = nil
|
33
|
+
unless name
|
34
|
+
@items.reject! { |entry|
|
35
|
+
test(?d, entry) && !@keep[entry]
|
36
|
+
}
|
37
|
+
return
|
38
|
+
end
|
39
|
+
elems = nil
|
40
|
+
@items.reject! { |entry|
|
41
|
+
next if @keep[entry]
|
42
|
+
elems = Sys.split_all(entry)
|
43
|
+
i = elems.index(name)
|
44
|
+
if i
|
45
|
+
path = File.join(*elems[0..i])
|
46
|
+
test(?d, path)
|
47
|
+
else
|
48
|
+
false
|
49
|
+
end
|
50
|
+
}
|
51
|
+
end
|
52
|
+
private :apply_no_dir
|
53
|
+
# Get a new filelist containing only the existing files from
|
54
|
+
# this filelist.
|
55
|
+
def files
|
56
|
+
select { |entry| test ?f, entry }
|
57
|
+
end
|
58
|
+
# Get a new filelist containing only the existing directories
|
59
|
+
# from this filelist.
|
60
|
+
def dirs
|
61
|
+
select { |entry| test ?d, entry }
|
62
|
+
end
|
63
|
+
end # class FileList
|
64
|
+
end # module Rant
|
@@ -244,6 +244,16 @@ class Rant::Generators::RubyPackage
|
|
244
244
|
spec = Gem::Specification.new do |s|
|
245
245
|
map_to_gemspec(s)
|
246
246
|
end
|
247
|
+
|
248
|
+
# fix for YAML bug in Ruby 1.8.3 and 1.8.4 previews
|
249
|
+
if RUBY_VERSION == "1.8.3" or
|
250
|
+
RUBY_VERSION == "1.8.4" && RUBY_RELEASE_DATE < "2005-12-24"
|
251
|
+
def spec.to_yaml(*args, &block)
|
252
|
+
yaml = super
|
253
|
+
yaml =~ /^---/ ? yaml : "--- #{yaml}"
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
247
257
|
fn = nil
|
248
258
|
begin
|
249
259
|
fn = Gem::Builder.new(spec).build
|
data/lib/rant/init.rb
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
|
2
|
+
# init.rb - Define constants and methods required by all Rant code.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
|
5
|
+
|
6
|
+
require 'rbconfig'
|
7
|
+
|
8
|
+
unless Process::Status.method_defined?(:success?) # new in 1.8.2
|
9
|
+
class Process::Status
|
10
|
+
def success?; exitstatus == 0; end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
unless Regexp.respond_to? :union # new in 1.8.1
|
14
|
+
def Regexp.union(*patterns)
|
15
|
+
# let's hope it comes close to ruby-1.8.1 and upwards...
|
16
|
+
return /(?!)/ if patterns.empty?
|
17
|
+
Regexp.new(patterns.join("|"))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
if RUBY_VERSION < "1.8.2"
|
21
|
+
class Array
|
22
|
+
undef_method :flatten, :flatten!
|
23
|
+
def flatten
|
24
|
+
cp = self.dup
|
25
|
+
cp.flatten!
|
26
|
+
cp
|
27
|
+
end
|
28
|
+
def flatten!
|
29
|
+
res = []
|
30
|
+
flattened = false
|
31
|
+
self.each { |e|
|
32
|
+
if e.respond_to? :to_ary
|
33
|
+
res.concat(e.to_ary)
|
34
|
+
flattened = true
|
35
|
+
else
|
36
|
+
res << e
|
37
|
+
end
|
38
|
+
}
|
39
|
+
if flattened
|
40
|
+
replace(res)
|
41
|
+
flatten!
|
42
|
+
self
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class String
|
49
|
+
def _rant_sub_ext(ext, new_ext = nil)
|
50
|
+
if new_ext
|
51
|
+
self.sub(/#{Regexp.escape ext}$/, new_ext)
|
52
|
+
else
|
53
|
+
self.sub(/(\.[^.]*$)|$/, ".#{ext}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
module Rant
|
59
|
+
VERSION = '0.5.2'
|
60
|
+
|
61
|
+
@__rant_no_value__ = Object.new.freeze
|
62
|
+
def self.__rant_no_value__
|
63
|
+
@__rant_no_value__
|
64
|
+
end
|
65
|
+
|
66
|
+
module Env
|
67
|
+
OS = ::Config::CONFIG['target']
|
68
|
+
RUBY = ::Config::CONFIG['ruby_install_name']
|
69
|
+
RUBY_BINDIR = ::Config::CONFIG['bindir']
|
70
|
+
RUBY_EXE = File.join(RUBY_BINDIR, RUBY + ::Config::CONFIG["EXEEXT"])
|
71
|
+
|
72
|
+
@@zip_bin = false
|
73
|
+
@@tar_bin = false
|
74
|
+
|
75
|
+
if OS =~ /mswin/i
|
76
|
+
def on_windows?; true; end
|
77
|
+
else
|
78
|
+
def on_windows?; false; end
|
79
|
+
end
|
80
|
+
|
81
|
+
def have_zip?
|
82
|
+
if @@zip_bin == false
|
83
|
+
@@zip_bin = find_bin "zip"
|
84
|
+
end
|
85
|
+
!@@zip_bin.nil?
|
86
|
+
end
|
87
|
+
def have_tar?
|
88
|
+
if @@tar_bin == false
|
89
|
+
@@tar_bin = find_bin "tar"
|
90
|
+
end
|
91
|
+
!@@tar_bin.nil?
|
92
|
+
end
|
93
|
+
# Get an array with all pathes in the PATH
|
94
|
+
# environment variable.
|
95
|
+
def pathes
|
96
|
+
# Windows doesn't care about case in environment variables,
|
97
|
+
# but the ENV hash does!
|
98
|
+
path = ENV[on_windows? ? "Path" : "PATH"]
|
99
|
+
return [] unless path
|
100
|
+
path.split(on_windows? ? ";" : ":")
|
101
|
+
end
|
102
|
+
# Searches for bin_name on path and returns
|
103
|
+
# an absolute path if successfull or nil
|
104
|
+
# if an executable called bin_name couldn't be found.
|
105
|
+
def find_bin bin_name
|
106
|
+
if on_windows?
|
107
|
+
bin_name_exe = nil
|
108
|
+
if bin_name !~ /\.[^\.]{1,3}$/i
|
109
|
+
bin_name_exe = bin_name + ".exe"
|
110
|
+
end
|
111
|
+
pathes.each { |dir|
|
112
|
+
file = File.join(dir, bin_name)
|
113
|
+
return file if test(?f, file)
|
114
|
+
if bin_name_exe
|
115
|
+
file = File.join(dir, bin_name_exe)
|
116
|
+
return file if test(?f, file)
|
117
|
+
end
|
118
|
+
}
|
119
|
+
else
|
120
|
+
pathes.each { |dir|
|
121
|
+
file = File.join(dir, bin_name)
|
122
|
+
return file if test(?x, file)
|
123
|
+
}
|
124
|
+
end
|
125
|
+
nil
|
126
|
+
end
|
127
|
+
# Add quotes to a path and replace File::Separators if necessary.
|
128
|
+
def shell_path path
|
129
|
+
# TODO: check for more characters when deciding wheter to use
|
130
|
+
# quotes.
|
131
|
+
if on_windows?
|
132
|
+
path = path.tr("/", "\\")
|
133
|
+
if path.include? ' '
|
134
|
+
'"' + path + '"'
|
135
|
+
else
|
136
|
+
path
|
137
|
+
end
|
138
|
+
else
|
139
|
+
if path.include? ' '
|
140
|
+
"'" + path + "'"
|
141
|
+
else
|
142
|
+
path
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
extend self
|
147
|
+
end # module Env
|
148
|
+
|
149
|
+
module Sys
|
150
|
+
# Returns a string that can be used as a valid path argument
|
151
|
+
# on the shell respecting portability issues.
|
152
|
+
def sp(arg)
|
153
|
+
if arg.respond_to? :to_ary
|
154
|
+
arg.to_ary.map{ |e| sp e }.join(' ')
|
155
|
+
else
|
156
|
+
_escaped_path arg
|
157
|
+
end
|
158
|
+
end
|
159
|
+
# Escape special shell characters (currently only spaces).
|
160
|
+
# Flattens arrays and returns always a single string.
|
161
|
+
def escape(arg)
|
162
|
+
if arg.respond_to? :to_ary
|
163
|
+
arg.to_ary.map{ |e| escape e }.join(' ')
|
164
|
+
else
|
165
|
+
_escaped arg
|
166
|
+
end
|
167
|
+
end
|
168
|
+
if Env.on_windows?
|
169
|
+
def _escaped_path(path)
|
170
|
+
_escaped(path.to_s.tr("/", "\\"))
|
171
|
+
end
|
172
|
+
def _escaped(arg)
|
173
|
+
sarg = arg.to_s
|
174
|
+
return sarg unless sarg.include?(" ")
|
175
|
+
sarg << "\\" if sarg[-1].chr == "\\"
|
176
|
+
"\"#{sarg}\""
|
177
|
+
end
|
178
|
+
def regular_filename(fn)
|
179
|
+
fn.to_str.tr("\\", "/").gsub(%r{/{2,}}, "/")
|
180
|
+
end
|
181
|
+
else
|
182
|
+
def _escaped_path(path)
|
183
|
+
path.to_s.gsub(/(?=\s)/, "\\")
|
184
|
+
end
|
185
|
+
alias _escaped _escaped_path
|
186
|
+
def regular_filename(fn)
|
187
|
+
fn.to_str.gsub(%r{/{2,}}, "/")
|
188
|
+
end
|
189
|
+
end
|
190
|
+
private :_escaped_path
|
191
|
+
private :_escaped
|
192
|
+
# Split a path in all elements.
|
193
|
+
def split_all(path)
|
194
|
+
names = regular_filename(path).split(%r{/})
|
195
|
+
names[0] = "/" if names[0] && names[0].empty?
|
196
|
+
names
|
197
|
+
end
|
198
|
+
extend self
|
199
|
+
end # module Sys
|
200
|
+
end # module Rant
|
data/lib/rant/rantlib.rb
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
# the GNU LGPL, Lesser General Public License version 2.1.
|
9
9
|
|
10
10
|
require 'getoptlong'
|
11
|
+
require 'rant/init'
|
11
12
|
require 'rant/rantvar'
|
12
|
-
require 'rant/rantenv'
|
13
13
|
require 'rant/rantsys'
|
14
14
|
require 'rant/node'
|
15
15
|
require 'rant/import/nodes/default' # could be optimized away
|
@@ -25,111 +25,16 @@ require 'rant/coregen'
|
|
25
25
|
# this object.
|
26
26
|
Rant::MAIN_OBJECT = self
|
27
27
|
|
28
|
-
unless Process::Status.method_defined?(:success?) # new in 1.8.2
|
29
|
-
class Process::Status
|
30
|
-
def success?; exitstatus == 0; end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
unless Regexp.respond_to? :union # new in 1.8.1
|
34
|
-
def Regexp.union(*patterns)
|
35
|
-
# let's hope it comes close to ruby-1.8.1 and upwards...
|
36
|
-
return /(?!)/ if patterns.empty?
|
37
|
-
# i guess the options are lost
|
38
|
-
Regexp.new(patterns.join("|"))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
if RUBY_VERSION < "1.8.2"
|
42
|
-
class Array
|
43
|
-
undef_method :flatten, :flatten!
|
44
|
-
def flatten
|
45
|
-
cp = self.dup
|
46
|
-
cp.flatten!
|
47
|
-
cp
|
48
|
-
end
|
49
|
-
def flatten!
|
50
|
-
res = []
|
51
|
-
flattened = false
|
52
|
-
self.each { |e|
|
53
|
-
if e.respond_to? :to_ary
|
54
|
-
res.concat(e.to_ary)
|
55
|
-
flattened = true
|
56
|
-
else
|
57
|
-
res << e
|
58
|
-
end
|
59
|
-
}
|
60
|
-
if flattened
|
61
|
-
replace(res)
|
62
|
-
flatten!
|
63
|
-
self
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
if RUBY_VERSION < "1.8.1"
|
68
|
-
module FileUtils
|
69
|
-
undef_method :fu_list
|
70
|
-
def fu_list(arg)
|
71
|
-
arg.respond_to?(:to_ary) ? arg.to_ary : [arg]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class Array
|
78
|
-
|
79
|
-
# Concatenates all elements like #join(' ') but also puts quotes
|
80
|
-
# around strings that contain a space.
|
81
|
-
def arglist
|
82
|
-
warn caller[0]
|
83
|
-
warn "[WARNING] Use `sys.sp(ary)' in Rantfiles instead of deprecated Array#arglist."
|
84
|
-
Rant::Sys.sp(self)
|
85
|
-
end
|
86
|
-
|
87
|
-
def shell_pathes
|
88
|
-
warn caller[0]
|
89
|
-
warn "[WARNING] Array#shell_pathes is highly deprecated " +
|
90
|
-
"and will not come with future (0.5.2 and later) Rant releases."
|
91
|
-
warn "Use `ary.map { |path| sys.sp path }' in Rantfiles."
|
92
|
-
map { |path| Rant::Sys.sp(path) }
|
93
|
-
=begin
|
94
|
-
entry = nil
|
95
|
-
if ::Rant::Env.on_windows?
|
96
|
-
self.collect { |entry|
|
97
|
-
entry = entry.to_s.tr("/", "\\")
|
98
|
-
if entry.include? ' '
|
99
|
-
'"' + entry + '"'
|
100
|
-
else
|
101
|
-
entry
|
102
|
-
end
|
103
|
-
}
|
104
|
-
else
|
105
|
-
self.collect { |entry|
|
106
|
-
entry = entry.to_s
|
107
|
-
if entry.include? ' '
|
108
|
-
"'" + entry + "'"
|
109
|
-
else
|
110
|
-
entry
|
111
|
-
end
|
112
|
-
}
|
113
|
-
end
|
114
|
-
=end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
28
|
class String
|
119
|
-
|
120
|
-
if new_ext
|
121
|
-
self.sub(/#{Regexp.escape ext}$/, new_ext)
|
122
|
-
else
|
123
|
-
self.sub(/(\.[^.]*$)|$/, ".#{ext}")
|
124
|
-
end
|
125
|
-
end
|
29
|
+
alias sub_ext _rant_sub_ext
|
126
30
|
def to_rant_target
|
127
31
|
self
|
128
32
|
end
|
129
33
|
end
|
130
34
|
|
35
|
+
# This module and its methods don't belong to Rant's public API.
|
36
|
+
# For (Rant) internal usage only!
|
131
37
|
module Rant::Lib
|
132
|
-
|
133
38
|
# Parses one string (elem) as it occurs in the array
|
134
39
|
# which is returned by caller.
|
135
40
|
# E.g.:
|
@@ -140,21 +45,101 @@ module Rant::Lib
|
|
140
45
|
# Note: This method splits on the pattern <tt>:(\d+)(:|$)</tt>,
|
141
46
|
# assuming anything before is the filename.
|
142
47
|
def parse_caller_elem(elem)
|
143
|
-
|
144
|
-
|
145
|
-
|
48
|
+
return { :file => "", :ln => 0 } unless elem
|
49
|
+
if elem =~ /^(.+):(\d+)(?::|$)/
|
50
|
+
{ :file => $1, :ln => $2.to_i }
|
51
|
+
else
|
52
|
+
# should never occur
|
53
|
+
$stderr.puts "parse_caller_elem: #{elem.inspect}"
|
54
|
+
{ :file => elem, :ln => 0 }
|
55
|
+
end
|
56
|
+
|
57
|
+
#parts = elem.split(":")
|
58
|
+
#{ :file => parts[0], :ln => parts[1].to_i }
|
59
|
+
end
|
60
|
+
module_function :parse_caller_elem
|
61
|
+
end # module Lib
|
62
|
+
|
63
|
+
module Rant::Console
|
64
|
+
RANT_PREFIX = "rant: "
|
65
|
+
ERROR_PREFIX = "[ERROR] "
|
66
|
+
WARN_PREFIX = "[WARNING] "
|
67
|
+
def msg_prefix
|
68
|
+
if defined? @msg_prefix and @msg_prefix
|
69
|
+
@msg_prefix
|
146
70
|
else
|
147
|
-
|
148
|
-
$stderr.puts "parse_caller_elem: #{elem.inspect}"
|
149
|
-
{ :file => elem, :ln => 0 }
|
71
|
+
RANT_PREFIX
|
150
72
|
end
|
151
|
-
|
152
|
-
#parts = elem.split(":")
|
153
|
-
#{ :file => parts[0], :ln => parts[1].to_i }
|
154
73
|
end
|
155
|
-
|
156
|
-
|
157
|
-
|
74
|
+
def msg(*text)
|
75
|
+
pre = msg_prefix
|
76
|
+
$stderr.puts "#{pre}#{text.join("\n" + ' ' * pre.length)}"
|
77
|
+
end
|
78
|
+
def vmsg(importance, *text)
|
79
|
+
msg(*text) if verbose >= importance
|
80
|
+
end
|
81
|
+
def err_msg(*text)
|
82
|
+
pre = msg_prefix + ERROR_PREFIX
|
83
|
+
$stderr.puts "#{pre}#{text.join("\n" + ' ' * pre.length)}"
|
84
|
+
end
|
85
|
+
def warn_msg(*text)
|
86
|
+
pre = msg_prefix + WARN_PREFIX
|
87
|
+
$stderr.puts "#{pre}#{text.join("\n" + ' ' * pre.length)}"
|
88
|
+
end
|
89
|
+
def ask_yes_no text
|
90
|
+
$stderr.print msg_prefix + text + " [y|n] "
|
91
|
+
case $stdin.readline
|
92
|
+
when /y|yes/i: true
|
93
|
+
when /n|no/i: false
|
94
|
+
else
|
95
|
+
$stderr.puts(' ' * msg_prefix.length +
|
96
|
+
"Please answer with `yes' or `no'")
|
97
|
+
ask_yes_no text
|
98
|
+
end
|
99
|
+
end
|
100
|
+
def prompt text
|
101
|
+
$stderr.print msg_prefix + text
|
102
|
+
input = $stdin.readline
|
103
|
+
input ? input.chomp : input
|
104
|
+
end
|
105
|
+
def option_listing opts
|
106
|
+
rs = ""
|
107
|
+
opts.each { |lopt, *opt_a|
|
108
|
+
if opt_a.size == 2
|
109
|
+
# no short option
|
110
|
+
mode, desc = opt_a
|
111
|
+
else
|
112
|
+
sopt, mode, desc = opt_a
|
113
|
+
end
|
114
|
+
next unless desc # "private" option
|
115
|
+
optstr = ""
|
116
|
+
arg = nil
|
117
|
+
if mode != GetoptLong::NO_ARGUMENT
|
118
|
+
if desc =~ /(\b[A-Z_]{2,}\b)/
|
119
|
+
arg = $1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
if lopt
|
123
|
+
optstr << lopt
|
124
|
+
if arg
|
125
|
+
optstr << " " << arg
|
126
|
+
end
|
127
|
+
optstr = optstr.ljust(30)
|
128
|
+
end
|
129
|
+
if sopt
|
130
|
+
optstr << " " unless optstr.empty?
|
131
|
+
optstr << sopt
|
132
|
+
if arg
|
133
|
+
optstr << " " << arg
|
134
|
+
end
|
135
|
+
end
|
136
|
+
rs << " #{optstr}\n"
|
137
|
+
rs << " #{desc.split("\n").join("\n ")}\n"
|
138
|
+
}
|
139
|
+
rs
|
140
|
+
end
|
141
|
+
extend self
|
142
|
+
end # module Rant::Console
|
158
143
|
|
159
144
|
# The methods in this module are the public interface to Rant that can
|
160
145
|
# be used in Rantfiles.
|
@@ -217,6 +202,7 @@ module RantContext
|
|
217
202
|
rant.make(*args, &block)
|
218
203
|
end
|
219
204
|
|
205
|
+
=begin
|
220
206
|
# +rac+ stands for "rant compiler"
|
221
207
|
def rac
|
222
208
|
ch = Rant::Lib.parse_caller_elem caller[0]
|
@@ -224,6 +210,7 @@ module RantContext
|
|
224
210
|
"Method `rac' is deprecated. Use `rant' instead.")
|
225
211
|
rant
|
226
212
|
end
|
213
|
+
=end
|
227
214
|
end # module RantContext
|
228
215
|
|
229
216
|
class RantAppContext
|