summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rake/cloneable.rb2
-rw-r--r--lib/rake/contrib/.document0
-rw-r--r--lib/rake/cpu_counter.rb3
-rw-r--r--lib/rake/dsl_definition.rb1
-rw-r--r--lib/rake/ext/pathname.rb25
-rw-r--r--lib/rake/ext/string.rb2
-rw-r--r--lib/rake/file_list.rb22
-rw-r--r--lib/rake/file_task.rb2
-rw-r--r--lib/rake/task_manager.rb2
9 files changed, 50 insertions, 9 deletions
diff --git a/lib/rake/cloneable.rb b/lib/rake/cloneable.rb
index cd19cd3733..d53645f2f3 100644
--- a/lib/rake/cloneable.rb
+++ b/lib/rake/cloneable.rb
@@ -3,7 +3,7 @@ module Rake
# Mixin for creating easily cloned objects.
module Cloneable # :nodoc:
- # The hook that invoked by 'clone' and 'dup' methods.
+ # The hook that is invoked by 'clone' and 'dup' methods.
def initialize_copy(source)
super
source.instance_variables.each do |var|
diff --git a/lib/rake/contrib/.document b/lib/rake/contrib/.document
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/lib/rake/contrib/.document
diff --git a/lib/rake/cpu_counter.rb b/lib/rake/cpu_counter.rb
index c05b69b7a7..d7c92a6cbe 100644
--- a/lib/rake/cpu_counter.rb
+++ b/lib/rake/cpu_counter.rb
@@ -38,7 +38,8 @@ module Rake
count_via_win32 ||
count_via_sysctl ||
count_via_hwprefs_thread_count ||
- count_via_hwprefs_cpu_count
+ count_via_hwprefs_cpu_count ||
+ count_via_cpuinfo
end
end
end
diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb
index 28e9631c3c..b521b7dc5c 100644
--- a/lib/rake/dsl_definition.rb
+++ b/lib/rake/dsl_definition.rb
@@ -98,6 +98,7 @@ module Rake
def directory(*args, &block) # :doc:
result = file_create(*args, &block)
dir, _ = *Rake.application.resolve_args(args)
+ dir = Rake.from_pathname(dir)
Rake.each_dir_parent(dir) do |d|
file_create d do |t|
mkdir_p t.name unless File.exist?(t.name)
diff --git a/lib/rake/ext/pathname.rb b/lib/rake/ext/pathname.rb
new file mode 100644
index 0000000000..49e2cd47ac
--- /dev/null
+++ b/lib/rake/ext/pathname.rb
@@ -0,0 +1,25 @@
+require 'rake/ext/core'
+require 'pathname'
+
+class Pathname
+
+ rake_extension("ext") do
+ # Return a new Pathname with <tt>String#ext</tt> applied to it.
+ #
+ # This Pathname extension comes from Rake
+ def ext(newext='')
+ Pathname.new(Rake.from_pathname(self).ext(newext))
+ end
+ end
+
+ rake_extension("pathmap") do
+ # Apply the pathmap spec to the Pathname, returning a
+ # new Pathname with the modified paths. (See String#pathmap for
+ # details.)
+ #
+ # This Pathname extension comes from Rake
+ def pathmap(spec=nil, &block)
+ Pathname.new(Rake.from_pathname(self).pathmap(spec, &block))
+ end
+ end
+end
diff --git a/lib/rake/ext/string.rb b/lib/rake/ext/string.rb
index 34ee328f72..b47b055a74 100644
--- a/lib/rake/ext/string.rb
+++ b/lib/rake/ext/string.rb
@@ -49,7 +49,7 @@ class String
end
protected :pathmap_partial
- # Preform the pathmap replacement operations on the given path. The
+ # Perform the pathmap replacement operations on the given path. The
# patterns take the form 'pat1,rep1;pat2,rep2...'.
#
# This String extension comes from Rake
diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb
index b01dbbb341..006ec7703e 100644
--- a/lib/rake/file_list.rb
+++ b/lib/rake/file_list.rb
@@ -49,7 +49,7 @@ module Rake
# List of methods that should not be delegated here (we define special
# versions of them explicitly below).
- MUST_NOT_DEFINE = %w[to_a to_ary partition *]
+ MUST_NOT_DEFINE = %w[to_a to_ary partition * <<]
# List of delegated methods that return new array values which need
# wrapping.
@@ -119,7 +119,7 @@ module Rake
if fn.respond_to? :to_ary
include(*fn.to_ary)
else
- @pending_add << fn
+ @pending_add << Rake.from_pathname(fn)
end
end
@pending = true
@@ -149,7 +149,7 @@ module Rake
#
def exclude(*patterns, &block)
patterns.each do |pat|
- @exclude_patterns << pat
+ @exclude_patterns << Rake.from_pathname(pat)
end
@exclude_procs << block if block_given?
resolve_exclude unless @pending
@@ -196,6 +196,12 @@ module Rake
end
end
+ def <<(obj)
+ resolve
+ @items << Rake.from_pathname(obj)
+ self
+ end
+
# Resolve all the pending adds now.
def resolve
if @pending
@@ -346,7 +352,7 @@ module Rake
# Should the given file name be excluded from the list?
#
- # NOTE: This method was formally named "exclude?", but Rails
+ # NOTE: This method was formerly named "exclude?", but Rails
# introduced an exclude? method as an array method and setup a
# conflict with file list. We renamed the method to avoid
# confusion. If you were using "FileList#exclude?" in your user
@@ -410,5 +416,13 @@ module Rake
dir = File.dirname(dir)
end
end
+
+ # Convert Pathname and Pathname-like objects to strings;
+ # leave everything else alone
+ def from_pathname(path) # :nodoc:
+ path = path.to_path if path.respond_to?(:to_path)
+ path = path.to_str if path.respond_to?(:to_str)
+ path
+ end
end
end # module Rake
diff --git a/lib/rake/file_task.rb b/lib/rake/file_task.rb
index 03e26d967b..11823bbe46 100644
--- a/lib/rake/file_task.rb
+++ b/lib/rake/file_task.rb
@@ -39,7 +39,7 @@ module Rake
# Apply the scope to the task name according to the rules for this kind
# of task. File based tasks ignore the scope when creating the name.
def scope_name(scope, task_name)
- task_name
+ Rake.from_pathname(task_name)
end
end
end
diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb
index af53e3f586..221c68cec4 100644
--- a/lib/rake/task_manager.rb
+++ b/lib/rake/task_manager.rb
@@ -35,7 +35,7 @@ module Rake
task_name = task_class.scope_name(@scope, task_name)
deps = [deps] unless deps.respond_to?(:to_ary)
- deps = deps.map { |d| d.to_s }
+ deps = deps.map { |d| Rake.from_pathname(d).to_s }
task = intern(task_class, task_name)
task.set_arg_names(arg_names) unless arg_names.empty?
if Rake::TaskManager.record_task_metadata