rant 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/rant/rantenv.rb
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
|
2
|
-
# rantenv.rb - Environment interface.
|
3
|
-
#
|
4
|
-
# Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
|
5
|
-
|
6
|
-
require 'rbconfig'
|
7
|
-
|
8
|
-
module Rant end
|
9
|
-
|
10
|
-
# This module interfaces with the environment to provide
|
11
|
-
# information/conversion methods in a portable manner.
|
12
|
-
module Rant::Env
|
13
|
-
OS = ::Config::CONFIG['target']
|
14
|
-
RUBY = ::Config::CONFIG['ruby_install_name']
|
15
|
-
RUBY_BINDIR = ::Config::CONFIG['bindir']
|
16
|
-
RUBY_EXE = File.join(RUBY_BINDIR, RUBY + ::Config::CONFIG["EXEEXT"])
|
17
|
-
|
18
|
-
@@zip_bin = false
|
19
|
-
@@tar_bin = false
|
20
|
-
|
21
|
-
if OS =~ /mswin/i
|
22
|
-
def on_windows?; true; end
|
23
|
-
else
|
24
|
-
def on_windows?; false; end
|
25
|
-
end
|
26
|
-
|
27
|
-
def have_zip?
|
28
|
-
if @@zip_bin == false
|
29
|
-
@@zip_bin = find_bin "zip"
|
30
|
-
end
|
31
|
-
!@@zip_bin.nil?
|
32
|
-
end
|
33
|
-
|
34
|
-
def have_tar?
|
35
|
-
if @@tar_bin == false
|
36
|
-
@@tar_bin = find_bin "tar"
|
37
|
-
end
|
38
|
-
!@@tar_bin.nil?
|
39
|
-
end
|
40
|
-
|
41
|
-
# Get an array with all pathes in the PATH
|
42
|
-
# environment variable.
|
43
|
-
def pathes
|
44
|
-
# Windows doesn't care about case in environment variables,
|
45
|
-
# but the ENV hash does!
|
46
|
-
path = on_windows? ? ENV["Path"] : ENV["PATH"]
|
47
|
-
return [] unless path
|
48
|
-
if on_windows?
|
49
|
-
path.split(";")
|
50
|
-
else
|
51
|
-
path.split(":")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Searches for bin_name on path and returns
|
56
|
-
# an absolute path if successfull or nil
|
57
|
-
# if an executable called bin_name couldn't be found.
|
58
|
-
def find_bin bin_name
|
59
|
-
if on_windows?
|
60
|
-
bin_name_exe = nil
|
61
|
-
if bin_name !~ /\.[^\.]{1,3}$/i
|
62
|
-
bin_name_exe = bin_name + ".exe"
|
63
|
-
end
|
64
|
-
pathes.each { |dir|
|
65
|
-
file = File.join(dir, bin_name)
|
66
|
-
return file if test(?f, file)
|
67
|
-
if bin_name_exe
|
68
|
-
file = File.join(dir, bin_name_exe)
|
69
|
-
return file if test(?f, file)
|
70
|
-
end
|
71
|
-
}
|
72
|
-
else
|
73
|
-
pathes.each { |dir|
|
74
|
-
file = File.join(dir, bin_name)
|
75
|
-
return file if test(?x, file)
|
76
|
-
}
|
77
|
-
end
|
78
|
-
nil
|
79
|
-
end
|
80
|
-
|
81
|
-
# Add quotes to a path and replace File::Separators if necessary.
|
82
|
-
def shell_path path
|
83
|
-
# TODO: check for more characters when deciding wheter to use
|
84
|
-
# quotes.
|
85
|
-
if on_windows?
|
86
|
-
path = path.tr("/", "\\")
|
87
|
-
if path.include? ' '
|
88
|
-
'"' + path + '"'
|
89
|
-
else
|
90
|
-
path
|
91
|
-
end
|
92
|
-
else
|
93
|
-
if path.include? ' '
|
94
|
-
"'" + path + "'"
|
95
|
-
else
|
96
|
-
path
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
extend self
|
102
|
-
end # module Rant::Env
|
103
|
-
|
104
|
-
module Rant::Console
|
105
|
-
RANT_PREFIX = "rant: "
|
106
|
-
ERROR_PREFIX = "[ERROR] "
|
107
|
-
WARN_PREFIX = "[WARNING] "
|
108
|
-
def msg_prefix
|
109
|
-
if defined? @msg_prefix and @msg_prefix
|
110
|
-
@msg_prefix
|
111
|
-
else
|
112
|
-
RANT_PREFIX
|
113
|
-
end
|
114
|
-
end
|
115
|
-
def msg(*text)
|
116
|
-
pre = msg_prefix
|
117
|
-
$stderr.puts "#{pre}#{text.join("\n" + ' ' * pre.length)}"
|
118
|
-
end
|
119
|
-
def vmsg(importance, *text)
|
120
|
-
msg(*text) if verbose >= importance
|
121
|
-
end
|
122
|
-
def err_msg(*text)
|
123
|
-
pre = msg_prefix + ERROR_PREFIX
|
124
|
-
$stderr.puts "#{pre}#{text.join("\n" + ' ' * pre.length)}"
|
125
|
-
end
|
126
|
-
def warn_msg(*text)
|
127
|
-
pre = msg_prefix + WARN_PREFIX
|
128
|
-
$stderr.puts "#{pre}#{text.join("\n" + ' ' * pre.length)}"
|
129
|
-
end
|
130
|
-
def ask_yes_no text
|
131
|
-
$stderr.print msg_prefix + text + " [y|n] "
|
132
|
-
case $stdin.readline
|
133
|
-
when /y|yes/i: true
|
134
|
-
when /n|no/i: false
|
135
|
-
else
|
136
|
-
$stderr.puts(' ' * msg_prefix.length +
|
137
|
-
"Please answer with `yes' or `no'")
|
138
|
-
ask_yes_no text
|
139
|
-
end
|
140
|
-
end
|
141
|
-
def prompt text
|
142
|
-
$stderr.print msg_prefix + text
|
143
|
-
input = $stdin.readline
|
144
|
-
input ? input.chomp : input
|
145
|
-
end
|
146
|
-
def option_listing opts
|
147
|
-
rs = ""
|
148
|
-
opts.each { |lopt, *opt_a|
|
149
|
-
if opt_a.size == 2
|
150
|
-
# no short option
|
151
|
-
mode, desc = opt_a
|
152
|
-
else
|
153
|
-
sopt, mode, desc = opt_a
|
154
|
-
end
|
155
|
-
next unless desc # "private" option
|
156
|
-
optstr = ""
|
157
|
-
arg = nil
|
158
|
-
if mode != GetoptLong::NO_ARGUMENT
|
159
|
-
if desc =~ /(\b[A-Z_]{2,}\b)/
|
160
|
-
arg = $1
|
161
|
-
end
|
162
|
-
end
|
163
|
-
if lopt
|
164
|
-
optstr << lopt
|
165
|
-
if arg
|
166
|
-
optstr << " " << arg
|
167
|
-
end
|
168
|
-
optstr = optstr.ljust(30)
|
169
|
-
end
|
170
|
-
if sopt
|
171
|
-
optstr << " " unless optstr.empty?
|
172
|
-
optstr << sopt
|
173
|
-
if arg
|
174
|
-
optstr << " " << arg
|
175
|
-
end
|
176
|
-
end
|
177
|
-
rs << " #{optstr}\n"
|
178
|
-
rs << " #{desc.split("\n").join("\n ")}\n"
|
179
|
-
}
|
180
|
-
rs
|
181
|
-
end
|
182
|
-
|
183
|
-
extend self
|
184
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'test/unit'
|
3
|
-
require 'tutil'
|
4
|
-
|
5
|
-
$test_deprecated_dir ||= File.expand_path(File.dirname(__FILE__))
|
6
|
-
|
7
|
-
class TestDeprecated_0_5_2 < Test::Unit::TestCase
|
8
|
-
include Rant::TestUtil
|
9
|
-
|
10
|
-
def setup
|
11
|
-
Dir.chdir $test_deprecated_dir
|
12
|
-
end
|
13
|
-
def test_method_rac
|
14
|
-
in_local_temp_dir do
|
15
|
-
write_to_file "root.rant", <<-EOF
|
16
|
-
import "sys/more"
|
17
|
-
file "f" do |t|
|
18
|
-
sys.write_to_file t.name, "nix"
|
19
|
-
end
|
20
|
-
task :a do
|
21
|
-
rac.build "f"
|
22
|
-
end
|
23
|
-
EOF
|
24
|
-
out, err = assert_rant("a")
|
25
|
-
assert test(?f, "f")
|
26
|
-
assert_equal "nix", File.read("f")
|
27
|
-
assert_match(/\bWARNING\b/, err)
|
28
|
-
assert_match(/\brac\b/, err)
|
29
|
-
assert_match(/\brant\b/, err)
|
30
|
-
assert_match(/\bdeprecated\b/, err)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
def test_ary_arglist
|
34
|
-
in_local_temp_dir do
|
35
|
-
write_to_file "Rantfile", <<-EOF
|
36
|
-
task :default do
|
37
|
-
sys(sys.sp(Env::RUBY_EXE) + " -e \\"puts ARGV\\" " +
|
38
|
-
["a b", "c/d"].arglist + " > a.out")
|
39
|
-
end
|
40
|
-
EOF
|
41
|
-
out, err = assert_rant
|
42
|
-
content = Rant::Env.on_windows? ? "a b\nc\\d\n" : "a b\nc/d\n"
|
43
|
-
assert_file_content "a.out", content
|
44
|
-
assert_match(/\bWARNING\b/, err)
|
45
|
-
assert_match(/\barglist\b/, err)
|
46
|
-
assert_match(/\bsp\b/, err)
|
47
|
-
assert_match(/\bdeprecated\b/, err)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
def test_ary_shell_pathes
|
51
|
-
out, err = capture_std do
|
52
|
-
sp = ["a b", "a/b"].shell_pathes
|
53
|
-
assert sp.respond_to?(:to_ary)
|
54
|
-
assert_equal 2, sp.size
|
55
|
-
end
|
56
|
-
assert_match(/\bWARNING\b/, err)
|
57
|
-
assert_match(/\bshell_pathes\b/, err)
|
58
|
-
assert_match(/\bsp\b/, err)
|
59
|
-
assert_match(/\bdeprecated\b/, err)
|
60
|
-
end
|
61
|
-
end
|