rake 10.0.4 → 10.1.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/doc/rakefile.rdoc +19 -0
  3. data/lib/rake/alt_system.rb +3 -4
  4. data/lib/rake/application.rb +114 -67
  5. data/lib/rake/backtrace.rb +9 -8
  6. data/lib/rake/contrib/ftptools.rb +6 -18
  7. data/lib/rake/contrib/sys.rb +2 -1
  8. data/lib/rake/dsl_definition.rb +1 -1
  9. data/lib/rake/ext/core.rb +2 -1
  10. data/lib/rake/ext/string.rb +1 -3
  11. data/lib/rake/file_list.rb +14 -14
  12. data/lib/rake/file_task.rb +1 -2
  13. data/lib/rake/file_utils.rb +9 -7
  14. data/lib/rake/file_utils_ext.rb +2 -1
  15. data/lib/rake/gempackagetask.rb +2 -1
  16. data/lib/rake/invocation_chain.rb +2 -0
  17. data/lib/rake/packagetask.rb +11 -6
  18. data/lib/rake/pseudo_status.rb +5 -0
  19. data/lib/rake/rdoctask.rb +2 -1
  20. data/lib/rake/ruby182_test_unit_fix.rb +4 -2
  21. data/lib/rake/runtest.rb +2 -2
  22. data/lib/rake/task.rb +9 -10
  23. data/lib/rake/task_arguments.rb +13 -2
  24. data/lib/rake/task_manager.rb +9 -8
  25. data/lib/rake/tasklib.rb +1 -1
  26. data/lib/rake/testtask.rb +10 -7
  27. data/lib/rake/thread_history_display.rb +1 -1
  28. data/lib/rake/thread_pool.rb +10 -4
  29. data/lib/rake/version.rb +3 -7
  30. data/lib/rake/win32.rb +3 -2
  31. data/test/helper.rb +28 -28
  32. data/test/test_rake_application.rb +14 -12
  33. data/test/test_rake_application_options.rb +7 -5
  34. data/test/test_rake_backtrace.rb +30 -1
  35. data/test/test_rake_definitions.rb +2 -3
  36. data/test/test_rake_file_creation_task.rb +2 -2
  37. data/test/test_rake_file_list.rb +9 -10
  38. data/test/test_rake_file_task.rb +4 -4
  39. data/test/test_rake_file_utils.rb +6 -2
  40. data/test/test_rake_ftp_file.rb +28 -13
  41. data/test/test_rake_functional.rb +4 -2
  42. data/test/test_rake_makefile_loader.rb +3 -1
  43. data/test/test_rake_multi_task.rb +2 -3
  44. data/test/test_rake_name_space.rb +1 -1
  45. data/test/test_rake_path_map.rb +23 -12
  46. data/test/test_rake_rake_test_loader.rb +2 -3
  47. data/test/test_rake_rules.rb +11 -12
  48. data/test/test_rake_task.rb +7 -7
  49. data/test/test_rake_task_arguments.rb +35 -2
  50. data/test/test_rake_task_manager.rb +3 -4
  51. data/test/test_rake_task_with_arguments.rb +2 -2
  52. data/test/test_rake_test_task.rb +1 -2
  53. data/test/test_rake_thread_pool.rb +36 -16
  54. data/test/test_thread_history_display.rb +16 -6
  55. data/test/test_trace_output.rb +2 -0
  56. metadata +2 -2
@@ -1,14 +1,15 @@
1
1
  module Rake
2
2
  module Backtrace
3
- SUPPRESSED_PATHS =
4
- RbConfig::CONFIG.values_at(*RbConfig::CONFIG.
5
- keys.grep(/(prefix|libdir)/)).uniq + [
6
- File.join(File.dirname(__FILE__), ".."),
7
- ].map { |f| Regexp.quote(File.expand_path(f)) }
8
- SUPPRESSED_PATHS.map! { |s| s.gsub("\\", "/") }
9
- SUPPRESSED_PATHS.reject! { |s| s.nil? || s =~ /^ *$/ }
3
+ SYS_KEYS = RbConfig::CONFIG.keys.grep(/(prefix|libdir)/)
4
+ SYS_PATHS = RbConfig::CONFIG.values_at(*SYS_KEYS).uniq +
5
+ [ File.join(File.dirname(__FILE__), "..") ]
10
6
 
11
- SUPPRESS_PATTERN = %r!(\A#{SUPPRESSED_PATHS.join('|')}|bin/rake:\d+)!i
7
+ SUPPRESSED_PATHS = SYS_PATHS.
8
+ map { |s| s.gsub("\\", "/") }.
9
+ map { |f| File.expand_path(f) }.
10
+ reject { |s| s.nil? || s =~ /^ *$/ }
11
+ SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|")
12
+ SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i
12
13
 
13
14
  def self.collapse(backtrace)
14
15
  pattern = Rake.application.options.suppress_backtrace_pattern ||
@@ -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]==?-) ? 0 : 1)
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 /:/ =~ d3
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
 
@@ -1 +1,2 @@
1
- fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported. Use 'FileUtils' instead."
1
+ fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported. " +
2
+ "Use 'FileUtils' instead."
@@ -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 if ! File.exist?(t.name)
69
+ mkdir_p t.name unless File.exist?(t.name)
70
70
  end
71
71
  end
72
72
  result
@@ -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: #{self}##{method} already exists"
22
+ $stderr.puts "WARNING: Possible conflict with Rake extension: " +
23
+ "#{self}##{method} already exists"
23
24
  else
24
25
  yield
25
26
  end
@@ -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
@@ -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).map { |n| n.to_s }
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[to_a inspect <=>]
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).collect{ |s| s.to_s }.sort.uniq
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.each_with_index do |sym, i|
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
- @exclude_procs << block
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
 
@@ -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
 
@@ -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
-
@@ -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 { |ok, status|
53
- ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
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,&block)
79
+ def ruby(*args, &block)
78
80
  options = (Hash === args.last) ? args.pop : {}
79
- if args.length > 1 then
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
- unless LN_SUPPORTED[0]
93
+ if ! LN_SUPPORTED[0]
92
94
  cp(*args)
93
95
  else
94
96
  begin
@@ -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 h.empty?
138
+ raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
139
+ h.empty?
139
140
  end
140
141
 
141
142
  extend self
@@ -1 +1,2 @@
1
- fail "ERROR: 'rake/gempackagetask' is obsolete and no longer supported. Use 'rubygems/package_task' instead."
1
+ fail "ERROR: 'rake/gempackagetask' is obsolete and no longer supported. " +
2
+ "Use 'rubygems/package_task' instead."
@@ -38,9 +38,11 @@ module Rake
38
38
  def member?(obj)
39
39
  false
40
40
  end
41
+
41
42
  def append(value)
42
43
  InvocationChain.new(value, self)
43
44
  end
45
+
44
46
  def to_s
45
47
  "TOP"
46
48
  end
@@ -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 false).
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 is false).
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 is false).
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}" => [package_dir_path] + package_files do
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}" => [package_dir_path] + package_files do
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) if !File.exist?(fdir)
153
+ mkdir_p(fdir) unless File.exist?(fdir)
149
154
  if File.directory?(fn)
150
155
  mkdir_p(f)
151
156
  else
@@ -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
@@ -1 +1,2 @@
1
- fail "ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead."
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(@req)
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{|t| add_suite(suites, t.suite)}
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
@@ -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 { |fn|
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
@@ -53,7 +53,7 @@ module Rake
53
53
 
54
54
  # List of prerequisite tasks
55
55
  def prerequisite_tasks
56
- prerequisites.collect { |pre| lookup_prerequisite(pre) }
56
+ prerequisites.map { |pre| lookup_prerequisite(pre) }
57
57
  end
58
58
 
59
59
  def lookup_prerequisite(prerequisite_name)
@@ -190,7 +190,8 @@ module Rake
190
190
  protected :invoke_with_call_chain
191
191
 
192
192
  def add_chain_to(exception, new_chain)
193
- exception.extend(InvocationExceptionMixin) unless exception.respond_to?(:chain)
193
+ exception.extend(InvocationExceptionMixin) unless
194
+ exception.respond_to?(:chain)
194
195
  exception.chain = new_chain if exception.chain.nil?
195
196
  end
196
197
  private :add_chain_to
@@ -208,8 +209,8 @@ module Rake
208
209
  end
209
210
 
210
211
  # Invoke all the prerequisites of a task in parallel.
211
- def invoke_prerequisites_concurrently(task_args, invocation_chain) # :nodoc:
212
- futures = prerequisite_tasks.collect do |p|
212
+ def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc:
213
+ futures = prerequisite_tasks.map do |p|
213
214
  prereq_args = task_args.new_scope(p.arg_names)
214
215
  application.thread_pool.future(p) do |r|
215
216
  r.invoke_with_call_chain(prereq_args, invocation_chain)
@@ -234,9 +235,7 @@ module Rake
234
235
  application.trace "** Execute (dry run) #{name}"
235
236
  return
236
237
  end
237
- if application.options.trace
238
- application.trace "** Execute #{name}"
239
- end
238
+ application.trace "** Execute #{name}" if application.options.trace
240
239
  application.enhance_with_matching_rule(name) if @actions.empty?
241
240
  @actions.each do |act|
242
241
  case act.arity
@@ -262,7 +261,7 @@ module Rake
262
261
  # Add a description to the task. The description can consist of an option
263
262
  # argument list (enclosed brackets) and an optional comment.
264
263
  def add_description(description)
265
- return if ! description
264
+ return unless description
266
265
  comment = description.strip
267
266
  add_comment(comment) if comment && ! comment.empty?
268
267
  end
@@ -305,11 +304,11 @@ module Rake
305
304
  result << "timestamp: #{timestamp}\n"
306
305
  result << "pre-requisites: \n"
307
306
  prereqs = prerequisite_tasks
308
- prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
307
+ prereqs.sort! { |a, b| a.timestamp <=> b.timestamp }
309
308
  prereqs.each do |p|
310
309
  result << "--#{p.name} (#{p.timestamp})\n"
311
310
  end
312
- latest_prereq = prerequisite_tasks.collect { |pre| pre.timestamp }.max
311
+ latest_prereq = prerequisite_tasks.map { |pre| pre.timestamp }.max
313
312
  result << "latest-prerequisite time: #{latest_prereq}\n"
314
313
  result << "................................\n\n"
315
314
  return result
@@ -15,16 +15,27 @@ module Rake
15
15
  @names = names
16
16
  @parent = parent
17
17
  @hash = {}
18
+ @values = values
18
19
  names.each_with_index { |name, i|
19
20
  @hash[name.to_sym] = values[i] unless values[i].nil?
20
21
  }
21
22
  end
22
23
 
24
+ # Retrive the complete array of sequential values
25
+ def to_a
26
+ @values.dup
27
+ end
28
+
29
+ # Retrive the list of values not associated with named arguments
30
+ def extras
31
+ @values[@names.length..-1] || []
32
+ end
33
+
23
34
  # Create a new argument scope using the prerequisite argument
24
35
  # names.
25
36
  def new_scope(names)
26
- values = names.collect { |n| self[n] }
27
- self.class.new(names, values, self)
37
+ values = names.map { |n| self[n] }
38
+ self.class.new(names, values + extras, self)
28
39
  end
29
40
 
30
41
  # Find an argument value by name or index.