rake 10.1.1 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -0
  4. data/.rubocop.yml +27 -0
  5. data/.togglerc +7 -0
  6. data/Gemfile +5 -0
  7. data/{CHANGES → History.rdoc} +84 -54
  8. data/Manifest.txt +161 -0
  9. data/README.rdoc +9 -10
  10. data/Rakefile +34 -337
  11. data/doc/command_line_usage.rdoc +16 -10
  12. data/doc/rake.1.gz +0 -0
  13. data/doc/rakefile.rdoc +72 -36
  14. data/doc/release_notes/rake-0.5.3.rdoc +1 -1
  15. data/doc/release_notes/rake-0.5.4.rdoc +1 -1
  16. data/doc/release_notes/rake-0.8.6.rdoc +1 -19
  17. data/doc/release_notes/rake-0.9.2.2.rdoc +2 -2
  18. data/doc/release_notes/rake-0.9.4.rdoc +0 -50
  19. data/doc/release_notes/rake-0.9.5.rdoc +0 -59
  20. data/doc/release_notes/rake-0.9.6.rdoc +0 -63
  21. data/doc/release_notes/rake-10.0.1.rdoc +2 -131
  22. data/doc/release_notes/rake-10.0.2.rdoc +2 -140
  23. data/doc/release_notes/rake-10.1.0.rdoc +2 -2
  24. data/lib/rake.rb +6 -1
  25. data/lib/rake/alt_system.rb +5 -3
  26. data/lib/rake/application.rb +102 -60
  27. data/lib/rake/backtrace.rb +1 -1
  28. data/lib/rake/cloneable.rb +3 -3
  29. data/lib/rake/contrib/.document +0 -0
  30. data/lib/rake/contrib/ftptools.rb +3 -5
  31. data/lib/rake/contrib/publisher.rb +12 -4
  32. data/lib/rake/contrib/rubyforgepublisher.rb +3 -1
  33. data/lib/rake/contrib/sshpublisher.rb +13 -2
  34. data/lib/rake/contrib/sys.rb +2 -0
  35. data/lib/rake/cpu_counter.rb +104 -0
  36. data/lib/rake/default_loader.rb +4 -0
  37. data/lib/rake/dsl_definition.rb +58 -17
  38. data/lib/rake/early_time.rb +4 -1
  39. data/lib/rake/ext/core.rb +2 -5
  40. data/lib/rake/ext/module.rb +1 -0
  41. data/lib/rake/ext/string.rb +35 -28
  42. data/lib/rake/ext/time.rb +1 -1
  43. data/lib/rake/file_list.rb +7 -9
  44. data/lib/rake/file_task.rb +1 -1
  45. data/lib/rake/gempackagetask.rb +3 -1
  46. data/lib/rake/invocation_chain.rb +0 -1
  47. data/lib/rake/linked_list.rb +1 -1
  48. data/lib/rake/packagetask.rb +19 -7
  49. data/lib/rake/pathmap.rb +2 -0
  50. data/lib/rake/pseudo_status.rb +2 -2
  51. data/lib/rake/rake_module.rb +6 -5
  52. data/lib/rake/rdoctask.rb +2 -0
  53. data/lib/rake/ruby182_test_unit_fix.rb +2 -0
  54. data/lib/rake/runtest.rb +6 -1
  55. data/lib/rake/scope.rb +1 -1
  56. data/lib/rake/task.rb +14 -9
  57. data/lib/rake/task_arguments.rb +19 -10
  58. data/lib/rake/task_manager.rb +20 -8
  59. data/lib/rake/tasklib.rb +2 -0
  60. data/lib/rake/testtask.rb +20 -9
  61. data/lib/rake/thread_pool.rb +13 -10
  62. data/lib/rake/trace_output.rb +1 -1
  63. data/lib/rake/version.rb +0 -2
  64. data/lib/rake/win32.rb +1 -1
  65. data/rakelib/publish.rake +20 -0
  66. data/rakelib/test_times.rake +25 -0
  67. data/test/helper.rb +6 -7
  68. data/test/support/rakefile_definitions.rb +34 -0
  69. data/test/test_rake_application.rb +89 -31
  70. data/test/test_rake_application_options.rb +13 -4
  71. data/test/test_rake_backtrace.rb +6 -2
  72. data/test/test_rake_clean.rb +3 -3
  73. data/test/test_rake_cpu_counter.rb +42 -0
  74. data/test/test_rake_file_task.rb +10 -0
  75. data/test/test_rake_functional.rb +17 -1
  76. data/test/test_rake_path_map.rb +2 -2
  77. data/test/test_rake_rules.rb +26 -0
  78. data/test/test_rake_task.rb +16 -0
  79. data/test/test_rake_task_argument_parsing.rb +6 -0
  80. data/test/test_rake_task_arguments.rb +6 -0
  81. data/test/test_rake_task_manager.rb +20 -0
  82. data/test/test_rake_test_task.rb +23 -1
  83. metadata +196 -72
  84. metadata.gz.sig +0 -0
  85. data/TODO +0 -21
  86. data/install.rb +0 -80
@@ -1,16 +1,16 @@
1
1
  module Rake
2
2
 
3
- ####################################################################
3
+ ##
4
4
  # TaskArguments manage the arguments passed to a task.
5
5
  #
6
6
  class TaskArguments
7
7
  include Enumerable
8
8
 
9
+ # Argument names
9
10
  attr_reader :names
10
11
 
11
- # Create a TaskArgument object with a list of named arguments
12
- # (given by :names) and a set of associated values (given by
13
- # :values). :parent is the parent argument object.
12
+ # Create a TaskArgument object with a list of argument +names+ and a set
13
+ # of associated +values+. +parent+ is the parent argument object.
14
14
  def initialize(names, values, parent=nil)
15
15
  @names = names
16
16
  @parent = parent
@@ -21,12 +21,12 @@ module Rake
21
21
  }
22
22
  end
23
23
 
24
- # Retrive the complete array of sequential values
24
+ # Retrieve the complete array of sequential values
25
25
  def to_a
26
26
  @values.dup
27
27
  end
28
28
 
29
- # Retrive the list of values not associated with named arguments
29
+ # Retrieve the list of values not associated with named arguments
30
30
  def extras
31
31
  @values[@names.length..-1] || []
32
32
  end
@@ -50,33 +50,42 @@ module Rake
50
50
  @hash = defaults.merge(@hash)
51
51
  end
52
52
 
53
+ # Enumerates the arguments and their values
53
54
  def each(&block)
54
55
  @hash.each(&block)
55
56
  end
56
57
 
58
+ # Extracts the argument values at +keys+
57
59
  def values_at(*keys)
58
60
  keys.map { |k| lookup(k) }
59
61
  end
60
62
 
63
+ # Returns the value of the given argument via method_missing
61
64
  def method_missing(sym, *args)
62
65
  lookup(sym.to_sym)
63
66
  end
64
67
 
68
+ # Returns a Hash of arguments and their values
65
69
  def to_hash
66
70
  @hash
67
71
  end
68
72
 
69
- def to_s
73
+ def to_s # :nodoc:
70
74
  @hash.inspect
71
75
  end
72
76
 
73
- def inspect
77
+ def inspect # :nodoc:
74
78
  to_s
75
79
  end
76
80
 
81
+ # Returns true if +key+ is one of the arguments
82
+ def has_key?(key)
83
+ @hash.has_key?(key)
84
+ end
85
+
77
86
  protected
78
87
 
79
- def lookup(name)
88
+ def lookup(name) # :nodoc:
80
89
  if @hash.has_key?(name)
81
90
  @hash[name]
82
91
  elsif @parent
@@ -85,5 +94,5 @@ module Rake
85
94
  end
86
95
  end
87
96
 
88
- EMPTY_TASK_ARGS = TaskArguments.new([], [])
97
+ EMPTY_TASK_ARGS = TaskArguments.new([], []) # :nodoc:
89
98
  end
@@ -4,9 +4,12 @@ module Rake
4
4
  module TaskManager
5
5
  # Track the last comment made in the Rakefile.
6
6
  attr_accessor :last_description
7
- alias :last_comment :last_description # Backwards compatibility
8
7
 
9
- def initialize
8
+ # TODO: Remove in Rake 11
9
+
10
+ alias :last_comment :last_description # :nodoc: Backwards compatibility
11
+
12
+ def initialize # :nodoc:
10
13
  super
11
14
  @tasks = Hash.new
12
15
  @rules = Array.new
@@ -14,14 +17,21 @@ module Rake
14
17
  @last_description = nil
15
18
  end
16
19
 
17
- def create_rule(*args, &block)
20
+ def create_rule(*args, &block) # :nodoc:
18
21
  pattern, args, deps = resolve_args(args)
19
22
  pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
20
23
  @rules << [pattern, args, deps, block]
21
24
  end
22
25
 
23
- def define_task(task_class, *args, &block)
26
+ def define_task(task_class, *args, &block) # :nodoc:
24
27
  task_name, arg_names, deps = resolve_args(args)
28
+
29
+ original_scope = @scope
30
+ if(task_name.is_a? String)
31
+ task_name, *definition_scope = *(task_name.split(":").reverse)
32
+ @scope = Scope.make(*(definition_scope + @scope.to_a))
33
+ end
34
+
25
35
  task_name = task_class.scope_name(@scope, task_name)
26
36
  deps = [deps] unless deps.respond_to?(:to_ary)
27
37
  deps = deps.map { |d| d.to_s }
@@ -32,6 +42,8 @@ module Rake
32
42
  task.add_description(get_description(task))
33
43
  end
34
44
  task.enhance(deps, &block)
45
+ ensure
46
+ @scope = original_scope
35
47
  end
36
48
 
37
49
  # Lookup a task. Return an existing task if found, otherwise
@@ -49,7 +61,7 @@ module Rake
49
61
  fail "Don't know how to build task '#{task_name}'"
50
62
  end
51
63
 
52
- def synthesize_file_task(task_name)
64
+ def synthesize_file_task(task_name) # :nodoc:
53
65
  return nil unless File.exist?(task_name)
54
66
  define_task(Rake::FileTask, task_name)
55
67
  end
@@ -226,7 +238,7 @@ module Rake
226
238
  "_anon_#{@seed}"
227
239
  end
228
240
 
229
- def trace_rule(level, message)
241
+ def trace_rule(level, message) # :nodoc:
230
242
  options.trace_output.puts "#{" " * level}#{message}" if
231
243
  Rake.application.options.trace_rules
232
244
  end
@@ -265,7 +277,7 @@ module Rake
265
277
  task_name.ext(ext)
266
278
  when String
267
279
  ext
268
- when Proc
280
+ when Proc, Method
269
281
  if ext.arity == 1
270
282
  ext.call(task_name)
271
283
  else
@@ -289,7 +301,7 @@ module Rake
289
301
  end
290
302
 
291
303
  class << self
292
- attr_accessor :record_task_metadata
304
+ attr_accessor :record_task_metadata # :nodoc:
293
305
  TaskManager.record_task_metadata = false
294
306
  end
295
307
  end
@@ -14,6 +14,8 @@ module Rake
14
14
  # libraries depend on this so I can't remove it without breaking
15
15
  # other people's code. So for now it stays for backwards
16
16
  # compatibility. BUT DON'T USE IT.
17
+ #--
18
+ # TODO: Remove in Rake 11
17
19
  def paste(a, b) # :nodoc:
18
20
  (a.to_s + b.to_s).intern
19
21
  end
@@ -1,5 +1,3 @@
1
- # Define a task library for running unit tests.
2
-
3
1
  require 'rake'
4
2
  require 'rake/tasklib'
5
3
 
@@ -67,6 +65,9 @@ module Rake
67
65
  # Array of commandline options to pass to ruby when running test loader.
68
66
  attr_accessor :ruby_opts
69
67
 
68
+ # Description of the test task. (default is 'Run tests')
69
+ attr_accessor :description
70
+
70
71
  # Explicitly define the list of test files to be included in a
71
72
  # test. +list+ is expected to be an array of file names (a
72
73
  # FileList is acceptable). If both +pattern+ and +test_files+ are
@@ -86,6 +87,7 @@ module Rake
86
87
  @warning = false
87
88
  @loader = :rake
88
89
  @ruby_opts = []
90
+ @description = "Run tests" + (@name == :test ? "" : " for #{@name}")
89
91
  yield self if block_given?
90
92
  @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
91
93
  define
@@ -93,7 +95,7 @@ module Rake
93
95
 
94
96
  # Create the tasks defined by this task lib.
95
97
  def define
96
- desc "Run tests" + (@name == :test ? "" : " for #{@name}")
98
+ desc @description
97
99
  task @name do
98
100
  FileUtilsExt.verbose(@verbose) do
99
101
  args =
@@ -121,18 +123,18 @@ module Rake
121
123
  "")
122
124
  end
123
125
 
124
- def ruby_opts_string
126
+ def ruby_opts_string # :nodoc:
125
127
  opts = @ruby_opts.dup
126
128
  opts.unshift("-I\"#{lib_path}\"") unless @libs.empty?
127
129
  opts.unshift("-w") if @warning
128
130
  opts.join(" ")
129
131
  end
130
132
 
131
- def lib_path
133
+ def lib_path # :nodoc:
132
134
  @libs.join(File::PATH_SEPARATOR)
133
135
  end
134
136
 
135
- def file_list_string
137
+ def file_list_string # :nodoc:
136
138
  file_list.map { |fn| "\"#{fn}\"" }.join(' ')
137
139
  end
138
140
 
@@ -156,18 +158,18 @@ module Rake
156
158
  end || ''
157
159
  end
158
160
 
159
- def ruby_version
161
+ def ruby_version # :nodoc:
160
162
  RUBY_VERSION
161
163
  end
162
164
 
163
- def run_code
165
+ def run_code # :nodoc:
164
166
  case @loader
165
167
  when :direct
166
168
  "-e \"ARGV.each{|f| require f}\""
167
169
  when :testrb
168
170
  "-S testrb #{fix}"
169
171
  when :rake
170
- "-I\"#{rake_lib_dir}\" \"#{rake_loader}\""
172
+ "#{rake_include_arg} \"#{rake_loader}\""
171
173
  end
172
174
  end
173
175
 
@@ -184,6 +186,15 @@ module Rake
184
186
  nil
185
187
  end
186
188
 
189
+ def rake_include_arg # :nodoc:
190
+ spec = Gem.loaded_specs['rake']
191
+ if spec.respond_to?(:default_gem?) && spec.default_gem?
192
+ ""
193
+ else
194
+ "-I\"#{rake_lib_dir}\""
195
+ end
196
+ end
197
+
187
198
  def rake_lib_dir # :nodoc:
188
199
  find_dir('rake') or
189
200
  fail "unable to find rake lib"
@@ -5,10 +5,10 @@ require 'rake/promise'
5
5
 
6
6
  module Rake
7
7
 
8
- class ThreadPool # :nodoc: all
8
+ class ThreadPool # :nodoc: all
9
9
 
10
- # Creates a ThreadPool object.
11
- # The parameter is the size of the pool.
10
+ # Creates a ThreadPool object. The +thread_count+ parameter is the size
11
+ # of the pool.
12
12
  def initialize(thread_count)
13
13
  @max_active_threads = [thread_count, 0].max
14
14
  @threads = Set.new
@@ -25,9 +25,9 @@ module Rake
25
25
  # Creates a future executed by the +ThreadPool+.
26
26
  #
27
27
  # The args are passed to the block when executing (similarly to
28
- # <tt>Thread#new</tt>) The return value is an object representing
28
+ # Thread#new) The return value is an object representing
29
29
  # a future which has been created and added to the queue in the
30
- # pool. Sending <tt>#value</tt> to the object will sleep the
30
+ # pool. Sending #value to the object will sleep the
31
31
  # current thread until the future is finished and will return the
32
32
  # result (or raise an exception thrown from the future)
33
33
  def future(*args, &block)
@@ -109,13 +109,19 @@ module Rake
109
109
  false
110
110
  end
111
111
 
112
+ def safe_thread_count
113
+ @threads_mon.synchronize do
114
+ @threads.count
115
+ end
116
+ end
117
+
112
118
  def start_thread # :nodoc:
113
119
  @threads_mon.synchronize do
114
120
  next unless @threads.count < @max_active_threads
115
121
 
116
122
  t = Thread.new do
117
123
  begin
118
- while @threads.count <= @max_active_threads
124
+ while safe_thread_count <= @max_active_threads
119
125
  break unless process_queue_item
120
126
  end
121
127
  ensure
@@ -126,6 +132,7 @@ module Rake
126
132
  end
127
133
  end
128
134
  end
135
+
129
136
  @threads << t
130
137
  stat(
131
138
  :spawned,
@@ -152,10 +159,6 @@ module Rake
152
159
  def __queue__ # :nodoc:
153
160
  @queue
154
161
  end
155
-
156
- def __threads__ # :nodoc:
157
- @threads.dup
158
- end
159
162
  end
160
163
 
161
164
  end
@@ -1,5 +1,5 @@
1
1
  module Rake
2
- module TraceOutput
2
+ module TraceOutput # :nodoc: all
3
3
 
4
4
  # Write trace output to output stream +out+.
5
5
  #
@@ -1,6 +1,4 @@
1
1
  module Rake
2
- VERSION = '10.1.1'
3
-
4
2
  module Version # :nodoc: all
5
3
  MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split '.'
6
4
 
@@ -4,7 +4,7 @@ module Rake
4
4
 
5
5
  # Win 32 interface methods for Rake. Windows specific functionality
6
6
  # will be placed here to collect that knowledge in one spot.
7
- module Win32
7
+ module Win32 # :nodoc: all
8
8
 
9
9
  # Error indicating a problem in locating the home directory on a
10
10
  # Win32 system.
@@ -0,0 +1,20 @@
1
+ # Optional publish task for Rake
2
+
3
+ begin
4
+ require 'rake/contrib/sshpublisher'
5
+ require 'rake/contrib/rubyforgepublisher'
6
+
7
+ publisher = Rake::SshDirPublisher.new(
8
+ 'linode',
9
+ 'htdocs/software/rake',
10
+ 'html')
11
+
12
+ desc "Publish the Documentation to RubyForge."
13
+ task :publish => [:rdoc] do
14
+ publisher.upload
15
+ end
16
+
17
+ rescue LoadError => ex
18
+ puts "#{ex.message} (#{ex.class})"
19
+ puts "No Publisher Task Available"
20
+ end
@@ -0,0 +1,25 @@
1
+ module TestTimes
2
+ def self.run(test_results, limit=0)
3
+ limit = limit.nonzero? || 10
4
+ tests = []
5
+ test_results.split(/\n/).each do |line|
6
+ if line =~ /^(.+?#[^:]+): ([0-9.]+) s: \.$/
7
+ tests << [$1, $2.to_f, line]
8
+ end
9
+ end
10
+
11
+ puts "#{limit} Slowest tests"
12
+ puts tests.sort_by { |item|
13
+ item[1]
14
+ }.reverse[0...limit].map { |item|
15
+ "%6.3f: %-s\n" % [item[1], item[0]]
16
+ }
17
+ end
18
+ end
19
+
20
+ namespace :test do
21
+ desc "Find the slowest unit tests"
22
+ task :times, [:limit] do |t, args|
23
+ TestTimes.run `rake test:units TESTOPTS='--verbose'`, args.limit.to_i
24
+ end
25
+ end
@@ -1,23 +1,22 @@
1
1
  require 'rubygems'
2
2
  $:.unshift File.expand_path('../../lib', __FILE__)
3
3
 
4
- begin
5
- gem 'minitest'
6
- rescue Gem::LoadError
7
- end
4
+ gem 'minitest', '~> 4'
8
5
 
9
6
  require 'minitest/autorun'
10
7
  require 'rake'
11
8
  require 'tmpdir'
12
9
  require File.expand_path('../file_creation', __FILE__)
13
10
 
14
- require 'test/support/ruby_runner'
15
- require 'test/support/rakefile_definitions'
16
11
 
17
12
  begin
18
13
  require_relative '../ruby/envutil'
14
+ require_relative 'support/ruby_runner'
15
+ require_relative 'support/rakefile_definitions'
19
16
  rescue NoMethodError, LoadError
20
- # for ruby trunk
17
+ # ruby 1.8
18
+ require 'test/support/ruby_runner'
19
+ require 'test/support/rakefile_definitions'
21
20
  end
22
21
 
23
22
  class Rake::TestCase < MiniTest::Unit::TestCase
@@ -41,6 +41,16 @@ end
41
41
  ACCESS
42
42
  end
43
43
 
44
+ def rakefile_test_task
45
+ rakefile <<-RAKEFILE
46
+ require "rake/testtask"
47
+
48
+ Rake::TestTask.new(:unit) do |t|
49
+ t.description = "custom test task description"
50
+ end
51
+ RAKEFILE
52
+ end
53
+
44
54
  def rakefile_chains
45
55
  rakefile <<-DEFAULT
46
56
  task :default => "play.app"
@@ -217,6 +227,30 @@ default: other
217
227
  end
218
228
  end
219
229
 
230
+ def rakefile_regenerate_imports
231
+ rakefile <<-REGENERATE_IMPORTS
232
+ task :default
233
+
234
+ task :regenerate do
235
+ open("deps", "w") do |f|
236
+ f << <<-CONTENT
237
+ file "deps" => :regenerate
238
+ puts "REGENERATED"
239
+ CONTENT
240
+ end
241
+ end
242
+
243
+ import "deps"
244
+ REGENERATE_IMPORTS
245
+
246
+ open "deps", "w" do |f|
247
+ f << <<-CONTENT
248
+ file "deps" => :regenerate
249
+ puts "INITIAL"
250
+ CONTENT
251
+ end
252
+ end
253
+
220
254
  def rakefile_multidesc
221
255
  rakefile <<-MULTIDESC
222
256
  task :b