rake 0.9.2.2 → 13.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/History.rdoc +2403 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +64 -106
  5. data/doc/command_line_usage.rdoc +65 -21
  6. data/doc/glossary.rdoc +40 -49
  7. data/doc/jamis.rb +1 -0
  8. data/doc/rake.1 +156 -0
  9. data/doc/rakefile.rdoc +127 -62
  10. data/{bin → exe}/rake +1 -7
  11. data/lib/rake/application.rb +507 -271
  12. data/lib/rake/backtrace.rb +24 -0
  13. data/lib/rake/clean.rb +54 -8
  14. data/lib/rake/cloneable.rb +11 -19
  15. data/lib/rake/cpu_counter.rb +107 -0
  16. data/lib/rake/default_loader.rb +5 -0
  17. data/lib/rake/dsl_definition.rb +67 -48
  18. data/lib/rake/early_time.rb +5 -1
  19. data/lib/rake/ext/core.rb +5 -6
  20. data/lib/rake/ext/string.rb +61 -52
  21. data/lib/rake/file_creation_task.rb +4 -3
  22. data/lib/rake/file_list.rb +81 -49
  23. data/lib/rake/file_task.rb +15 -8
  24. data/lib/rake/file_utils.rb +63 -43
  25. data/lib/rake/file_utils_ext.rb +14 -25
  26. data/lib/rake/invocation_chain.rb +25 -19
  27. data/lib/rake/invocation_exception_mixin.rb +1 -0
  28. data/lib/rake/late_time.rb +18 -0
  29. data/lib/rake/linked_list.rb +112 -0
  30. data/lib/rake/loaders/makefile.rb +23 -9
  31. data/lib/rake/multi_task.rb +4 -6
  32. data/lib/rake/name_space.rb +36 -23
  33. data/lib/rake/packagetask.rb +71 -34
  34. data/lib/rake/phony.rb +16 -0
  35. data/lib/rake/private_reader.rb +21 -0
  36. data/lib/rake/promise.rb +100 -0
  37. data/lib/rake/pseudo_status.rb +8 -2
  38. data/lib/rake/rake_module.rb +41 -3
  39. data/lib/rake/rake_test_loader.rb +9 -4
  40. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  41. data/lib/rake/scope.rb +43 -0
  42. data/lib/rake/task.rb +186 -79
  43. data/lib/rake/task_argument_error.rb +1 -0
  44. data/lib/rake/task_arguments.rb +46 -15
  45. data/lib/rake/task_manager.rb +91 -67
  46. data/lib/rake/tasklib.rb +2 -12
  47. data/lib/rake/testtask.rb +61 -63
  48. data/lib/rake/thread_history_display.rb +49 -0
  49. data/lib/rake/thread_pool.rb +163 -0
  50. data/lib/rake/trace_output.rb +23 -0
  51. data/lib/rake/version.rb +5 -3
  52. data/lib/rake/win32.rb +14 -18
  53. data/lib/rake.rb +35 -33
  54. data/rake.gemspec +100 -0
  55. metadata +74 -176
  56. data/.gemtest +0 -0
  57. data/CHANGES +0 -522
  58. data/Rakefile +0 -369
  59. data/TODO +0 -20
  60. data/doc/rake.1.gz +0 -0
  61. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  62. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  63. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  64. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  65. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  66. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  67. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  68. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  69. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  70. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  71. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  72. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  73. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  74. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  75. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  76. data/doc/release_notes/rake-0.8.6.rdoc +0 -55
  77. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  78. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  79. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  80. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  81. data/install.rb +0 -90
  82. data/lib/rake/alt_system.rb +0 -109
  83. data/lib/rake/classic_namespace.rb +0 -11
  84. data/lib/rake/contrib/compositepublisher.rb +0 -21
  85. data/lib/rake/contrib/ftptools.rb +0 -150
  86. data/lib/rake/contrib/publisher.rb +0 -73
  87. data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
  88. data/lib/rake/contrib/sshpublisher.rb +0 -50
  89. data/lib/rake/contrib/sys.rb +0 -191
  90. data/lib/rake/ext/module.rb +0 -39
  91. data/lib/rake/ext/time.rb +0 -14
  92. data/lib/rake/gempackagetask.rb +0 -15
  93. data/lib/rake/pathmap.rb +0 -1
  94. data/lib/rake/rdoctask.rb +0 -234
  95. data/lib/rake/ruby182_test_unit_fix.rb +0 -25
  96. data/lib/rake/runtest.rb +0 -21
  97. data/test/file_creation.rb +0 -34
  98. data/test/helper.rb +0 -492
  99. data/test/test_rake.rb +0 -40
  100. data/test/test_rake_application.rb +0 -489
  101. data/test/test_rake_application_options.rb +0 -335
  102. data/test/test_rake_clean.rb +0 -14
  103. data/test/test_rake_definitions.rb +0 -80
  104. data/test/test_rake_directory_task.rb +0 -46
  105. data/test/test_rake_dsl.rb +0 -77
  106. data/test/test_rake_early_time.rb +0 -31
  107. data/test/test_rake_extension.rb +0 -59
  108. data/test/test_rake_file_creation_task.rb +0 -56
  109. data/test/test_rake_file_list.rb +0 -628
  110. data/test/test_rake_file_list_path_map.rb +0 -8
  111. data/test/test_rake_file_task.rb +0 -102
  112. data/test/test_rake_file_utils.rb +0 -305
  113. data/test/test_rake_ftp_file.rb +0 -59
  114. data/test/test_rake_functional.rb +0 -450
  115. data/test/test_rake_invocation_chain.rb +0 -52
  116. data/test/test_rake_makefile_loader.rb +0 -44
  117. data/test/test_rake_multi_task.rb +0 -51
  118. data/test/test_rake_name_space.rb +0 -43
  119. data/test/test_rake_package_task.rb +0 -79
  120. data/test/test_rake_path_map.rb +0 -157
  121. data/test/test_rake_path_map_explode.rb +0 -34
  122. data/test/test_rake_path_map_partial.rb +0 -18
  123. data/test/test_rake_pseudo_status.rb +0 -21
  124. data/test/test_rake_rake_test_loader.rb +0 -21
  125. data/test/test_rake_rdoc_task.rb +0 -83
  126. data/test/test_rake_require.rb +0 -40
  127. data/test/test_rake_rules.rb +0 -327
  128. data/test/test_rake_task.rb +0 -267
  129. data/test/test_rake_task_argument_parsing.rb +0 -103
  130. data/test/test_rake_task_arguments.rb +0 -88
  131. data/test/test_rake_task_lib.rb +0 -9
  132. data/test/test_rake_task_manager.rb +0 -157
  133. data/test/test_rake_task_manager_argument_resolution.rb +0 -36
  134. data/test/test_rake_task_with_arguments.rb +0 -173
  135. data/test/test_rake_test_task.rb +0 -120
  136. data/test/test_rake_top_level_functions.rb +0 -111
  137. data/test/test_rake_win32.rb +0 -72
  138. data/test/test_sys.rb +0 -20
@@ -1,19 +1,20 @@
1
- require 'rake/ext/core'
1
+ # frozen_string_literal: true
2
+ require "rake/ext/core"
2
3
 
3
- ######################################################################
4
- # Rake extension methods for String.
5
- #
6
4
  class String
5
+
7
6
  rake_extension("ext") do
8
7
  # Replace the file extension with +newext+. If there is no extension on
9
8
  # the string, append the new extension to the end. If the new extension
10
9
  # is not given, or is the empty string, remove any existing extension.
11
10
  #
12
11
  # +ext+ is a user added method for the String class.
13
- def ext(newext='')
14
- return self.dup if ['.', '..'].include? self
15
- if newext != ''
16
- newext = (newext =~ /^\./) ? newext : ("." + newext)
12
+ #
13
+ # This String extension comes from Rake
14
+ def ext(newext="")
15
+ return self.dup if [".", ".."].include? self
16
+ if newext != ""
17
+ newext = "." + newext unless newext =~ /^\./
17
18
  end
18
19
  self.chomp(File.extname(self)) << newext
19
20
  end
@@ -21,11 +22,13 @@ class String
21
22
 
22
23
  rake_extension("pathmap") do
23
24
  # Explode a path into individual components. Used by +pathmap+.
25
+ #
26
+ # This String extension comes from Rake
24
27
  def pathmap_explode
25
28
  head, tail = File.split(self)
26
29
  return [self] if head == self
27
- return [tail] if head == '.' || tail == '/'
28
- return [head, tail] if head == '/'
30
+ return [tail] if head == "." || tail == "/"
31
+ return [head, tail] if head == "/"
29
32
  return head.pathmap_explode + [tail]
30
33
  end
31
34
  protected :pathmap_explode
@@ -33,6 +36,8 @@ class String
33
36
  # Extract a partial path from the path. Include +n+ directories from the
34
37
  # front end (left hand side) if +n+ is positive. Include |+n+|
35
38
  # directories from the back end (right hand side) if +n+ is negative.
39
+ #
40
+ # This String extension comes from Rake
36
41
  def pathmap_partial(n)
37
42
  dirs = File.dirname(self).pathmap_explode
38
43
  partial_dirs =
@@ -47,19 +52,21 @@ class String
47
52
  end
48
53
  protected :pathmap_partial
49
54
 
50
- # Preform the pathmap replacement operations on the given path. The
55
+ # Perform the pathmap replacement operations on the given path. The
51
56
  # patterns take the form 'pat1,rep1;pat2,rep2...'.
57
+ #
58
+ # This String extension comes from Rake
52
59
  def pathmap_replace(patterns, &block)
53
60
  result = self
54
- patterns.split(';').each do |pair|
55
- pattern, replacement = pair.split(',')
61
+ patterns.split(";").each do |pair|
62
+ pattern, replacement = pair.split(",")
56
63
  pattern = Regexp.new(pattern)
57
- if replacement == '*' && block_given?
64
+ if replacement == "*" && block_given?
58
65
  result = result.sub(pattern, &block)
59
66
  elsif replacement
60
67
  result = result.sub(pattern, replacement)
61
68
  else
62
- result = result.sub(pattern, '')
69
+ result = result.sub(pattern, "")
63
70
  end
64
71
  end
65
72
  result
@@ -70,35 +77,36 @@ class String
70
77
  # controls the details of the mapping. The following special patterns are
71
78
  # recognized:
72
79
  #
73
- # * <b>%p</b> -- The complete path.
74
- # * <b>%f</b> -- The base file name of the path, with its file extension,
75
- # but without any directories.
76
- # * <b>%n</b> -- The file name of the path without its file extension.
77
- # * <b>%d</b> -- The directory list of the path.
78
- # * <b>%x</b> -- The file extension of the path. An empty string if there
79
- # is no extension.
80
- # * <b>%X</b> -- Everything *but* the file extension.
81
- # * <b>%s</b> -- The alternate file separator if defined, otherwise use
82
- # the standard file separator.
83
- # * <b>%%</b> -- A percent sign.
84
- #
85
- # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the
86
- # number is positive, only return (up to) +n+ directories in the path,
87
- # starting from the left hand side. If +n+ is negative, return (up to)
88
- # |+n+| directories from the right hand side of the path.
80
+ # <tt>%p</tt> :: The complete path.
81
+ # <tt>%f</tt> :: The base file name of the path, with its file extension,
82
+ # but without any directories.
83
+ # <tt>%n</tt> :: The file name of the path without its file extension.
84
+ # <tt>%d</tt> :: The directory list of the path.
85
+ # <tt>%x</tt> :: The file extension of the path. An empty string if there
86
+ # is no extension.
87
+ # <tt>%X</tt> :: Everything *but* the file extension.
88
+ # <tt>%s</tt> :: The alternate file separator if defined, otherwise use #
89
+ # the standard file separator.
90
+ # <tt>%%</tt> :: A percent sign.
91
+ #
92
+ # The <tt>%d</tt> specifier can also have a numeric prefix (e.g. '%2d').
93
+ # If the number is positive, only return (up to) +n+ directories in the
94
+ # path, starting from the left hand side. If +n+ is negative, return (up
95
+ # to) +n+ directories from the right hand side of the path.
89
96
  #
90
97
  # Examples:
91
98
  #
92
99
  # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b'
93
100
  # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
94
101
  #
95
- # Also the %d, %p, %f, %n, %x, and %X operators can take a
96
- # pattern/replacement argument to perform simple string substitutions on a
97
- # particular part of the path. The pattern and replacement are separated
98
- # by a comma and are enclosed by curly braces. The replacement spec comes
99
- # after the % character but before the operator letter. (e.g.
100
- # "%{old,new}d"). Multiple replacement specs should be separated by
101
- # semi-colons (e.g. "%{old,new;src,bin}d").
102
+ # Also the <tt>%d</tt>, <tt>%p</tt>, <tt>%f</tt>, <tt>%n</tt>,
103
+ # <tt>%x</tt>, and <tt>%X</tt> operators can take a pattern/replacement
104
+ # argument to perform simple string substitutions on a particular part of
105
+ # the path. The pattern and replacement are separated by a comma and are
106
+ # enclosed by curly braces. The replacement spec comes after the %
107
+ # character but before the operator letter. (e.g. "%{old,new}d").
108
+ # Multiple replacement specs should be separated by semi-colons (e.g.
109
+ # "%{old,new;src,bin}d").
102
110
  #
103
111
  # Regular expressions may be used for the pattern, and back refs may be
104
112
  # used in the replacement text. Curly braces, commas and semi-colons are
@@ -107,11 +115,11 @@ class String
107
115
  #
108
116
  # For example:
109
117
  #
110
- # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
118
+ # "src/org/onestepback/proj/A.java".pathmap("%{^src,class}X.class")
111
119
  #
112
120
  # returns:
113
121
  #
114
- # "bin/org/onestepback/proj/A.class"
122
+ # "class/org/onestepback/proj/A.class"
115
123
  #
116
124
  # If the replacement text is '*', then a block may be provided to perform
117
125
  # some arbitrary calculation for the replacement.
@@ -126,34 +134,35 @@ class String
126
134
  #
127
135
  # "/path/to/file.txt"
128
136
  #
137
+ # This String extension comes from Rake
129
138
  def pathmap(spec=nil, &block)
130
139
  return self if spec.nil?
131
- result = ''
140
+ result = "".dup
132
141
  spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
133
142
  case frag
134
- when '%f'
143
+ when "%f"
135
144
  result << File.basename(self)
136
- when '%n'
145
+ when "%n"
137
146
  result << File.basename(self).ext
138
- when '%d'
147
+ when "%d"
139
148
  result << File.dirname(self)
140
- when '%x'
149
+ when "%x"
141
150
  result << File.extname(self)
142
- when '%X'
151
+ when "%X"
143
152
  result << self.ext
144
- when '%p'
153
+ when "%p"
145
154
  result << self
146
- when '%s'
155
+ when "%s"
147
156
  result << (File::ALT_SEPARATOR || File::SEPARATOR)
148
- when '%-'
157
+ when "%-"
149
158
  # do nothing
150
- when '%%'
159
+ when "%%"
151
160
  result << "%"
152
161
  when /%(-?\d+)d/
153
162
  result << pathmap_partial($1.to_i)
154
163
  when /^%\{([^}]*)\}(\d*[dpfnxX])/
155
164
  patterns, operator = $1, $2
156
- result << pathmap('%' + operator).pathmap_replace(patterns, &block)
165
+ result << pathmap("%" + operator).pathmap_replace(patterns, &block)
157
166
  when /^%/
158
167
  fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
159
168
  else
@@ -163,5 +172,5 @@ class String
163
172
  result
164
173
  end
165
174
  end
166
- end # class String
167
175
 
176
+ end
@@ -1,5 +1,6 @@
1
- require 'rake/file_task'
2
- require 'rake/early_time'
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
- ! File.exist?(name)
15
+ !File.exist?(name)
15
16
  end
16
17
 
17
18
  # Time stamp for file creation task. This time stamp is earlier
@@ -1,11 +1,11 @@
1
- require 'rake/cloneable'
2
- require 'rake/file_utils_ext'
3
- require 'rake/pathmap'
1
+ # frozen_string_literal: true
2
+ require "rake/cloneable"
3
+ require "rake/file_utils_ext"
4
+ require "rake/ext/string"
4
5
 
5
- ######################################################################
6
6
  module Rake
7
7
 
8
- # #########################################################################
8
+ ##
9
9
  # A FileList is essentially an array with a few helper methods defined to
10
10
  # make file manipulation a bit easier.
11
11
  #
@@ -41,14 +41,14 @@ 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).map(&:to_s)
45
45
 
46
46
  # List of additional methods that must be delegated.
47
- MUST_DEFINE = %w[to_a inspect <=>]
47
+ MUST_DEFINE = %w[inspect <=>]
48
48
 
49
49
  # List of methods that should not be delegated here (we define special
50
50
  # versions of them explicitly below).
51
- MUST_NOT_DEFINE = %w[to_a to_ary partition *]
51
+ MUST_NOT_DEFINE = %w[to_a to_ary partition * <<]
52
52
 
53
53
  # List of delegated methods that return new array values which need
54
54
  # wrapping.
@@ -58,21 +58,21 @@ module Rake
58
58
  + - & |
59
59
  ]
60
60
 
61
- DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq
61
+ DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).map(&:to_s).sort.uniq
62
62
 
63
63
  # Now do the delegation.
64
- DELEGATING_METHODS.each_with_index do |sym, i|
64
+ DELEGATING_METHODS.each do |sym|
65
65
  if SPECIAL_RETURN.include?(sym)
66
- ln = __LINE__+1
66
+ ln = __LINE__ + 1
67
67
  class_eval %{
68
68
  def #{sym}(*args, &block)
69
69
  resolve
70
70
  result = @items.send(:#{sym}, *args, &block)
71
- FileList.new.import(result)
71
+ self.class.new.import(result)
72
72
  end
73
73
  }, __FILE__, ln
74
74
  else
75
- ln = __LINE__+1
75
+ ln = __LINE__ + 1
76
76
  class_eval %{
77
77
  def #{sym}(*args, &block)
78
78
  resolve
@@ -83,6 +83,8 @@ module Rake
83
83
  end
84
84
  end
85
85
 
86
+ GLOB_PATTERN = %r{[*?\[\{]}
87
+
86
88
  # Create a file list from the globbable patterns given. If you wish to
87
89
  # perform multiple includes or excludes at object build time, use the
88
90
  # "yield self" pattern.
@@ -117,7 +119,7 @@ module Rake
117
119
  if fn.respond_to? :to_ary
118
120
  include(*fn.to_ary)
119
121
  else
120
- @pending_add << fn
122
+ @pending_add << Rake.from_pathname(fn)
121
123
  end
122
124
  end
123
125
  @pending = true
@@ -147,16 +149,17 @@ module Rake
147
149
  #
148
150
  def exclude(*patterns, &block)
149
151
  patterns.each do |pat|
150
- @exclude_patterns << pat
151
- end
152
- if block_given?
153
- @exclude_procs << block
152
+ if pat.respond_to? :to_ary
153
+ exclude(*pat.to_ary)
154
+ else
155
+ @exclude_patterns << Rake.from_pathname(pat)
156
+ end
154
157
  end
155
- resolve_exclude if ! @pending
158
+ @exclude_procs << block if block_given?
159
+ resolve_exclude unless @pending
156
160
  self
157
161
  end
158
162
 
159
-
160
163
  # Clear all the exclude patterns so that we exclude nothing.
161
164
  def clear_exclude
162
165
  @exclude_patterns = []
@@ -164,7 +167,7 @@ module Rake
164
167
  self
165
168
  end
166
169
 
167
- # Define equality.
170
+ # A FileList is equal through array equality.
168
171
  def ==(array)
169
172
  to_ary == array
170
173
  end
@@ -191,12 +194,18 @@ module Rake
191
194
  result = @items * other
192
195
  case result
193
196
  when Array
194
- FileList.new.import(result)
197
+ self.class.new.import(result)
195
198
  else
196
199
  result
197
200
  end
198
201
  end
199
202
 
203
+ def <<(obj)
204
+ resolve
205
+ @items << Rake.from_pathname(obj)
206
+ self
207
+ end
208
+
200
209
  # Resolve all the pending adds now.
201
210
  def resolve
202
211
  if @pending
@@ -208,9 +217,9 @@ module Rake
208
217
  self
209
218
  end
210
219
 
211
- def resolve_add(fn)
220
+ def resolve_add(fn) # :nodoc:
212
221
  case fn
213
- when %r{[*?\[\{]}
222
+ when GLOB_PATTERN
214
223
  add_matching(fn)
215
224
  else
216
225
  self << fn
@@ -218,8 +227,8 @@ module Rake
218
227
  end
219
228
  private :resolve_add
220
229
 
221
- def resolve_exclude
222
- reject! { |fn| exclude?(fn) }
230
+ def resolve_exclude # :nodoc:
231
+ reject! { |fn| excluded_from_list?(fn) }
223
232
  self
224
233
  end
225
234
  private :resolve_exclude
@@ -231,7 +240,7 @@ module Rake
231
240
  # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
232
241
  #
233
242
  def sub(pat, rep)
234
- inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) }
243
+ inject(self.class.new) { |res, fn| res << fn.sub(pat, rep) }
235
244
  end
236
245
 
237
246
  # Return a new FileList with the results of running +gsub+ against each
@@ -242,26 +251,26 @@ module Rake
242
251
  # => ['lib\\test\\file', 'x\\y']
243
252
  #
244
253
  def gsub(pat, rep)
245
- inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) }
254
+ inject(self.class.new) { |res, fn| res << fn.gsub(pat, rep) }
246
255
  end
247
256
 
248
257
  # Same as +sub+ except that the original file list is modified.
249
258
  def sub!(pat, rep)
250
- each_with_index { |fn, i| self[i] = fn.sub(pat,rep) }
259
+ each_with_index { |fn, i| self[i] = fn.sub(pat, rep) }
251
260
  self
252
261
  end
253
262
 
254
263
  # Same as +gsub+ except that the original file list is modified.
255
264
  def gsub!(pat, rep)
256
- each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }
265
+ each_with_index { |fn, i| self[i] = fn.gsub(pat, rep) }
257
266
  self
258
267
  end
259
268
 
260
269
  # Apply the pathmap spec to each of the included file names, returning a
261
270
  # new file list with the modified paths. (See String#pathmap for
262
271
  # details.)
263
- def pathmap(spec=nil)
264
- collect { |fn| fn.pathmap(spec) }
272
+ def pathmap(spec=nil, &block)
273
+ collect { |fn| fn.pathmap(spec, &block) }
265
274
  end
266
275
 
267
276
  # Return a new FileList with <tt>String#ext</tt> method applied to
@@ -272,11 +281,10 @@ module Rake
272
281
  # array.collect { |item| item.ext(newext) }
273
282
  #
274
283
  # +ext+ is a user added method for the Array class.
275
- def ext(newext='')
284
+ def ext(newext="")
276
285
  collect { |fn| fn.ext(newext) }
277
286
  end
278
287
 
279
-
280
288
  # Grep each of the files in the filelist using the given pattern. If a
281
289
  # block is given, call the block on each matching line, passing the file
282
290
  # name, line number, and the matching line of text. If no block is given,
@@ -286,7 +294,7 @@ module Rake
286
294
  matched = 0
287
295
  each do |fn|
288
296
  begin
289
- open(fn, "rb", *options) do |inf|
297
+ File.open(fn, "r", *options) do |inf|
290
298
  count = 0
291
299
  inf.each do |line|
292
300
  count += 1
@@ -310,14 +318,14 @@ module Rake
310
318
  # Return a new file list that only contains file names from the current
311
319
  # file list that exist on the file system.
312
320
  def existing
313
- select { |fn| File.exist?(fn) }
321
+ select { |fn| File.exist?(fn) }.uniq
314
322
  end
315
323
 
316
324
  # Modify the current file list so that it contains only file name that
317
325
  # exist on the file system.
318
326
  def existing!
319
327
  resolve
320
- @items = @items.select { |fn| File.exist?(fn) }
328
+ @items = @items.select { |fn| File.exist?(fn) }.uniq
321
329
  self
322
330
  end
323
331
 
@@ -327,33 +335,42 @@ module Rake
327
335
  resolve
328
336
  result = @items.partition(&block)
329
337
  [
330
- FileList.new.import(result[0]),
331
- FileList.new.import(result[1]),
338
+ self.class.new.import(result[0]),
339
+ self.class.new.import(result[1]),
332
340
  ]
333
341
  end
334
342
 
335
343
  # Convert a FileList to a string by joining all elements with a space.
336
344
  def to_s
337
345
  resolve
338
- self.join(' ')
346
+ self.join(" ")
339
347
  end
340
348
 
341
349
  # Add matching glob patterns.
342
350
  def add_matching(pattern)
343
- Dir[pattern].each do |fn|
344
- self << fn unless exclude?(fn)
351
+ self.class.glob(pattern).each do |fn|
352
+ self << fn unless excluded_from_list?(fn)
345
353
  end
346
354
  end
347
355
  private :add_matching
348
356
 
349
- # Should the given file name be excluded?
350
- def exclude?(fn)
357
+ # Should the given file name be excluded from the list?
358
+ #
359
+ # NOTE: This method was formerly named "exclude?", but Rails
360
+ # introduced an exclude? method as an array method and setup a
361
+ # conflict with file list. We renamed the method to avoid
362
+ # confusion. If you were using "FileList#exclude?" in your user
363
+ # code, you will need to update.
364
+ def excluded_from_list?(fn)
351
365
  return true if @exclude_patterns.any? do |pat|
352
366
  case pat
353
367
  when Regexp
354
368
  fn =~ pat
355
- when /[*?]/
356
- File.fnmatch?(pat, fn, File::FNM_PATHNAME)
369
+ when GLOB_PATTERN
370
+ flags = File::FNM_PATHNAME
371
+ # Ruby <= 1.9.3 does not support File::FNM_EXTGLOB
372
+ flags |= File::FNM_EXTGLOB if defined? File::FNM_EXTGLOB
373
+ File.fnmatch?(pat, fn, flags)
357
374
  else
358
375
  fn == pat
359
376
  end
@@ -368,10 +385,10 @@ module Rake
368
385
  /~$/
369
386
  ]
370
387
  DEFAULT_IGNORE_PROCS = [
371
- proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) }
388
+ proc { |fn| fn =~ /(^|[\/\\])core$/ && !File.directory?(fn) }
372
389
  ]
373
390
 
374
- def import(array)
391
+ def import(array) # :nodoc:
375
392
  @items = array
376
393
  self
377
394
  end
@@ -383,6 +400,13 @@ module Rake
383
400
  def [](*args)
384
401
  new(*args)
385
402
  end
403
+
404
+ # Get a sorted list of files matching the pattern. This method
405
+ # should be preferred to Dir[pattern] and Dir.glob(pattern) because
406
+ # the files returned are guaranteed to be sorted.
407
+ def glob(pattern, *args)
408
+ Dir.glob(pattern, *args).sort
409
+ end
386
410
  end
387
411
  end
388
412
  end
@@ -393,11 +417,19 @@ module Rake
393
417
  # Yield each file or directory component.
394
418
  def each_dir_parent(dir) # :nodoc:
395
419
  old_length = nil
396
- while dir != '.' && dir.length != old_length
420
+ while dir != "." && dir.length != old_length
397
421
  yield(dir)
398
422
  old_length = dir.length
399
423
  dir = File.dirname(dir)
400
424
  end
401
425
  end
426
+
427
+ # Convert Pathname and Pathname-like objects to strings;
428
+ # leave everything else alone
429
+ def from_pathname(path) # :nodoc:
430
+ path = path.to_path if path.respond_to?(:to_path)
431
+ path = path.to_str if path.respond_to?(:to_str)
432
+ path
433
+ end
402
434
  end
403
435
  end # module Rake
@@ -1,8 +1,9 @@
1
- require 'rake/task.rb'
2
- require 'rake/early_time'
1
+ # frozen_string_literal: true
2
+ require "rake/task"
3
+ require "rake/early_time"
3
4
 
4
5
  module Rake
5
- # #########################################################################
6
+
6
7
  # A FileTask is a task that includes time based dependencies. If any of a
7
8
  # FileTask's prerequisites have a timestamp that is later than the file
8
9
  # represented by this task, then the file must be rebuilt (using the
@@ -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
- ! File.exist?(name) || out_of_date?(timestamp)
17
+ !File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
17
18
  end
18
19
 
19
20
  # Time stamp for file task.
@@ -21,7 +22,7 @@ module Rake
21
22
  if File.exist?(name)
22
23
  File.mtime(name.to_s)
23
24
  else
24
- Rake::EARLY
25
+ Rake::LATE
25
26
  end
26
27
  end
27
28
 
@@ -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
- @prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
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
  # ----------------------------------------------------------------
@@ -39,9 +47,8 @@ module Rake
39
47
  # Apply the scope to the task name according to the rules for this kind
40
48
  # of task. File based tasks ignore the scope when creating the name.
41
49
  def scope_name(scope, task_name)
42
- task_name
50
+ Rake.from_pathname(task_name)
43
51
  end
44
52
  end
45
53
  end
46
54
  end
47
-