rake 11.3.0 → 13.0.1
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 +5 -5
- data/.github/workflows/macos.yml +22 -0
- data/.github/workflows/ubuntu-rvm.yml +28 -0
- data/.github/workflows/ubuntu.yml +20 -0
- data/.github/workflows/windows.yml +20 -0
- data/CONTRIBUTING.rdoc +11 -4
- data/Gemfile +8 -1
- data/History.rdoc +171 -37
- data/README.rdoc +9 -11
- data/Rakefile +21 -13
- data/bin/bundle +105 -0
- data/bin/rake +29 -0
- data/bin/rdoc +29 -0
- data/bin/rubocop +29 -0
- data/doc/jamis.rb +1 -0
- data/doc/rake.1 +139 -124
- data/doc/rakefile.rdoc +2 -4
- data/exe/rake +1 -1
- data/lib/rake/application.rb +119 -79
- data/lib/rake/backtrace.rb +3 -2
- data/lib/rake/clean.rb +7 -5
- data/lib/rake/cloneable.rb +1 -0
- data/lib/rake/cpu_counter.rb +3 -2
- data/lib/rake/default_loader.rb +1 -0
- data/lib/rake/dsl_definition.rb +5 -4
- data/lib/rake/early_time.rb +1 -0
- data/lib/rake/ext/core.rb +1 -0
- data/lib/rake/ext/string.rb +22 -21
- data/lib/rake/file_creation_task.rb +4 -3
- data/lib/rake/file_list.rb +13 -14
- data/lib/rake/file_task.rb +12 -4
- data/lib/rake/file_utils.rb +17 -22
- data/lib/rake/file_utils_ext.rb +8 -18
- data/lib/rake/invocation_chain.rb +1 -0
- data/lib/rake/invocation_exception_mixin.rb +1 -0
- data/lib/rake/late_time.rb +2 -1
- data/lib/rake/linked_list.rb +1 -0
- data/lib/rake/loaders/makefile.rb +5 -4
- data/lib/rake/multi_task.rb +2 -1
- data/lib/rake/name_space.rb +1 -1
- data/lib/rake/packagetask.rb +28 -16
- data/lib/rake/phony.rb +2 -1
- data/lib/rake/private_reader.rb +1 -0
- data/lib/rake/promise.rb +13 -12
- data/lib/rake/pseudo_status.rb +1 -0
- data/lib/rake/rake_module.rb +30 -1
- data/lib/rake/rake_test_loader.rb +18 -12
- data/lib/rake/rule_recursion_overflow_error.rb +2 -1
- data/lib/rake/scope.rb +3 -2
- data/lib/rake/task.rb +70 -27
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +10 -4
- data/lib/rake/task_manager.rb +54 -39
- data/lib/rake/tasklib.rb +2 -1
- data/lib/rake/testtask.rb +28 -16
- data/lib/rake/thread_history_display.rb +4 -3
- data/lib/rake/thread_pool.rb +15 -14
- data/lib/rake/trace_output.rb +1 -0
- data/lib/rake/version.rb +3 -2
- data/lib/rake/win32.rb +9 -8
- data/lib/rake.rb +34 -33
- data/rake.gemspec +22 -9
- metadata +25 -108
- data/.gitignore +0 -14
- data/.rubocop.yml +0 -18
- data/.travis.yml +0 -28
- data/appveyor.yml +0 -22
- data/doc/release_notes/README.md +0 -4
- data/doc/release_notes/rake-0.4.14.rdoc +0 -23
- data/doc/release_notes/rake-0.4.15.rdoc +0 -35
- data/doc/release_notes/rake-0.5.0.rdoc +0 -53
- data/doc/release_notes/rake-0.5.3.rdoc +0 -78
- data/doc/release_notes/rake-0.5.4.rdoc +0 -46
- data/doc/release_notes/rake-0.6.0.rdoc +0 -141
- data/doc/release_notes/rake-0.7.0.rdoc +0 -119
- data/doc/release_notes/rake-0.7.1.rdoc +0 -59
- data/doc/release_notes/rake-0.7.2.rdoc +0 -121
- data/doc/release_notes/rake-0.7.3.rdoc +0 -47
- data/doc/release_notes/rake-0.8.0.rdoc +0 -114
- data/doc/release_notes/rake-0.8.2.rdoc +0 -165
- data/doc/release_notes/rake-0.8.3.rdoc +0 -112
- data/doc/release_notes/rake-0.8.4.rdoc +0 -147
- data/doc/release_notes/rake-0.8.5.rdoc +0 -53
- data/doc/release_notes/rake-0.8.6.rdoc +0 -37
- data/doc/release_notes/rake-0.8.7.rdoc +0 -55
- data/doc/release_notes/rake-0.9.0.rdoc +0 -112
- data/doc/release_notes/rake-0.9.1.rdoc +0 -52
- data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
- data/doc/release_notes/rake-0.9.2.rdoc +0 -49
- data/doc/release_notes/rake-0.9.3.rdoc +0 -102
- data/doc/release_notes/rake-0.9.4.rdoc +0 -60
- data/doc/release_notes/rake-0.9.5.rdoc +0 -55
- data/doc/release_notes/rake-0.9.6.rdoc +0 -64
- data/doc/release_notes/rake-10.0.0.rdoc +0 -178
- data/doc/release_notes/rake-10.0.1.rdoc +0 -58
- data/doc/release_notes/rake-10.0.2.rdoc +0 -53
- data/doc/release_notes/rake-10.0.3.rdoc +0 -191
- data/doc/release_notes/rake-10.1.0.rdoc +0 -61
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -137
- data/lib/rake/contrib/sshpublisher.rb +0 -60
- data/lib/rake/ext/pathname.rb +0 -25
data/lib/rake/backtrace.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Rake
|
|
2
3
|
module Backtrace # :nodoc: all
|
|
3
4
|
SYS_KEYS = RbConfig::CONFIG.keys.grep(/(?:[a-z]prefix|libdir)\z/)
|
|
@@ -5,12 +6,12 @@ module Rake
|
|
|
5
6
|
[ File.join(File.dirname(__FILE__), "..") ]
|
|
6
7
|
|
|
7
8
|
SUPPRESSED_PATHS = SYS_PATHS.
|
|
8
|
-
map { |s| s.
|
|
9
|
+
map { |s| s.tr("\\", "/") }.
|
|
9
10
|
map { |f| File.expand_path(f) }.
|
|
10
11
|
reject { |s| s.nil? || s =~ /^ *$/ }
|
|
11
12
|
SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|")
|
|
12
13
|
SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if
|
|
13
|
-
Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE ==
|
|
14
|
+
Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == "jruby"
|
|
14
15
|
|
|
15
16
|
SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i
|
|
16
17
|
|
data/lib/rake/clean.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
|
|
2
3
|
# two rake tasks (:clean and :clobber).
|
|
3
4
|
#
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
# The intent of this task is to return a project to its
|
|
12
13
|
# pristine, just unpacked state.
|
|
13
14
|
|
|
14
|
-
require
|
|
15
|
+
require "rake"
|
|
15
16
|
|
|
16
17
|
# :stopdoc:
|
|
17
18
|
|
|
@@ -27,9 +28,10 @@ module Rake
|
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
|
|
30
|
-
def cleanup(file_name, opts
|
|
31
|
+
def cleanup(file_name, **opts)
|
|
31
32
|
begin
|
|
32
|
-
|
|
33
|
+
opts = { verbose: Rake.application.options.trace }.merge(opts)
|
|
34
|
+
rm_r file_name, **opts
|
|
33
35
|
rescue StandardError => ex
|
|
34
36
|
puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name)
|
|
35
37
|
end
|
|
@@ -60,7 +62,7 @@ end
|
|
|
60
62
|
|
|
61
63
|
CLEAN = ::Rake::FileList["**/*~", "**/*.bak", "**/core"]
|
|
62
64
|
CLEAN.clear_exclude.exclude { |fn|
|
|
63
|
-
fn.pathmap("%f").downcase ==
|
|
65
|
+
fn.pathmap("%f").downcase == "core" && File.directory?(fn)
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
desc "Remove any temporary products."
|
|
@@ -71,6 +73,6 @@ end
|
|
|
71
73
|
CLOBBER = ::Rake::FileList.new
|
|
72
74
|
|
|
73
75
|
desc "Remove any generated files."
|
|
74
|
-
task :
|
|
76
|
+
task clobber: [:clean] do
|
|
75
77
|
Rake::Cleaner.cleanup_files(CLOBBER)
|
|
76
78
|
end
|
data/lib/rake/cloneable.rb
CHANGED
data/lib/rake/cpu_counter.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Rake
|
|
2
3
|
|
|
3
4
|
# Based on a script at:
|
|
@@ -14,7 +15,7 @@ module Rake
|
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
begin
|
|
17
|
-
require
|
|
18
|
+
require "etc"
|
|
18
19
|
rescue LoadError
|
|
19
20
|
else
|
|
20
21
|
if Etc.respond_to?(:nprocessors)
|
|
@@ -31,7 +32,7 @@ unless Rake::CpuCounter.method_defined?(:count)
|
|
|
31
32
|
require 'rbconfig'
|
|
32
33
|
|
|
33
34
|
def count
|
|
34
|
-
if
|
|
35
|
+
if RUBY_PLATFORM == 'java'
|
|
35
36
|
count_via_java_runtime
|
|
36
37
|
else
|
|
37
38
|
case RbConfig::CONFIG['host_os']
|
data/lib/rake/default_loader.rb
CHANGED
data/lib/rake/dsl_definition.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# Rake DSL functions.
|
|
2
|
-
require
|
|
3
|
+
require "rake/file_utils_ext"
|
|
3
4
|
|
|
4
5
|
module Rake
|
|
5
6
|
|
|
@@ -25,9 +26,9 @@ module Rake
|
|
|
25
26
|
private
|
|
26
27
|
|
|
27
28
|
# :call-seq:
|
|
28
|
-
# task
|
|
29
|
-
# task
|
|
30
|
-
# task
|
|
29
|
+
# task(task_name)
|
|
30
|
+
# task(task_name: dependencies)
|
|
31
|
+
# task(task_name, arguments => dependencies)
|
|
31
32
|
#
|
|
32
33
|
# Declare a basic task. The +task_name+ is always the first argument. If
|
|
33
34
|
# the task name contains a ":" it is defined in that namespace.
|
data/lib/rake/early_time.rb
CHANGED
data/lib/rake/ext/core.rb
CHANGED
data/lib/rake/ext/string.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "rake/ext/core"
|
|
2
3
|
|
|
3
4
|
class String
|
|
4
5
|
|
|
@@ -10,9 +11,9 @@ class String
|
|
|
10
11
|
# +ext+ is a user added method for the String class.
|
|
11
12
|
#
|
|
12
13
|
# This String extension comes from Rake
|
|
13
|
-
def ext(newext=
|
|
14
|
-
return self.dup if [
|
|
15
|
-
if newext !=
|
|
14
|
+
def ext(newext="")
|
|
15
|
+
return self.dup if [".", ".."].include? self
|
|
16
|
+
if newext != ""
|
|
16
17
|
newext = "." + newext unless newext =~ /^\./
|
|
17
18
|
end
|
|
18
19
|
self.chomp(File.extname(self)) << newext
|
|
@@ -26,8 +27,8 @@ class String
|
|
|
26
27
|
def pathmap_explode
|
|
27
28
|
head, tail = File.split(self)
|
|
28
29
|
return [self] if head == self
|
|
29
|
-
return [tail] if head ==
|
|
30
|
-
return [head, tail] if head ==
|
|
30
|
+
return [tail] if head == "." || tail == "/"
|
|
31
|
+
return [head, tail] if head == "/"
|
|
31
32
|
return head.pathmap_explode + [tail]
|
|
32
33
|
end
|
|
33
34
|
protected :pathmap_explode
|
|
@@ -57,15 +58,15 @@ class String
|
|
|
57
58
|
# This String extension comes from Rake
|
|
58
59
|
def pathmap_replace(patterns, &block)
|
|
59
60
|
result = self
|
|
60
|
-
patterns.split(
|
|
61
|
-
pattern, replacement = pair.split(
|
|
61
|
+
patterns.split(";").each do |pair|
|
|
62
|
+
pattern, replacement = pair.split(",")
|
|
62
63
|
pattern = Regexp.new(pattern)
|
|
63
|
-
if replacement ==
|
|
64
|
+
if replacement == "*" && block_given?
|
|
64
65
|
result = result.sub(pattern, &block)
|
|
65
66
|
elsif replacement
|
|
66
67
|
result = result.sub(pattern, replacement)
|
|
67
68
|
else
|
|
68
|
-
result = result.sub(pattern,
|
|
69
|
+
result = result.sub(pattern, "")
|
|
69
70
|
end
|
|
70
71
|
end
|
|
71
72
|
result
|
|
@@ -136,32 +137,32 @@ class String
|
|
|
136
137
|
# This String extension comes from Rake
|
|
137
138
|
def pathmap(spec=nil, &block)
|
|
138
139
|
return self if spec.nil?
|
|
139
|
-
result =
|
|
140
|
+
result = "".dup
|
|
140
141
|
spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
|
|
141
142
|
case frag
|
|
142
|
-
when
|
|
143
|
+
when "%f"
|
|
143
144
|
result << File.basename(self)
|
|
144
|
-
when
|
|
145
|
+
when "%n"
|
|
145
146
|
result << File.basename(self).ext
|
|
146
|
-
when
|
|
147
|
+
when "%d"
|
|
147
148
|
result << File.dirname(self)
|
|
148
|
-
when
|
|
149
|
+
when "%x"
|
|
149
150
|
result << File.extname(self)
|
|
150
|
-
when
|
|
151
|
+
when "%X"
|
|
151
152
|
result << self.ext
|
|
152
|
-
when
|
|
153
|
+
when "%p"
|
|
153
154
|
result << self
|
|
154
|
-
when
|
|
155
|
+
when "%s"
|
|
155
156
|
result << (File::ALT_SEPARATOR || File::SEPARATOR)
|
|
156
|
-
when
|
|
157
|
+
when "%-"
|
|
157
158
|
# do nothing
|
|
158
|
-
when
|
|
159
|
+
when "%%"
|
|
159
160
|
result << "%"
|
|
160
161
|
when /%(-?\d+)d/
|
|
161
162
|
result << pathmap_partial($1.to_i)
|
|
162
163
|
when /^%\{([^}]*)\}(\d*[dpfnxX])/
|
|
163
164
|
patterns, operator = $1, $2
|
|
164
|
-
result << pathmap(
|
|
165
|
+
result << pathmap("%" + operator).pathmap_replace(patterns, &block)
|
|
165
166
|
when /^%/
|
|
166
167
|
fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
|
|
167
168
|
else
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "rake/file_task"
|
|
3
|
+
require "rake/early_time"
|
|
3
4
|
|
|
4
5
|
module Rake
|
|
5
6
|
|
|
@@ -11,7 +12,7 @@ module Rake
|
|
|
11
12
|
class FileCreationTask < FileTask
|
|
12
13
|
# Is this file task needed? Yes if it doesn't exist.
|
|
13
14
|
def needed?
|
|
14
|
-
!
|
|
15
|
+
!File.exist?(name)
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
# Time stamp for file creation task. This time stamp is earlier
|
data/lib/rake/file_list.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
require
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "rake/cloneable"
|
|
3
|
+
require "rake/file_utils_ext"
|
|
4
|
+
require "rake/ext/string"
|
|
4
5
|
|
|
5
6
|
module Rake
|
|
6
7
|
|
|
@@ -40,8 +41,7 @@ module Rake
|
|
|
40
41
|
|
|
41
42
|
# List of array methods (that are not in +Object+) that need to be
|
|
42
43
|
# delegated.
|
|
43
|
-
ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).
|
|
44
|
-
map { |n| n.to_s }
|
|
44
|
+
ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map(&:to_s)
|
|
45
45
|
|
|
46
46
|
# List of additional methods that must be delegated.
|
|
47
47
|
MUST_DEFINE = %w[inspect <=>]
|
|
@@ -58,8 +58,7 @@ module Rake
|
|
|
58
58
|
+ - & |
|
|
59
59
|
]
|
|
60
60
|
|
|
61
|
-
DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).
|
|
62
|
-
map { |s| s.to_s }.sort.uniq
|
|
61
|
+
DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).map(&:to_s).sort.uniq
|
|
63
62
|
|
|
64
63
|
# Now do the delegation.
|
|
65
64
|
DELEGATING_METHODS.each do |sym|
|
|
@@ -282,7 +281,7 @@ module Rake
|
|
|
282
281
|
# array.collect { |item| item.ext(newext) }
|
|
283
282
|
#
|
|
284
283
|
# +ext+ is a user added method for the Array class.
|
|
285
|
-
def ext(newext=
|
|
284
|
+
def ext(newext="")
|
|
286
285
|
collect { |fn| fn.ext(newext) }
|
|
287
286
|
end
|
|
288
287
|
|
|
@@ -295,7 +294,7 @@ module Rake
|
|
|
295
294
|
matched = 0
|
|
296
295
|
each do |fn|
|
|
297
296
|
begin
|
|
298
|
-
open(fn, "r", *options) do |inf|
|
|
297
|
+
File.open(fn, "r", *options) do |inf|
|
|
299
298
|
count = 0
|
|
300
299
|
inf.each do |line|
|
|
301
300
|
count += 1
|
|
@@ -319,14 +318,14 @@ module Rake
|
|
|
319
318
|
# Return a new file list that only contains file names from the current
|
|
320
319
|
# file list that exist on the file system.
|
|
321
320
|
def existing
|
|
322
|
-
select { |fn| File.exist?(fn) }
|
|
321
|
+
select { |fn| File.exist?(fn) }.uniq
|
|
323
322
|
end
|
|
324
323
|
|
|
325
324
|
# Modify the current file list so that it contains only file name that
|
|
326
325
|
# exist on the file system.
|
|
327
326
|
def existing!
|
|
328
327
|
resolve
|
|
329
|
-
@items = @items.select { |fn| File.exist?(fn) }
|
|
328
|
+
@items = @items.select { |fn| File.exist?(fn) }.uniq
|
|
330
329
|
self
|
|
331
330
|
end
|
|
332
331
|
|
|
@@ -344,7 +343,7 @@ module Rake
|
|
|
344
343
|
# Convert a FileList to a string by joining all elements with a space.
|
|
345
344
|
def to_s
|
|
346
345
|
resolve
|
|
347
|
-
self.join(
|
|
346
|
+
self.join(" ")
|
|
348
347
|
end
|
|
349
348
|
|
|
350
349
|
# Add matching glob patterns.
|
|
@@ -386,7 +385,7 @@ module Rake
|
|
|
386
385
|
/~$/
|
|
387
386
|
]
|
|
388
387
|
DEFAULT_IGNORE_PROCS = [
|
|
389
|
-
proc { |fn| fn =~ /(^|[\/\\])core$/ && !
|
|
388
|
+
proc { |fn| fn =~ /(^|[\/\\])core$/ && !File.directory?(fn) }
|
|
390
389
|
]
|
|
391
390
|
|
|
392
391
|
def import(array) # :nodoc:
|
|
@@ -418,7 +417,7 @@ module Rake
|
|
|
418
417
|
# Yield each file or directory component.
|
|
419
418
|
def each_dir_parent(dir) # :nodoc:
|
|
420
419
|
old_length = nil
|
|
421
|
-
while dir !=
|
|
420
|
+
while dir != "." && dir.length != old_length
|
|
422
421
|
yield(dir)
|
|
423
422
|
old_length = dir.length
|
|
424
423
|
dir = File.dirname(dir)
|
data/lib/rake/file_task.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "rake/task"
|
|
3
|
+
require "rake/early_time"
|
|
3
4
|
|
|
4
5
|
module Rake
|
|
5
6
|
|
|
@@ -13,7 +14,7 @@ module Rake
|
|
|
13
14
|
# Is this file task needed? Yes if it doesn't exist, or if its time stamp
|
|
14
15
|
# is out of date.
|
|
15
16
|
def needed?
|
|
16
|
-
!
|
|
17
|
+
!File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
# Time stamp for file task.
|
|
@@ -29,7 +30,14 @@ module Rake
|
|
|
29
30
|
|
|
30
31
|
# Are there any prerequisites with a later time than the given time stamp?
|
|
31
32
|
def out_of_date?(stamp)
|
|
32
|
-
|
|
33
|
+
all_prerequisite_tasks.any? { |prereq|
|
|
34
|
+
prereq_task = application[prereq, @scope]
|
|
35
|
+
if prereq_task.instance_of?(Rake::FileTask)
|
|
36
|
+
prereq_task.timestamp > stamp || @application.options.build_all
|
|
37
|
+
else
|
|
38
|
+
prereq_task.timestamp > stamp
|
|
39
|
+
end
|
|
40
|
+
}
|
|
33
41
|
end
|
|
34
42
|
|
|
35
43
|
# ----------------------------------------------------------------
|
data/lib/rake/file_utils.rb
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "rbconfig"
|
|
3
|
+
require "fileutils"
|
|
3
4
|
|
|
4
5
|
#--
|
|
5
6
|
# This a FileUtils extension that defines several additional commands to be
|
|
6
7
|
# added to the FileUtils utility functions.
|
|
7
8
|
module FileUtils
|
|
8
9
|
# Path to the currently running Ruby program
|
|
9
|
-
RUBY = ENV[
|
|
10
|
-
RbConfig::CONFIG[
|
|
11
|
-
RbConfig::CONFIG[
|
|
10
|
+
RUBY = ENV["RUBY"] || File.join(
|
|
11
|
+
RbConfig::CONFIG["bindir"],
|
|
12
|
+
RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]).
|
|
12
13
|
sub(/.*\s.*/m, '"\&"')
|
|
13
14
|
|
|
14
|
-
OPT_TABLE['sh'] = %w(noop verbose)
|
|
15
|
-
OPT_TABLE['ruby'] = %w(noop verbose)
|
|
16
|
-
|
|
17
15
|
# Run the system command +cmd+. If multiple arguments are given the command
|
|
18
16
|
# is run directly (without the shell, same semantics as Kernel::exec and
|
|
19
17
|
# Kernel::system).
|
|
@@ -37,7 +35,7 @@ module FileUtils
|
|
|
37
35
|
#
|
|
38
36
|
# # check exit status after command runs
|
|
39
37
|
# sh %{grep pattern file} do |ok, res|
|
|
40
|
-
# if !
|
|
38
|
+
# if !ok
|
|
41
39
|
# puts "pattern not found (status = #{res.exitstatus})"
|
|
42
40
|
# end
|
|
43
41
|
# end
|
|
@@ -53,7 +51,7 @@ module FileUtils
|
|
|
53
51
|
Rake.rake_output_message sh_show_command cmd if verbose
|
|
54
52
|
|
|
55
53
|
unless noop
|
|
56
|
-
res = system(*cmd, options)
|
|
54
|
+
res = (Hash === cmd.last) ? system(*cmd) : system(*cmd, options)
|
|
57
55
|
status = $?
|
|
58
56
|
status = Rake::PseudoStatus.new(1) if !res && status.nil?
|
|
59
57
|
shell_runner.call(res, status)
|
|
@@ -99,12 +97,11 @@ module FileUtils
|
|
|
99
97
|
# Example:
|
|
100
98
|
# ruby %{-pe '$_.upcase!' <README}
|
|
101
99
|
#
|
|
102
|
-
def ruby(*args, &block)
|
|
103
|
-
options = (Hash === args.last) ? args.pop : {}
|
|
100
|
+
def ruby(*args, **options, &block)
|
|
104
101
|
if args.length > 1
|
|
105
|
-
sh(
|
|
102
|
+
sh(RUBY, *args, **options, &block)
|
|
106
103
|
else
|
|
107
|
-
sh("#{RUBY} #{args.first}", options, &block)
|
|
104
|
+
sh("#{RUBY} #{args.first}", **options, &block)
|
|
108
105
|
end
|
|
109
106
|
end
|
|
110
107
|
|
|
@@ -112,17 +109,15 @@ module FileUtils
|
|
|
112
109
|
|
|
113
110
|
# Attempt to do a normal file link, but fall back to a copy if the link
|
|
114
111
|
# fails.
|
|
115
|
-
def safe_ln(*args)
|
|
116
|
-
if
|
|
117
|
-
cp(*args)
|
|
118
|
-
else
|
|
112
|
+
def safe_ln(*args, **options)
|
|
113
|
+
if LN_SUPPORTED[0]
|
|
119
114
|
begin
|
|
120
|
-
ln(*args)
|
|
115
|
+
return options.empty? ? ln(*args) : ln(*args, **options)
|
|
121
116
|
rescue StandardError, NotImplementedError
|
|
122
117
|
LN_SUPPORTED[0] = false
|
|
123
|
-
cp(*args)
|
|
124
118
|
end
|
|
125
119
|
end
|
|
120
|
+
options.empty? ? cp(*args) : cp(*args, **options)
|
|
126
121
|
end
|
|
127
122
|
|
|
128
123
|
# Split a file path into individual directory names.
|
|
@@ -132,8 +127,8 @@ module FileUtils
|
|
|
132
127
|
#
|
|
133
128
|
def split_all(path)
|
|
134
129
|
head, tail = File.split(path)
|
|
135
|
-
return [tail] if head ==
|
|
136
|
-
return [head, tail] if head ==
|
|
130
|
+
return [tail] if head == "." || tail == "/"
|
|
131
|
+
return [head, tail] if head == "/"
|
|
137
132
|
return split_all(head) + [tail]
|
|
138
133
|
end
|
|
139
134
|
end
|