rake 10.0.4 → 10.1.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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/doc/command_line_usage.rdoc +1 -1
- data/doc/rakefile.rdoc +27 -13
- data/doc/release_notes/rake-10.1.0.rdoc +61 -0
- data/install.rb +5 -15
- data/lib/rake/alt_system.rb +3 -4
- data/lib/rake/application.rb +115 -68
- data/lib/rake/backtrace.rb +9 -8
- data/lib/rake/clean.rb +27 -4
- data/lib/rake/contrib/ftptools.rb +6 -18
- data/lib/rake/contrib/sys.rb +2 -1
- data/lib/rake/dsl_definition.rb +2 -1
- data/lib/rake/ext/core.rb +2 -1
- data/lib/rake/ext/string.rb +1 -3
- data/lib/rake/file_list.rb +24 -18
- data/lib/rake/file_task.rb +1 -2
- data/lib/rake/file_utils.rb +9 -7
- data/lib/rake/file_utils_ext.rb +2 -1
- data/lib/rake/gempackagetask.rb +2 -1
- data/lib/rake/invocation_chain.rb +24 -18
- data/lib/rake/linked_list.rb +103 -0
- data/lib/rake/packagetask.rb +11 -6
- data/lib/rake/pseudo_status.rb +5 -0
- data/lib/rake/rdoctask.rb +2 -1
- data/lib/rake/ruby182_test_unit_fix.rb +4 -2
- data/lib/rake/runtest.rb +2 -2
- data/lib/rake/scope.rb +42 -0
- data/lib/rake/task.rb +47 -37
- data/lib/rake/task_arguments.rb +13 -2
- data/lib/rake/task_manager.rb +25 -24
- data/lib/rake/tasklib.rb +1 -1
- data/lib/rake/testtask.rb +10 -7
- data/lib/rake/thread_history_display.rb +1 -1
- data/lib/rake/thread_pool.rb +10 -4
- data/lib/rake/version.rb +3 -7
- data/lib/rake/win32.rb +3 -2
- data/lib/rake.rb +2 -0
- data/test/helper.rb +36 -470
- data/test/support/rakefile_definitions.rb +444 -0
- data/test/support/ruby_runner.rb +33 -0
- data/test/test_rake_application.rb +14 -12
- data/test/test_rake_application_options.rb +7 -5
- data/test/test_rake_backtrace.rb +38 -14
- data/test/test_rake_clean.rb +36 -4
- data/test/test_rake_definitions.rb +2 -3
- data/test/test_rake_file_creation_task.rb +2 -2
- data/test/test_rake_file_list.rb +23 -24
- data/test/test_rake_file_task.rb +4 -4
- data/test/test_rake_file_utils.rb +6 -2
- data/test/test_rake_ftp_file.rb +28 -13
- data/test/test_rake_functional.rb +6 -36
- data/test/test_rake_invocation_chain.rb +15 -3
- data/test/test_rake_linked_list.rb +84 -0
- data/test/test_rake_makefile_loader.rb +3 -1
- data/test/test_rake_multi_task.rb +2 -3
- data/test/test_rake_name_space.rb +1 -1
- data/test/test_rake_path_map.rb +23 -12
- data/test/test_rake_rake_test_loader.rb +2 -3
- data/test/test_rake_reduce_compat.rb +2 -6
- data/test/test_rake_rules.rb +47 -12
- data/test/test_rake_scope.rb +44 -0
- data/test/test_rake_task.rb +47 -11
- data/test/test_rake_task_arguments.rb +35 -2
- data/test/test_rake_task_manager.rb +16 -15
- data/test/test_rake_task_with_arguments.rb +2 -2
- data/test/test_rake_test_task.rb +1 -2
- data/test/test_rake_thread_pool.rb +36 -16
- data/test/test_thread_history_display.rb +16 -6
- data/test/test_trace_output.rb +2 -0
- metadata +10 -2
data/lib/rake/clean.rb
CHANGED
|
@@ -14,19 +14,42 @@
|
|
|
14
14
|
require 'rake'
|
|
15
15
|
|
|
16
16
|
# :stopdoc:
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
module Rake
|
|
19
|
+
module Cleaner
|
|
20
|
+
extend FileUtils
|
|
21
|
+
|
|
22
|
+
module_function
|
|
23
|
+
|
|
24
|
+
def cleanup_files(file_names)
|
|
25
|
+
file_names.each do |file_name|
|
|
26
|
+
cleanup(file_name)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def cleanup(file_name, opts={})
|
|
31
|
+
begin
|
|
32
|
+
rm_r file_name, opts
|
|
33
|
+
rescue StandardError => ex
|
|
34
|
+
puts "Failed to remove #{file_name}: #{ex}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
CLEAN = ::Rake::FileList["**/*~", "**/*.bak", "**/core"]
|
|
18
41
|
CLEAN.clear_exclude.exclude { |fn|
|
|
19
42
|
fn.pathmap("%f").downcase == 'core' && File.directory?(fn)
|
|
20
43
|
}
|
|
21
44
|
|
|
22
45
|
desc "Remove any temporary products."
|
|
23
46
|
task :clean do
|
|
24
|
-
CLEAN
|
|
47
|
+
Rake::Cleaner.cleanup_files(CLEAN)
|
|
25
48
|
end
|
|
26
49
|
|
|
27
|
-
CLOBBER = Rake::FileList.new
|
|
50
|
+
CLOBBER = ::Rake::FileList.new
|
|
28
51
|
|
|
29
52
|
desc "Remove any generated file."
|
|
30
53
|
task :clobber => [:clean] do
|
|
31
|
-
CLOBBER
|
|
54
|
+
Rake::Cleaner.cleanup_files(CLOBBER)
|
|
32
55
|
end
|
|
@@ -50,33 +50,21 @@ module Rake # :nodoc:
|
|
|
50
50
|
def parse_mode(m)
|
|
51
51
|
result = 0
|
|
52
52
|
(1..9).each do |i|
|
|
53
|
-
result = 2*result + ((m[i]
|
|
53
|
+
result = 2 * result + ((m[i] == ?-) ? 0 : 1)
|
|
54
54
|
end
|
|
55
55
|
result
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def determine_time(d1, d2, d3)
|
|
59
59
|
now = self.class.time.now
|
|
60
|
-
if /:/
|
|
61
|
-
result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
|
|
62
|
-
if result > now
|
|
63
|
-
result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}")
|
|
64
|
-
end
|
|
65
|
-
else
|
|
60
|
+
if /:/ !~ d3
|
|
66
61
|
result = Time.parse("#{d1} #{d2} #{d3}")
|
|
62
|
+
else
|
|
63
|
+
result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
|
|
64
|
+
result = Time.parse("#{d1} #{d2} #{now.year - 1} #{d3}") if
|
|
65
|
+
result > now
|
|
67
66
|
end
|
|
68
67
|
result
|
|
69
|
-
# elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
|
|
70
|
-
# if elements[0].nil?
|
|
71
|
-
# today = self.class.date.today
|
|
72
|
-
# if elements[1] > today.month
|
|
73
|
-
# elements[0] = today.year - 1
|
|
74
|
-
# else
|
|
75
|
-
# elements[0] = today.year
|
|
76
|
-
# end
|
|
77
|
-
# end
|
|
78
|
-
# elements = elements.collect { |el| el.nil? ? 0 : el }
|
|
79
|
-
# Time.mktime(*elements[0,7])
|
|
80
68
|
end
|
|
81
69
|
end
|
|
82
70
|
|
data/lib/rake/contrib/sys.rb
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported.
|
|
1
|
+
fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported. " +
|
|
2
|
+
"Use 'FileUtils' instead."
|
data/lib/rake/dsl_definition.rb
CHANGED
|
@@ -66,7 +66,7 @@ module Rake
|
|
|
66
66
|
dir, _ = *Rake.application.resolve_args(args)
|
|
67
67
|
Rake.each_dir_parent(dir) do |d|
|
|
68
68
|
file_create d do |t|
|
|
69
|
-
mkdir_p t.name
|
|
69
|
+
mkdir_p t.name unless File.exist?(t.name)
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
result
|
|
@@ -116,6 +116,7 @@ module Rake
|
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
# Describe the next rake task.
|
|
119
|
+
# Duplicate descriptions are discarded.
|
|
119
120
|
#
|
|
120
121
|
# Example:
|
|
121
122
|
# desc "Run the Unit Tests"
|
data/lib/rake/ext/core.rb
CHANGED
|
@@ -19,7 +19,8 @@ class Module
|
|
|
19
19
|
#
|
|
20
20
|
def rake_extension(method)
|
|
21
21
|
if method_defined?(method)
|
|
22
|
-
$stderr.puts "WARNING: Possible conflict with Rake extension:
|
|
22
|
+
$stderr.puts "WARNING: Possible conflict with Rake extension: " +
|
|
23
|
+
"#{self}##{method} already exists"
|
|
23
24
|
else
|
|
24
25
|
yield
|
|
25
26
|
end
|
data/lib/rake/ext/string.rb
CHANGED
|
@@ -13,9 +13,7 @@ class String
|
|
|
13
13
|
# +ext+ is a user added method for the String class.
|
|
14
14
|
def ext(newext='')
|
|
15
15
|
return self.dup if ['.', '..'].include? self
|
|
16
|
-
if newext != ''
|
|
17
|
-
newext = (newext =~ /^\./) ? newext : ("." + newext)
|
|
18
|
-
end
|
|
16
|
+
newext = (newext =~ /^\./) ? newext : ("." + newext) if newext != ''
|
|
19
17
|
self.chomp(File.extname(self)) << newext
|
|
20
18
|
end
|
|
21
19
|
end
|
data/lib/rake/file_list.rb
CHANGED
|
@@ -41,10 +41,11 @@ module Rake
|
|
|
41
41
|
|
|
42
42
|
# List of array methods (that are not in +Object+) that need to be
|
|
43
43
|
# delegated.
|
|
44
|
-
ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).
|
|
44
|
+
ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).
|
|
45
|
+
map { |n| n.to_s }
|
|
45
46
|
|
|
46
47
|
# List of additional methods that must be delegated.
|
|
47
|
-
MUST_DEFINE = %w[
|
|
48
|
+
MUST_DEFINE = %w[inspect <=>]
|
|
48
49
|
|
|
49
50
|
# List of methods that should not be delegated here (we define special
|
|
50
51
|
# versions of them explicitly below).
|
|
@@ -58,12 +59,13 @@ module Rake
|
|
|
58
59
|
+ - & |
|
|
59
60
|
]
|
|
60
61
|
|
|
61
|
-
DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).
|
|
62
|
+
DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).
|
|
63
|
+
map { |s| s.to_s }.sort.uniq
|
|
62
64
|
|
|
63
65
|
# Now do the delegation.
|
|
64
|
-
DELEGATING_METHODS.
|
|
66
|
+
DELEGATING_METHODS.each do |sym|
|
|
65
67
|
if SPECIAL_RETURN.include?(sym)
|
|
66
|
-
ln = __LINE__+1
|
|
68
|
+
ln = __LINE__ + 1
|
|
67
69
|
class_eval %{
|
|
68
70
|
def #{sym}(*args, &block)
|
|
69
71
|
resolve
|
|
@@ -72,7 +74,7 @@ module Rake
|
|
|
72
74
|
end
|
|
73
75
|
}, __FILE__, ln
|
|
74
76
|
else
|
|
75
|
-
ln = __LINE__+1
|
|
77
|
+
ln = __LINE__ + 1
|
|
76
78
|
class_eval %{
|
|
77
79
|
def #{sym}(*args, &block)
|
|
78
80
|
resolve
|
|
@@ -149,10 +151,8 @@ module Rake
|
|
|
149
151
|
patterns.each do |pat|
|
|
150
152
|
@exclude_patterns << pat
|
|
151
153
|
end
|
|
152
|
-
if block_given?
|
|
153
|
-
|
|
154
|
-
end
|
|
155
|
-
resolve_exclude if ! @pending
|
|
154
|
+
@exclude_procs << block if block_given?
|
|
155
|
+
resolve_exclude unless @pending
|
|
156
156
|
self
|
|
157
157
|
end
|
|
158
158
|
|
|
@@ -219,7 +219,7 @@ module Rake
|
|
|
219
219
|
private :resolve_add
|
|
220
220
|
|
|
221
221
|
def resolve_exclude
|
|
222
|
-
reject! { |fn|
|
|
222
|
+
reject! { |fn| excluded_from_list?(fn) }
|
|
223
223
|
self
|
|
224
224
|
end
|
|
225
225
|
private :resolve_exclude
|
|
@@ -231,7 +231,7 @@ module Rake
|
|
|
231
231
|
# FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
|
|
232
232
|
#
|
|
233
233
|
def sub(pat, rep)
|
|
234
|
-
inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) }
|
|
234
|
+
inject(FileList.new) { |res, fn| res << fn.sub(pat, rep) }
|
|
235
235
|
end
|
|
236
236
|
|
|
237
237
|
# Return a new FileList with the results of running +gsub+ against each
|
|
@@ -242,18 +242,18 @@ module Rake
|
|
|
242
242
|
# => ['lib\\test\\file', 'x\\y']
|
|
243
243
|
#
|
|
244
244
|
def gsub(pat, rep)
|
|
245
|
-
inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) }
|
|
245
|
+
inject(FileList.new) { |res, fn| res << fn.gsub(pat, rep) }
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
# Same as +sub+ except that the original file list is modified.
|
|
249
249
|
def sub!(pat, rep)
|
|
250
|
-
each_with_index { |fn, i| self[i] = fn.sub(pat,rep) }
|
|
250
|
+
each_with_index { |fn, i| self[i] = fn.sub(pat, rep) }
|
|
251
251
|
self
|
|
252
252
|
end
|
|
253
253
|
|
|
254
254
|
# Same as +gsub+ except that the original file list is modified.
|
|
255
255
|
def gsub!(pat, rep)
|
|
256
|
-
each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }
|
|
256
|
+
each_with_index { |fn, i| self[i] = fn.gsub(pat, rep) }
|
|
257
257
|
self
|
|
258
258
|
end
|
|
259
259
|
|
|
@@ -341,13 +341,19 @@ module Rake
|
|
|
341
341
|
# Add matching glob patterns.
|
|
342
342
|
def add_matching(pattern)
|
|
343
343
|
FileList.glob(pattern).each do |fn|
|
|
344
|
-
self << fn unless
|
|
344
|
+
self << fn unless excluded_from_list?(fn)
|
|
345
345
|
end
|
|
346
346
|
end
|
|
347
347
|
private :add_matching
|
|
348
348
|
|
|
349
|
-
# Should the given file name be excluded?
|
|
350
|
-
|
|
349
|
+
# Should the given file name be excluded from the list?
|
|
350
|
+
#
|
|
351
|
+
# NOTE: This method was formally named "exclude?", but Rails
|
|
352
|
+
# introduced an exclude? method as an array method and setup a
|
|
353
|
+
# conflict with file list. We renamed the method to avoid
|
|
354
|
+
# confusion. If you were using "FileList#exclude?" in your user
|
|
355
|
+
# code, you will need to update.
|
|
356
|
+
def excluded_from_list?(fn)
|
|
351
357
|
return true if @exclude_patterns.any? do |pat|
|
|
352
358
|
case pat
|
|
353
359
|
when Regexp
|
data/lib/rake/file_task.rb
CHANGED
|
@@ -29,7 +29,7 @@ module Rake
|
|
|
29
29
|
|
|
30
30
|
# Are there any prerequisites with a later time than the given time stamp?
|
|
31
31
|
def out_of_date?(stamp)
|
|
32
|
-
@prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
|
|
32
|
+
@prerequisites.any? { |n| application[n, @scope].timestamp > stamp }
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# ----------------------------------------------------------------
|
|
@@ -44,4 +44,3 @@ module Rake
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
|
-
|
data/lib/rake/file_utils.rb
CHANGED
|
@@ -48,10 +48,12 @@ module FileUtils
|
|
|
48
48
|
|
|
49
49
|
def create_shell_runner(cmd) # :nodoc:
|
|
50
50
|
show_command = cmd.join(" ")
|
|
51
|
-
show_command = show_command[0,42] + "..." unless $trace
|
|
52
|
-
lambda
|
|
53
|
-
ok or
|
|
54
|
-
|
|
51
|
+
show_command = show_command[0, 42] + "..." unless $trace
|
|
52
|
+
lambda do |ok, status|
|
|
53
|
+
ok or
|
|
54
|
+
fail "Command failed with status (#{status.exitstatus}): " +
|
|
55
|
+
"[#{show_command}]"
|
|
56
|
+
end
|
|
55
57
|
end
|
|
56
58
|
private :create_shell_runner
|
|
57
59
|
|
|
@@ -74,9 +76,9 @@ module FileUtils
|
|
|
74
76
|
# Example:
|
|
75
77
|
# ruby %{-pe '$_.upcase!' <README}
|
|
76
78
|
#
|
|
77
|
-
def ruby(*args
|
|
79
|
+
def ruby(*args, &block)
|
|
78
80
|
options = (Hash === args.last) ? args.pop : {}
|
|
79
|
-
if args.length > 1
|
|
81
|
+
if args.length > 1
|
|
80
82
|
sh(*([RUBY] + args + [options]), &block)
|
|
81
83
|
else
|
|
82
84
|
sh("#{RUBY} #{args.first}", options, &block)
|
|
@@ -88,7 +90,7 @@ module FileUtils
|
|
|
88
90
|
# Attempt to do a normal file link, but fall back to a copy if the link
|
|
89
91
|
# fails.
|
|
90
92
|
def safe_ln(*args)
|
|
91
|
-
|
|
93
|
+
if ! LN_SUPPORTED[0]
|
|
92
94
|
cp(*args)
|
|
93
95
|
else
|
|
94
96
|
begin
|
data/lib/rake/file_utils_ext.rb
CHANGED
|
@@ -135,7 +135,8 @@ module Rake
|
|
|
135
135
|
optdecl.each do |name|
|
|
136
136
|
h.delete name
|
|
137
137
|
end
|
|
138
|
-
raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
|
|
138
|
+
raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
|
|
139
|
+
h.empty?
|
|
139
140
|
end
|
|
140
141
|
|
|
141
142
|
extend self
|
data/lib/rake/gempackagetask.rb
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
fail "ERROR: 'rake/gempackagetask' is obsolete and no longer supported.
|
|
1
|
+
fail "ERROR: 'rake/gempackagetask' is obsolete and no longer supported. " +
|
|
2
|
+
"Use 'rubygems/packagetask' instead."
|
|
@@ -3,44 +3,50 @@ module Rake
|
|
|
3
3
|
####################################################################
|
|
4
4
|
# InvocationChain tracks the chain of task invocations to detect
|
|
5
5
|
# circular dependencies.
|
|
6
|
-
class InvocationChain
|
|
7
|
-
def initialize(value, tail)
|
|
8
|
-
@value = value
|
|
9
|
-
@tail = tail
|
|
10
|
-
end
|
|
6
|
+
class InvocationChain < LinkedList
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
# Is the invocation already in the chain?
|
|
9
|
+
def member?(invocation)
|
|
10
|
+
head == invocation || tail.member?(invocation)
|
|
14
11
|
end
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
# Append an invocation to the chain of invocations. It is an error
|
|
14
|
+
# if the invocation already listed.
|
|
15
|
+
def append(invocation)
|
|
16
|
+
if member?(invocation)
|
|
17
|
+
fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}"
|
|
19
18
|
end
|
|
20
|
-
|
|
19
|
+
conj(invocation)
|
|
21
20
|
end
|
|
22
21
|
|
|
22
|
+
# Convert to string, ie: TOP => invocation => invocation
|
|
23
23
|
def to_s
|
|
24
|
-
"#{prefix}#{
|
|
24
|
+
"#{prefix}#{head}"
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
# Class level append.
|
|
28
|
+
def self.append(invocation, chain)
|
|
29
|
+
chain.append(invocation)
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
private
|
|
32
33
|
|
|
33
34
|
def prefix
|
|
34
|
-
"#{
|
|
35
|
+
"#{tail.to_s} => "
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
# Null object for an empty chain.
|
|
39
|
+
class EmptyInvocationChain < LinkedList::EmptyLinkedList
|
|
40
|
+
@parent = InvocationChain
|
|
41
|
+
|
|
38
42
|
def member?(obj)
|
|
39
43
|
false
|
|
40
44
|
end
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
|
|
46
|
+
def append(invocation)
|
|
47
|
+
conj(invocation)
|
|
43
48
|
end
|
|
49
|
+
|
|
44
50
|
def to_s
|
|
45
51
|
"TOP"
|
|
46
52
|
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
module Rake
|
|
2
|
+
|
|
3
|
+
# Polylithic linked list structure used to implement several data
|
|
4
|
+
# structures in Rake.
|
|
5
|
+
class LinkedList
|
|
6
|
+
include Enumerable
|
|
7
|
+
|
|
8
|
+
attr_reader :head, :tail
|
|
9
|
+
|
|
10
|
+
def initialize(head, tail=EMPTY)
|
|
11
|
+
@head = head
|
|
12
|
+
@tail = tail
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Polymorphically add a new element to the head of a list. The
|
|
16
|
+
# type of head node will be the same list type has the tail.
|
|
17
|
+
def conj(item)
|
|
18
|
+
self.class.cons(item, self)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Is the list empty?
|
|
22
|
+
def empty?
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Lists are structurally equivalent.
|
|
27
|
+
def ==(other)
|
|
28
|
+
current = self
|
|
29
|
+
while ! current.empty? && ! other.empty?
|
|
30
|
+
return false if current.head != other.head
|
|
31
|
+
current = current.tail
|
|
32
|
+
other = other.tail
|
|
33
|
+
end
|
|
34
|
+
current.empty? && other.empty?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Convert to string: LL(item, item...)
|
|
38
|
+
def to_s
|
|
39
|
+
items = map { |item| item.to_s }.join(", ")
|
|
40
|
+
"LL(#{items})"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Same as +to_s+, but with inspected items.
|
|
44
|
+
def inspect
|
|
45
|
+
items = map { |item| item.inspect }.join(", ")
|
|
46
|
+
"LL(#{items})"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# For each item in the list.
|
|
50
|
+
def each
|
|
51
|
+
current = self
|
|
52
|
+
while ! current.empty?
|
|
53
|
+
yield(current.head)
|
|
54
|
+
current = current.tail
|
|
55
|
+
end
|
|
56
|
+
self
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Make a list out of the given arguments. This method is
|
|
60
|
+
# polymorphic
|
|
61
|
+
def self.make(*args)
|
|
62
|
+
result = empty
|
|
63
|
+
args.reverse_each do |item|
|
|
64
|
+
result = cons(item, result)
|
|
65
|
+
end
|
|
66
|
+
result
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Cons a new head onto the tail list.
|
|
70
|
+
def self.cons(head, tail)
|
|
71
|
+
new(head, tail)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# The standard empty list class for the given LinkedList class.
|
|
75
|
+
def self.empty
|
|
76
|
+
self::EMPTY
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Represent an empty list, using the Null Object Pattern.
|
|
80
|
+
#
|
|
81
|
+
# When inheriting from the LinkedList class, you should implement
|
|
82
|
+
# a type specific Empty class as well. Make sure you set the class
|
|
83
|
+
# instance variable @parent to the assocated list class (this
|
|
84
|
+
# allows conj, cons and make to work polymorphically).
|
|
85
|
+
class EmptyLinkedList < LinkedList
|
|
86
|
+
@parent = LinkedList
|
|
87
|
+
|
|
88
|
+
def initialize
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def empty?
|
|
92
|
+
true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def self.cons(head, tail)
|
|
96
|
+
@parent.cons(head, tail)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
EMPTY = EmptyLinkedList.new
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
data/lib/rake/packagetask.rb
CHANGED
|
@@ -51,13 +51,16 @@ module Rake
|
|
|
51
51
|
# Directory used to store the package files (default is 'pkg').
|
|
52
52
|
attr_accessor :package_dir
|
|
53
53
|
|
|
54
|
-
# True if a gzipped tar file (tgz) should be produced (default is
|
|
54
|
+
# True if a gzipped tar file (tgz) should be produced (default is
|
|
55
|
+
# false).
|
|
55
56
|
attr_accessor :need_tar
|
|
56
57
|
|
|
57
|
-
# True if a gzipped tar file (tar.gz) should be produced (default
|
|
58
|
+
# True if a gzipped tar file (tar.gz) should be produced (default
|
|
59
|
+
# is false).
|
|
58
60
|
attr_accessor :need_tar_gz
|
|
59
61
|
|
|
60
|
-
# True if a bzip2'd tar file (tar.bz2) should be produced (default
|
|
62
|
+
# True if a bzip2'd tar file (tar.bz2) should be produced (default
|
|
63
|
+
# is false).
|
|
61
64
|
attr_accessor :need_tar_bz2
|
|
62
65
|
|
|
63
66
|
# True if a zip file should be produced (default is false)
|
|
@@ -121,7 +124,8 @@ module Rake
|
|
|
121
124
|
].each do |(need, file, flag)|
|
|
122
125
|
if need
|
|
123
126
|
task :package => ["#{package_dir}/#{file}"]
|
|
124
|
-
file "#{package_dir}/#{file}" =>
|
|
127
|
+
file "#{package_dir}/#{file}" =>
|
|
128
|
+
[package_dir_path] + package_files do
|
|
125
129
|
chdir(package_dir) do
|
|
126
130
|
sh %{#{@tar_command} #{flag}cvf #{file} #{package_name}}
|
|
127
131
|
end
|
|
@@ -131,7 +135,8 @@ module Rake
|
|
|
131
135
|
|
|
132
136
|
if need_zip
|
|
133
137
|
task :package => ["#{package_dir}/#{zip_file}"]
|
|
134
|
-
file "#{package_dir}/#{zip_file}" =>
|
|
138
|
+
file "#{package_dir}/#{zip_file}" =>
|
|
139
|
+
[package_dir_path] + package_files do
|
|
135
140
|
chdir(package_dir) do
|
|
136
141
|
sh %{#{@zip_command} -r #{zip_file} #{package_name}}
|
|
137
142
|
end
|
|
@@ -145,7 +150,7 @@ module Rake
|
|
|
145
150
|
@package_files.each do |fn|
|
|
146
151
|
f = File.join(package_dir_path, fn)
|
|
147
152
|
fdir = File.dirname(f)
|
|
148
|
-
mkdir_p(fdir)
|
|
153
|
+
mkdir_p(fdir) unless File.exist?(fdir)
|
|
149
154
|
if File.directory?(fn)
|
|
150
155
|
mkdir_p(f)
|
|
151
156
|
else
|
data/lib/rake/pseudo_status.rb
CHANGED
|
@@ -4,18 +4,23 @@ module Rake
|
|
|
4
4
|
# Exit status class for times the system just gives us a nil.
|
|
5
5
|
class PseudoStatus
|
|
6
6
|
attr_reader :exitstatus
|
|
7
|
+
|
|
7
8
|
def initialize(code=0)
|
|
8
9
|
@exitstatus = code
|
|
9
10
|
end
|
|
11
|
+
|
|
10
12
|
def to_i
|
|
11
13
|
@exitstatus << 8
|
|
12
14
|
end
|
|
15
|
+
|
|
13
16
|
def >>(n)
|
|
14
17
|
to_i >> n
|
|
15
18
|
end
|
|
19
|
+
|
|
16
20
|
def stopped?
|
|
17
21
|
false
|
|
18
22
|
end
|
|
23
|
+
|
|
19
24
|
def exited?
|
|
20
25
|
true
|
|
21
26
|
end
|
data/lib/rake/rdoctask.rb
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
fail "ERROR: 'rake/rdoctask' is obsolete and no longer supported.
|
|
1
|
+
fail "ERROR: 'rake/rdoctask' is obsolete and no longer supported. " +
|
|
2
|
+
"Use 'rdoc/task' (available in RDoc 2.4.2+) instead."
|
|
@@ -10,12 +10,14 @@ module Test # :nodoc:
|
|
|
10
10
|
def collect_file(name, suites, already_gathered) # :nodoc:
|
|
11
11
|
dir = File.dirname(File.expand_path(name))
|
|
12
12
|
$:.unshift(dir) unless $:.first == dir
|
|
13
|
-
if
|
|
13
|
+
if @req
|
|
14
14
|
@req.require(name)
|
|
15
15
|
else
|
|
16
16
|
require(name)
|
|
17
17
|
end
|
|
18
|
-
find_test_cases(already_gathered).each
|
|
18
|
+
find_test_cases(already_gathered).each do |t|
|
|
19
|
+
add_suite(suites, t.suite)
|
|
20
|
+
end
|
|
19
21
|
ensure
|
|
20
22
|
$:.delete_at $:.rindex(dir)
|
|
21
23
|
end
|
data/lib/rake/runtest.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Rake
|
|
|
6
6
|
include Test::Unit::Assertions
|
|
7
7
|
|
|
8
8
|
def run_tests(pattern='test/test*.rb', log_enabled=false)
|
|
9
|
-
FileList.glob(pattern).each
|
|
9
|
+
FileList.glob(pattern).each do |fn|
|
|
10
10
|
$stderr.puts fn if log_enabled
|
|
11
11
|
begin
|
|
12
12
|
require fn
|
|
@@ -15,7 +15,7 @@ module Rake
|
|
|
15
15
|
$stderr.puts ex.backtrace
|
|
16
16
|
assert false
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
extend self
|
data/lib/rake/scope.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Rake
|
|
2
|
+
class Scope < LinkedList
|
|
3
|
+
|
|
4
|
+
# Path for the scope.
|
|
5
|
+
def path
|
|
6
|
+
map { |item| item.to_s }.reverse.join(":")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Path for the scope + the named path.
|
|
10
|
+
def path_with_task_name(task_name)
|
|
11
|
+
"#{path}:#{task_name}"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Trim +n+ innermost scope levels from the scope. In no case will
|
|
15
|
+
# this trim beyond the toplevel scope.
|
|
16
|
+
def trim(n)
|
|
17
|
+
result = self
|
|
18
|
+
while n > 0 && ! result.empty?
|
|
19
|
+
result = result.tail
|
|
20
|
+
n -= 1
|
|
21
|
+
end
|
|
22
|
+
result
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Scope lists always end with an EmptyScope object. See Null
|
|
26
|
+
# Object Pattern)
|
|
27
|
+
class EmptyScope < EmptyLinkedList
|
|
28
|
+
@parent = Scope
|
|
29
|
+
|
|
30
|
+
def path
|
|
31
|
+
""
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def path_with_task_name(task_name)
|
|
35
|
+
task_name
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Singleton null object for an empty scope.
|
|
40
|
+
EMPTY = EmptyScope.new
|
|
41
|
+
end
|
|
42
|
+
end
|