summaryrefslogtreecommitdiff
path: root/lib/rake
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rake')
-rw-r--r--lib/rake/application.rb12
-rw-r--r--lib/rake/file_list.rb2
-rw-r--r--lib/rake/task.rb15
-rw-r--r--lib/rake/trace_output.rb19
-rw-r--r--lib/rake/version.rb11
5 files changed, 42 insertions, 17 deletions
diff --git a/lib/rake/application.rb b/lib/rake/application.rb
index 54796312d8..734e20ac31 100644
--- a/lib/rake/application.rb
+++ b/lib/rake/application.rb
@@ -5,6 +5,7 @@ require 'rake/task_manager'
require 'rake/file_list'
require 'rake/thread_pool'
require 'rake/thread_history_display'
+require 'rake/trace_output'
require 'rake/win32'
module Rake
@@ -17,6 +18,7 @@ module Rake
#
class Application
include TaskManager
+ include TraceOutput
# The name of the application (typically 'rake')
attr_reader :name
@@ -176,7 +178,7 @@ module Rake
if options.backtrace
trace ex.backtrace.join("\n")
else
- trace Backtrace.collapse(ex.backtrace)
+ trace Backtrace.collapse(ex.backtrace).join("\n")
end
trace "Tasks: #{ex.chain}" if has_chain?(ex)
trace "(See full trace by running task with --trace)" unless options.backtrace
@@ -314,9 +316,9 @@ module Rake
end
end
- def trace(*str)
+ def trace(*strings)
options.trace_output ||= $stderr
- options.trace_output.puts(*str)
+ trace_on(options.trace_output, *strings)
end
def sort_options(options)
@@ -336,7 +338,7 @@ module Rake
options.show_all_tasks = value
}
],
- ['--backtrace [OUT]', "Enable full backtrace. OUT can be stderr (default) or stdout.",
+ ['--backtrace=[OUT]', "Enable full backtrace. OUT can be stderr (default) or stdout.",
lambda { |value|
options.backtrace = true
select_trace_output(options, 'backtrace', value)
@@ -467,7 +469,7 @@ module Rake
select_tasks_to_show(options, :tasks, value)
}
],
- ['--trace', '-t [OUT]', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
+ ['--trace=[OUT]', '-t', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
lambda { |value|
options.trace = true
options.backtrace = true
diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb
index b9b9d7216a..3eae5fb0d7 100644
--- a/lib/rake/file_list.rb
+++ b/lib/rake/file_list.rb
@@ -385,7 +385,7 @@ module Rake
end
# Get a sorted list of files matching the pattern. This method
- # should be prefered to Dir[pattern] and Dir.glob[pattern] because
+ # should be prefered to Dir[pattern] and Dir.glob(pattern) because
# the files returned are guaranteed to be sorted.
def glob(pattern, *args)
Dir.glob(pattern, *args).sort
diff --git a/lib/rake/task.rb b/lib/rake/task.rb
index afa1b6153d..ac0ce68c60 100644
--- a/lib/rake/task.rb
+++ b/lib/rake/task.rb
@@ -105,7 +105,7 @@ module Rake
# Argument description (nil if none).
def arg_description # :nodoc:
- @arg_names ? "[#{(arg_names || []).join(',')}]" : nil
+ @arg_names ? "[#{arg_names.join(',')}]" : nil
end
# Name of arguments for this task.
@@ -182,18 +182,19 @@ module Rake
if application.options.always_multitask
invoke_prerequisites_concurrently(task_args, invocation_chain)
else
- prerequisite_tasks.each { |prereq|
- prereq_args = task_args.new_scope(prereq.arg_names)
- prereq.invoke_with_call_chain(prereq_args, invocation_chain)
+ prerequisite_tasks.each { |p|
+ prereq_args = task_args.new_scope(p.arg_names)
+ p.invoke_with_call_chain(prereq_args, invocation_chain)
}
end
end
# Invoke all the prerequisites of a task in parallel.
- def invoke_prerequisites_concurrently(args, invocation_chain) # :nodoc:
- futures = @prerequisites.collect do |p|
+ def invoke_prerequisites_concurrently(task_args, invocation_chain) # :nodoc:
+ futures = prerequisite_tasks.collect do |p|
+ prereq_args = task_args.new_scope(p.arg_names)
application.thread_pool.future(p) do |r|
- application[r, @scope].invoke_with_call_chain(args, invocation_chain)
+ r.invoke_with_call_chain(prereq_args, invocation_chain)
end
end
futures.each { |f| f.value }
diff --git a/lib/rake/trace_output.rb b/lib/rake/trace_output.rb
new file mode 100644
index 0000000000..e4d61cfb93
--- /dev/null
+++ b/lib/rake/trace_output.rb
@@ -0,0 +1,19 @@
+module Rake
+ module TraceOutput
+
+ # Write trace output to output stream +out+.
+ #
+ # The write is done as a single IO call (to print) to lessen the
+ # chance that the trace output is interrupted by other tasks also
+ # producing output.
+ def trace_on(out, *strings)
+ sep = $\ || "\n"
+ if strings.empty?
+ output = sep
+ else
+ output = strings.map { |s| s.end_with?(sep) ? s : s + sep }.join
+ end
+ out.print(output)
+ end
+ end
+end
diff --git a/lib/rake/version.rb b/lib/rake/version.rb
index f6cb389478..410afa82cf 100644
--- a/lib/rake/version.rb
+++ b/lib/rake/version.rb
@@ -1,10 +1,13 @@
module Rake
+ VERSION = '0.9.5'
+
module Version # :nodoc: all
+ MAJOR, MINOR, BUILD, = Rake::VERSION.split '.'
+
NUMBERS = [
- MAJOR = 0,
- MINOR = 9,
- BUILD = 4,
+ MAJOR,
+ MINOR,
+ BUILD,
]
end
- VERSION = "0.9.4"
end