rake 0.9.2 → 13.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.rdoc +43 -0
- data/Gemfile +10 -0
- data/History.rdoc +2386 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +64 -109
- data/Rakefile +22 -386
- data/bin/bundle +105 -0
- data/bin/console +7 -0
- data/bin/rake +20 -23
- data/bin/rdoc +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +6 -0
- data/doc/command_line_usage.rdoc +65 -21
- data/doc/glossary.rdoc +40 -49
- data/doc/jamis.rb +1 -0
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +127 -62
- data/exe/rake +27 -0
- data/lib/rake.rb +37 -31
- data/lib/rake/application.rb +507 -272
- data/lib/rake/backtrace.rb +24 -0
- data/lib/rake/clean.rb +55 -8
- data/lib/rake/cloneable.rb +11 -19
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +5 -0
- data/lib/rake/dsl_definition.rb +74 -46
- data/lib/rake/early_time.rb +5 -1
- data/lib/rake/ext/core.rb +5 -6
- data/lib/rake/ext/string.rb +61 -52
- data/lib/rake/file_creation_task.rb +4 -3
- data/lib/rake/file_list.rb +81 -49
- data/lib/rake/file_task.rb +15 -8
- data/lib/rake/file_utils.rb +69 -47
- data/lib/rake/file_utils_ext.rb +18 -26
- data/lib/rake/invocation_chain.rb +25 -19
- data/lib/rake/invocation_exception_mixin.rb +1 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +23 -9
- data/lib/rake/multi_task.rb +4 -6
- data/lib/rake/name_space.rb +36 -23
- data/lib/rake/packagetask.rb +71 -34
- data/lib/rake/phony.rb +16 -0
- data/lib/rake/private_reader.rb +21 -0
- data/lib/rake/promise.rb +100 -0
- data/lib/rake/pseudo_status.rb +8 -2
- data/lib/rake/rake_module.rb +41 -3
- data/lib/rake/rake_test_loader.rb +21 -7
- data/lib/rake/rule_recursion_overflow_error.rb +2 -2
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +186 -79
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +50 -15
- data/lib/rake/task_manager.rb +89 -65
- data/lib/rake/tasklib.rb +2 -12
- data/lib/rake/testtask.rb +61 -63
- data/lib/rake/thread_history_display.rb +49 -0
- data/lib/rake/thread_pool.rb +163 -0
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +7 -7
- data/lib/rake/win32.rb +14 -18
- data/rake.gemspec +43 -0
- metadata +82 -221
- data/.gemtest +0 -0
- data/CHANGES +0 -509
- data/RRR +0 -9
- data/TODO +0 -20
- data/doc/rake.1.gz +0 -0
- 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 -55
- 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.rdoc +0 -49
- data/install.rb +0 -90
- data/lib/rake/alt_system.rb +0 -109
- data/lib/rake/classic_namespace.rb +0 -9
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -150
- data/lib/rake/contrib/publisher.rb +0 -69
- data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
- data/lib/rake/contrib/sshpublisher.rb +0 -45
- data/lib/rake/contrib/sys.rb +0 -191
- data/lib/rake/ext/module.rb +0 -39
- data/lib/rake/ext/time.rb +0 -14
- data/lib/rake/gempackagetask.rb +0 -13
- data/lib/rake/pathmap.rb +0 -1
- data/lib/rake/rdoctask.rb +0 -230
- data/lib/rake/ruby182_test_unit_fix.rb +0 -25
- data/lib/rake/runtest.rb +0 -21
- data/test/check_expansion.rb +0 -5
- data/test/check_no_expansion.rb +0 -5
- data/test/data/access/Rakefile +0 -35
- data/test/data/chains/Rakefile +0 -15
- data/test/data/comments/Rakefile +0 -18
- data/test/data/default/Rakefile +0 -17
- data/test/data/deprecated_import/Rakefile +0 -1
- data/test/data/dryrun/Rakefile +0 -22
- data/test/data/extra/Rakefile +0 -1
- data/test/data/file_creation_task/Rakefile +0 -31
- data/test/data/imports/Rakefile +0 -19
- data/test/data/imports/deps.mf +0 -1
- data/test/data/multidesc/Rakefile +0 -15
- data/test/data/namespace/Rakefile +0 -64
- data/test/data/rakelib/test1.rb +0 -4
- data/test/data/rbext/rakefile.rb +0 -3
- data/test/data/sample.mf +0 -14
- data/test/data/statusreturn/Rakefile +0 -6
- data/test/data/unittest/Rakefile +0 -1
- data/test/data/verbose/Rakefile +0 -34
- data/test/file_creation.rb +0 -34
- data/test/helper.rb +0 -44
- data/test/in_environment.rb +0 -35
- data/test/reqfile.rb +0 -3
- data/test/reqfile2.rb +0 -3
- data/test/shellcommand.rb +0 -3
- data/test/test_rake.rb +0 -38
- data/test/test_rake_application.rb +0 -364
- data/test/test_rake_application_options.rb +0 -382
- data/test/test_rake_clean.rb +0 -12
- data/test/test_rake_definitions.rb +0 -80
- data/test/test_rake_directory_task.rb +0 -55
- data/test/test_rake_dsl.rb +0 -73
- data/test/test_rake_early_time.rb +0 -31
- data/test/test_rake_extension.rb +0 -59
- data/test/test_rake_file_creation_task.rb +0 -62
- data/test/test_rake_file_list.rb +0 -633
- data/test/test_rake_file_list_path_map.rb +0 -8
- data/test/test_rake_file_task.rb +0 -104
- data/test/test_rake_file_utils.rb +0 -252
- data/test/test_rake_ftp_file.rb +0 -59
- data/test/test_rake_functional.rb +0 -468
- data/test/test_rake_invocation_chain.rb +0 -52
- data/test/test_rake_makefile_loader.rb +0 -23
- data/test/test_rake_multi_task.rb +0 -51
- data/test/test_rake_name_space.rb +0 -43
- data/test/test_rake_package_task.rb +0 -78
- data/test/test_rake_path_map.rb +0 -157
- data/test/test_rake_path_map_explode.rb +0 -31
- data/test/test_rake_path_map_partial.rb +0 -18
- data/test/test_rake_pseudo_status.rb +0 -20
- data/test/test_rake_rdoc_task.rb +0 -81
- data/test/test_rake_require.rb +0 -35
- data/test/test_rake_rules.rb +0 -346
- data/test/test_rake_task.rb +0 -271
- data/test/test_rake_task_argument_parsing.rb +0 -116
- data/test/test_rake_task_arguments.rb +0 -86
- data/test/test_rake_task_lib.rb +0 -9
- data/test/test_rake_task_manager.rb +0 -145
- data/test/test_rake_task_manager_argument_resolution.rb +0 -36
- data/test/test_rake_task_with_arguments.rb +0 -162
- data/test/test_rake_test_task.rb +0 -122
- data/test/test_rake_top_level_functions.rb +0 -76
- data/test/test_rake_win32.rb +0 -83
- data/test/test_sys.rb +0 -20
data/lib/rake/task_arguments.rb
CHANGED
@@ -1,30 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
3
|
|
3
|
-
|
4
|
+
##
|
4
5
|
# TaskArguments manage the arguments passed to a task.
|
5
6
|
#
|
6
7
|
class TaskArguments
|
7
8
|
include Enumerable
|
8
9
|
|
10
|
+
# Argument names
|
9
11
|
attr_reader :names
|
10
12
|
|
11
|
-
# Create a TaskArgument object with a list of
|
12
|
-
#
|
13
|
-
# :values). :parent is the parent argument object.
|
13
|
+
# Create a TaskArgument object with a list of argument +names+ and a set
|
14
|
+
# of associated +values+. +parent+ is the parent argument object.
|
14
15
|
def initialize(names, values, parent=nil)
|
15
16
|
@names = names
|
16
17
|
@parent = parent
|
17
18
|
@hash = {}
|
19
|
+
@values = values
|
18
20
|
names.each_with_index { |name, i|
|
19
|
-
|
21
|
+
next if values[i].nil? || values[i] == ""
|
22
|
+
@hash[name.to_sym] = values[i]
|
20
23
|
}
|
21
24
|
end
|
22
25
|
|
26
|
+
# Retrieve the complete array of sequential values
|
27
|
+
def to_a
|
28
|
+
@values.dup
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieve the list of values not associated with named arguments
|
32
|
+
def extras
|
33
|
+
@values[@names.length..-1] || []
|
34
|
+
end
|
35
|
+
|
23
36
|
# Create a new argument scope using the prerequisite argument
|
24
37
|
# names.
|
25
38
|
def new_scope(names)
|
26
|
-
values = names.
|
27
|
-
self.class.new(names, values, self)
|
39
|
+
values = names.map { |n| self[n] }
|
40
|
+
self.class.new(names, values + extras, self)
|
28
41
|
end
|
29
42
|
|
30
43
|
# Find an argument value by name or index.
|
@@ -39,29 +52,51 @@ module Rake
|
|
39
52
|
@hash = defaults.merge(@hash)
|
40
53
|
end
|
41
54
|
|
55
|
+
# Enumerates the arguments and their values
|
42
56
|
def each(&block)
|
43
57
|
@hash.each(&block)
|
44
58
|
end
|
45
59
|
|
46
|
-
|
60
|
+
# Extracts the argument values at +keys+
|
61
|
+
def values_at(*keys)
|
62
|
+
keys.map { |k| lookup(k) }
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns the value of the given argument via method_missing
|
66
|
+
def method_missing(sym, *args)
|
47
67
|
lookup(sym.to_sym)
|
48
68
|
end
|
49
69
|
|
70
|
+
# Returns a Hash of arguments and their values
|
50
71
|
def to_hash
|
51
|
-
@hash
|
72
|
+
@hash.dup
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_s # :nodoc:
|
76
|
+
inspect
|
77
|
+
end
|
78
|
+
|
79
|
+
def inspect # :nodoc:
|
80
|
+
inspection = @hash.map do |k,v|
|
81
|
+
"#{k.to_s}: #{v.to_s}"
|
82
|
+
end.join(", ")
|
83
|
+
|
84
|
+
"#<#{self.class} #{inspection}>"
|
52
85
|
end
|
53
86
|
|
54
|
-
|
55
|
-
|
87
|
+
# Returns true if +key+ is one of the arguments
|
88
|
+
def has_key?(key)
|
89
|
+
@hash.has_key?(key)
|
56
90
|
end
|
91
|
+
alias key? has_key?
|
57
92
|
|
58
|
-
def
|
59
|
-
|
93
|
+
def fetch(*args, &block)
|
94
|
+
@hash.fetch(*args, &block)
|
60
95
|
end
|
61
96
|
|
62
97
|
protected
|
63
98
|
|
64
|
-
def lookup(name)
|
99
|
+
def lookup(name) # :nodoc:
|
65
100
|
if @hash.has_key?(name)
|
66
101
|
@hash[name]
|
67
102
|
elsif @parent
|
@@ -70,5 +105,5 @@ module Rake
|
|
70
105
|
end
|
71
106
|
end
|
72
107
|
|
73
|
-
EMPTY_TASK_ARGS = TaskArguments.new([], [])
|
108
|
+
EMPTY_TASK_ARGS = TaskArguments.new([], []) # :nodoc:
|
74
109
|
end
|
data/lib/rake/task_manager.rb
CHANGED
@@ -1,37 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
3
|
|
3
4
|
# The TaskManager module is a mixin for managing tasks.
|
4
5
|
module TaskManager
|
5
6
|
# Track the last comment made in the Rakefile.
|
6
7
|
attr_accessor :last_description
|
7
|
-
alias :last_comment :last_description # Backwards compatibility
|
8
8
|
|
9
|
-
def initialize
|
9
|
+
def initialize # :nodoc:
|
10
10
|
super
|
11
11
|
@tasks = Hash.new
|
12
12
|
@rules = Array.new
|
13
|
-
@scope =
|
13
|
+
@scope = Scope.make
|
14
14
|
@last_description = nil
|
15
15
|
end
|
16
16
|
|
17
|
-
def create_rule(*args, &block)
|
18
|
-
pattern,
|
19
|
-
pattern = Regexp.new(Regexp.quote(pattern) +
|
20
|
-
@rules << [pattern, deps, block]
|
17
|
+
def create_rule(*args, &block) # :nodoc:
|
18
|
+
pattern, args, deps, order_only = resolve_args(args)
|
19
|
+
pattern = Regexp.new(Regexp.quote(pattern) + "$") if String === pattern
|
20
|
+
@rules << [pattern, args, deps, order_only, block]
|
21
21
|
end
|
22
22
|
|
23
|
-
def define_task(task_class, *args, &block)
|
24
|
-
task_name, arg_names, deps = resolve_args(args)
|
23
|
+
def define_task(task_class, *args, &block) # :nodoc:
|
24
|
+
task_name, arg_names, deps, order_only = resolve_args(args)
|
25
|
+
|
26
|
+
original_scope = @scope
|
27
|
+
if String === task_name and
|
28
|
+
not task_class.ancestors.include? Rake::FileTask
|
29
|
+
task_name, *definition_scope = *(task_name.split(":").reverse)
|
30
|
+
@scope = Scope.make(*(definition_scope + @scope.to_a))
|
31
|
+
end
|
32
|
+
|
25
33
|
task_name = task_class.scope_name(@scope, task_name)
|
26
|
-
deps = [deps] unless deps.respond_to?(:to_ary)
|
27
|
-
deps = deps.collect {|d| d.to_s }
|
28
34
|
task = intern(task_class, task_name)
|
29
35
|
task.set_arg_names(arg_names) unless arg_names.empty?
|
30
36
|
if Rake::TaskManager.record_task_metadata
|
31
37
|
add_location(task)
|
32
38
|
task.add_description(get_description(task))
|
33
39
|
end
|
34
|
-
task.enhance(deps, &block)
|
40
|
+
task.enhance(Task.format_deps(deps), &block)
|
41
|
+
task | order_only unless order_only.nil?
|
42
|
+
task
|
43
|
+
ensure
|
44
|
+
@scope = original_scope
|
35
45
|
end
|
36
46
|
|
37
47
|
# Lookup a task. Return an existing task if found, otherwise
|
@@ -46,16 +56,35 @@ module Rake
|
|
46
56
|
self.lookup(task_name, scopes) or
|
47
57
|
enhance_with_matching_rule(task_name) or
|
48
58
|
synthesize_file_task(task_name) or
|
49
|
-
fail
|
59
|
+
fail generate_message_for_undefined_task(task_name)
|
60
|
+
end
|
61
|
+
|
62
|
+
def generate_message_for_undefined_task(task_name)
|
63
|
+
message = "Don't know how to build task '#{task_name}' "\
|
64
|
+
"(See the list of available tasks with `#{Rake.application.name} --tasks`)"
|
65
|
+
message + generate_did_you_mean_suggestions(task_name)
|
66
|
+
end
|
67
|
+
|
68
|
+
def generate_did_you_mean_suggestions(task_name)
|
69
|
+
return "" unless defined?(::DidYouMean::SpellChecker)
|
70
|
+
|
71
|
+
suggestions = ::DidYouMean::SpellChecker.new(dictionary: @tasks.keys).correct(task_name.to_s)
|
72
|
+
if ::DidYouMean.respond_to?(:formatter)# did_you_mean v1.2.0 or later
|
73
|
+
::DidYouMean.formatter.message_for(suggestions)
|
74
|
+
elsif defined?(::DidYouMean::Formatter) # before did_you_mean v1.2.0
|
75
|
+
::DidYouMean::Formatter.new(suggestions).to_s
|
76
|
+
else
|
77
|
+
""
|
78
|
+
end
|
50
79
|
end
|
51
80
|
|
52
|
-
def synthesize_file_task(task_name)
|
81
|
+
def synthesize_file_task(task_name) # :nodoc:
|
53
82
|
return nil unless File.exist?(task_name)
|
54
83
|
define_task(Rake::FileTask, task_name)
|
55
84
|
end
|
56
85
|
|
57
|
-
# Resolve the arguments for a task/rule. Returns a
|
58
|
-
# [task_name, arg_name_list, prerequisites].
|
86
|
+
# Resolve the arguments for a task/rule. Returns a tuple of
|
87
|
+
# [task_name, arg_name_list, prerequisites, order_only_prerequisites].
|
59
88
|
def resolve_args(args)
|
60
89
|
if args.last.is_a?(Hash)
|
61
90
|
deps = args.pop
|
@@ -72,7 +101,6 @@ module Rake
|
|
72
101
|
#
|
73
102
|
# task :t
|
74
103
|
# task :t, [:a]
|
75
|
-
# task :t, :a (deprecated)
|
76
104
|
#
|
77
105
|
def resolve_args_without_dependencies(args)
|
78
106
|
task_name = args.shift
|
@@ -81,7 +109,7 @@ module Rake
|
|
81
109
|
else
|
82
110
|
arg_names = args
|
83
111
|
end
|
84
|
-
[task_name, arg_names, []]
|
112
|
+
[task_name, arg_names, [], nil]
|
85
113
|
end
|
86
114
|
private :resolve_args_without_dependencies
|
87
115
|
|
@@ -90,33 +118,29 @@ module Rake
|
|
90
118
|
#
|
91
119
|
# The patterns recognized by this argument resolving function are:
|
92
120
|
#
|
121
|
+
# task :t, order_only: [:e]
|
93
122
|
# task :t => [:d]
|
123
|
+
# task :t => [:d], order_only: [:e]
|
94
124
|
# task :t, [a] => [:d]
|
95
|
-
# task :t,
|
96
|
-
# task :t, :a, :needs => [:d] (deprecated)
|
125
|
+
# task :t, [a] => [:d], order_only: [:e]
|
97
126
|
#
|
98
127
|
def resolve_args_with_dependencies(args, hash) # :nodoc:
|
99
|
-
fail "Task Argument Error" if
|
100
|
-
|
128
|
+
fail "Task Argument Error" if
|
129
|
+
hash.size != 1 &&
|
130
|
+
(hash.size != 2 || !hash.key?(:order_only))
|
131
|
+
order_only = hash.delete(:order_only)
|
132
|
+
key, value = hash.map { |k, v| [k, v] }.first
|
101
133
|
if args.empty?
|
102
134
|
task_name = key
|
103
135
|
arg_names = []
|
104
|
-
deps = value
|
105
|
-
elsif key == :needs
|
106
|
-
Rake.application.deprecate(
|
107
|
-
"task :t, arg, :needs => [deps]",
|
108
|
-
"task :t, [args] => [deps]",
|
109
|
-
caller.detect { |c| c !~ /\blib\/rake\b/ })
|
110
|
-
task_name = args.shift
|
111
|
-
arg_names = args
|
112
|
-
deps = value
|
136
|
+
deps = value || []
|
113
137
|
else
|
114
138
|
task_name = args.shift
|
115
|
-
arg_names = key
|
116
|
-
deps = value
|
139
|
+
arg_names = key || args.shift|| []
|
140
|
+
deps = value || []
|
117
141
|
end
|
118
142
|
deps = [deps] unless deps.respond_to?(:to_ary)
|
119
|
-
[task_name, arg_names, deps]
|
143
|
+
[task_name, arg_names, deps, order_only]
|
120
144
|
end
|
121
145
|
private :resolve_args_with_dependencies
|
122
146
|
|
@@ -127,9 +151,10 @@ module Rake
|
|
127
151
|
def enhance_with_matching_rule(task_name, level=0)
|
128
152
|
fail Rake::RuleRecursionOverflowError,
|
129
153
|
"Rule Recursion Too Deep" if level >= 16
|
130
|
-
@rules.each do |pattern, extensions, block|
|
131
|
-
if pattern.match(task_name)
|
132
|
-
task = attempt_rule(task_name, extensions, block, level)
|
154
|
+
@rules.each do |pattern, args, extensions, order_only, block|
|
155
|
+
if pattern && pattern.match(task_name)
|
156
|
+
task = attempt_rule(task_name, pattern, args, extensions, block, level)
|
157
|
+
task | order_only unless order_only.nil?
|
133
158
|
return task if task
|
134
159
|
end
|
135
160
|
end
|
@@ -147,7 +172,7 @@ module Rake
|
|
147
172
|
# List of all the tasks defined in the given scope (and its
|
148
173
|
# sub-scopes).
|
149
174
|
def tasks_in_scope(scope)
|
150
|
-
prefix = scope.
|
175
|
+
prefix = scope.path
|
151
176
|
tasks.select { |t|
|
152
177
|
/^#{prefix}:/ =~ t.name
|
153
178
|
}
|
@@ -168,11 +193,11 @@ module Rake
|
|
168
193
|
initial_scope ||= @scope
|
169
194
|
task_name = task_name.to_s
|
170
195
|
if task_name =~ /^rake:/
|
171
|
-
scopes =
|
172
|
-
task_name = task_name.sub(/^rake:/,
|
196
|
+
scopes = Scope.make
|
197
|
+
task_name = task_name.sub(/^rake:/, "")
|
173
198
|
elsif task_name =~ /^(\^+)/
|
174
|
-
scopes = initial_scope
|
175
|
-
task_name = task_name.sub(/^(\^+)/,
|
199
|
+
scopes = initial_scope.trim($1.size)
|
200
|
+
task_name = task_name.sub(/^(\^+)/, "")
|
176
201
|
else
|
177
202
|
scopes = initial_scope
|
178
203
|
end
|
@@ -181,12 +206,12 @@ module Rake
|
|
181
206
|
|
182
207
|
# Lookup the task name
|
183
208
|
def lookup_in_scope(name, scope)
|
184
|
-
|
185
|
-
|
186
|
-
tn = (scope[0,n] + [name]).join(':')
|
209
|
+
loop do
|
210
|
+
tn = scope.path_with_task_name(name)
|
187
211
|
task = @tasks[tn]
|
188
212
|
return task if task
|
189
|
-
|
213
|
+
break if scope.empty?
|
214
|
+
scope = scope.tail
|
190
215
|
end
|
191
216
|
nil
|
192
217
|
end
|
@@ -195,19 +220,19 @@ module Rake
|
|
195
220
|
# Return the list of scope names currently active in the task
|
196
221
|
# manager.
|
197
222
|
def current_scope
|
198
|
-
@scope
|
223
|
+
@scope
|
199
224
|
end
|
200
225
|
|
201
226
|
# Evaluate the block in a nested namespace named +name+. Create
|
202
227
|
# an anonymous namespace if +name+ is nil.
|
203
228
|
def in_namespace(name)
|
204
229
|
name ||= generate_name
|
205
|
-
@scope.
|
230
|
+
@scope = Scope.new(name, @scope)
|
206
231
|
ns = NameSpace.new(self, @scope)
|
207
232
|
yield(ns)
|
208
233
|
ns
|
209
234
|
ensure
|
210
|
-
@scope.
|
235
|
+
@scope = @scope.tail
|
211
236
|
end
|
212
237
|
|
213
238
|
private
|
@@ -224,7 +249,7 @@ module Rake
|
|
224
249
|
locations = caller
|
225
250
|
i = 0
|
226
251
|
while locations[i]
|
227
|
-
return locations[i+1] if locations[i] =~ /rake\/dsl_definition.rb/
|
252
|
+
return locations[i + 1] if locations[i] =~ /rake\/dsl_definition.rb/
|
228
253
|
i += 1
|
229
254
|
end
|
230
255
|
nil
|
@@ -237,19 +262,20 @@ module Rake
|
|
237
262
|
"_anon_#{@seed}"
|
238
263
|
end
|
239
264
|
|
240
|
-
def trace_rule(level, message)
|
241
|
-
|
265
|
+
def trace_rule(level, message) # :nodoc:
|
266
|
+
options.trace_output.puts "#{" " * level}#{message}" if
|
267
|
+
Rake.application.options.trace_rules
|
242
268
|
end
|
243
269
|
|
244
270
|
# Attempt to create a rule given the list of prerequisites.
|
245
|
-
def attempt_rule(task_name, extensions, block, level)
|
246
|
-
sources = make_sources(task_name, extensions)
|
247
|
-
prereqs = sources.
|
271
|
+
def attempt_rule(task_name, task_pattern, args, extensions, block, level)
|
272
|
+
sources = make_sources(task_name, task_pattern, extensions)
|
273
|
+
prereqs = sources.map { |source|
|
248
274
|
trace_rule level, "Attempting Rule #{task_name} => #{source}"
|
249
275
|
if File.exist?(source) || Rake::Task.task_defined?(source)
|
250
276
|
trace_rule level, "(#{task_name} => #{source} ... EXIST)"
|
251
277
|
source
|
252
|
-
elsif parent = enhance_with_matching_rule(source, level+1)
|
278
|
+
elsif parent = enhance_with_matching_rule(source, level + 1)
|
253
279
|
trace_rule level, "(#{task_name} => #{source} ... ENHANCE)"
|
254
280
|
parent.name
|
255
281
|
else
|
@@ -257,25 +283,26 @@ module Rake
|
|
257
283
|
return nil
|
258
284
|
end
|
259
285
|
}
|
260
|
-
task = FileTask.define_task(
|
286
|
+
task = FileTask.define_task(task_name, { args => prereqs }, &block)
|
261
287
|
task.sources = prereqs
|
262
288
|
task
|
263
289
|
end
|
264
290
|
|
265
291
|
# Make a list of sources from the list of file name extensions /
|
266
292
|
# translation procs.
|
267
|
-
def make_sources(task_name, extensions)
|
268
|
-
result = extensions.
|
293
|
+
def make_sources(task_name, task_pattern, extensions)
|
294
|
+
result = extensions.map { |ext|
|
269
295
|
case ext
|
270
296
|
when /%/
|
271
297
|
task_name.pathmap(ext)
|
272
298
|
when %r{/}
|
273
299
|
ext
|
274
300
|
when /^\./
|
275
|
-
task_name.
|
301
|
+
source = task_name.sub(task_pattern, ext)
|
302
|
+
source == ext ? task_name.ext(ext) : source
|
276
303
|
when String
|
277
304
|
ext
|
278
|
-
when Proc
|
305
|
+
when Proc, Method
|
279
306
|
if ext.arity == 1
|
280
307
|
ext.call(task_name)
|
281
308
|
else
|
@@ -288,9 +315,6 @@ module Rake
|
|
288
315
|
result.flatten
|
289
316
|
end
|
290
317
|
|
291
|
-
|
292
|
-
private
|
293
|
-
|
294
318
|
# Return the current description, clearing it in the process.
|
295
319
|
def get_description(task)
|
296
320
|
desc = @last_description
|
@@ -299,7 +323,7 @@ module Rake
|
|
299
323
|
end
|
300
324
|
|
301
325
|
class << self
|
302
|
-
attr_accessor :record_task_metadata
|
326
|
+
attr_accessor :record_task_metadata # :nodoc:
|
303
327
|
TaskManager.record_task_metadata = false
|
304
328
|
end
|
305
329
|
end
|
data/lib/rake/tasklib.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake"
|
2
3
|
|
3
4
|
module Rake
|
4
5
|
|
@@ -6,17 +7,6 @@ module Rake
|
|
6
7
|
class TaskLib
|
7
8
|
include Cloneable
|
8
9
|
include Rake::DSL
|
9
|
-
|
10
|
-
# Make a symbol by pasting two strings together.
|
11
|
-
#
|
12
|
-
# NOTE: DEPRECATED! This method is kinda stupid. I don't know why
|
13
|
-
# I didn't just use string interpolation. But now other task
|
14
|
-
# libraries depend on this so I can't remove it without breaking
|
15
|
-
# other people's code. So for now it stays for backwards
|
16
|
-
# compatibility. BUT DON'T USE IT.
|
17
|
-
def paste(a,b) # :nodoc:
|
18
|
-
(a.to_s + b.to_s).intern
|
19
|
-
end
|
20
10
|
end
|
21
11
|
|
22
12
|
end
|