rake 0.4.11 → 13.4.2

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.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/History.rdoc +2454 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +155 -0
  5. data/doc/command_line_usage.rdoc +171 -0
  6. data/doc/glossary.rdoc +40 -49
  7. data/doc/jamis.rb +135 -107
  8. data/doc/proto_rake.rdoc +22 -22
  9. data/doc/rake.1 +156 -0
  10. data/doc/rakefile.rdoc +428 -27
  11. data/doc/rational.rdoc +6 -6
  12. data/exe/rake +27 -0
  13. data/lib/rake/application.rb +847 -0
  14. data/lib/rake/backtrace.rb +25 -0
  15. data/lib/rake/clean.rb +57 -10
  16. data/lib/rake/cloneable.rb +17 -0
  17. data/lib/rake/cpu_counter.rb +122 -0
  18. data/lib/rake/default_loader.rb +15 -0
  19. data/lib/rake/dsl_definition.rb +196 -0
  20. data/lib/rake/early_time.rb +22 -0
  21. data/lib/rake/ext/core.rb +26 -0
  22. data/lib/rake/ext/string.rb +176 -0
  23. data/lib/rake/file_creation_task.rb +25 -0
  24. data/lib/rake/file_list.rb +435 -0
  25. data/lib/rake/file_task.rb +58 -0
  26. data/lib/rake/file_utils.rb +137 -0
  27. data/lib/rake/file_utils_ext.rb +135 -0
  28. data/lib/rake/invocation_chain.rb +57 -0
  29. data/lib/rake/invocation_exception_mixin.rb +17 -0
  30. data/lib/rake/late_time.rb +18 -0
  31. data/lib/rake/linked_list.rb +112 -0
  32. data/lib/rake/loaders/makefile.rb +54 -0
  33. data/lib/rake/multi_task.rb +14 -0
  34. data/lib/rake/name_space.rb +38 -0
  35. data/lib/rake/options.rb +31 -0
  36. data/lib/rake/packagetask.rb +124 -54
  37. data/lib/rake/phony.rb +16 -0
  38. data/lib/rake/private_reader.rb +21 -0
  39. data/lib/rake/promise.rb +100 -0
  40. data/lib/rake/pseudo_status.rb +30 -0
  41. data/lib/rake/rake_module.rb +67 -0
  42. data/lib/rake/rake_test_loader.rb +27 -0
  43. data/lib/rake/rule_recursion_overflow_error.rb +20 -0
  44. data/lib/rake/scope.rb +43 -0
  45. data/lib/rake/task.rb +434 -0
  46. data/lib/rake/task_argument_error.rb +8 -0
  47. data/lib/rake/task_arguments.rb +113 -0
  48. data/lib/rake/task_manager.rb +333 -0
  49. data/lib/rake/tasklib.rb +4 -16
  50. data/lib/rake/testtask.rb +110 -36
  51. data/lib/rake/thread_history_display.rb +49 -0
  52. data/lib/rake/thread_pool.rb +157 -0
  53. data/lib/rake/trace_output.rb +23 -0
  54. data/lib/rake/version.rb +10 -0
  55. data/lib/rake/win32.rb +17 -0
  56. data/lib/rake.rb +64 -992
  57. data/rake.gemspec +102 -0
  58. metadata +117 -89
  59. data/CHANGES +0 -153
  60. data/README +0 -209
  61. data/Rakefile +0 -215
  62. data/TODO +0 -19
  63. data/bin/rake +0 -8
  64. data/install.rb +0 -88
  65. data/lib/rake/contrib/compositepublisher.rb +0 -24
  66. data/lib/rake/contrib/ftptools.rb +0 -139
  67. data/lib/rake/contrib/publisher.rb +0 -75
  68. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  69. data/lib/rake/contrib/sshpublisher.rb +0 -47
  70. data/lib/rake/contrib/sys.rb +0 -207
  71. data/lib/rake/gempackagetask.rb +0 -98
  72. data/lib/rake/rdoctask.rb +0 -128
  73. data/lib/rake/runtest.rb +0 -23
  74. data/test/contrib/testsys.rb +0 -47
  75. data/test/data/rbext/rakefile.rb +0 -3
  76. data/test/filecreation.rb +0 -26
  77. data/test/functional.rb +0 -82
  78. data/test/shellcommand.rb +0 -3
  79. data/test/testclean.rb +0 -13
  80. data/test/testfilelist.rb +0 -255
  81. data/test/testfileutils.rb +0 -83
  82. data/test/testftp.rb +0 -55
  83. data/test/testpackagetask.rb +0 -81
  84. data/test/testtasks.rb +0 -371
  85. data/test/testtesttask.rb +0 -71
@@ -1,10 +1,9 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Define a package task libarary to aid in the definition of
1
+ # frozen_string_literal: true
2
+ # Define a package task library to aid in the definition of
4
3
  # redistributable package files.
5
4
 
6
- require 'rake'
7
- require 'rake/tasklib'
5
+ require_relative "../rake"
6
+ require_relative "tasklib"
8
7
 
9
8
  module Rake
10
9
 
@@ -13,26 +12,32 @@ module Rake
13
12
  #
14
13
  # The PackageTask will create the following targets:
15
14
  #
16
- # [<b>:package</b>]
15
+ # +:package+ ::
17
16
  # Create all the requested package files.
18
17
  #
19
- # [<b>:clobber_package</b>]
18
+ # +:clobber_package+ ::
20
19
  # Delete all the package files. This target is automatically
21
20
  # added to the main clobber target.
22
21
  #
23
- # [<b>:repackage</b>]
22
+ # +:repackage+ ::
24
23
  # Rebuild the package files from scratch, even if they are not out
25
24
  # of date.
26
25
  #
27
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</b>]
28
- # Create a gzipped tar package (if <em>need_tar</em> is true).
26
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</tt> ::
27
+ # Create a gzipped tar package (if <em>need_tar</em> is true).
28
+ #
29
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</tt> ::
30
+ # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
29
31
  #
30
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</b>]
32
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</tt> ::
33
+ # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
34
+ #
35
+ # <tt>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</tt> ::
31
36
  # Create a zip package archive (if <em>need_zip</em> is true).
32
37
  #
33
38
  # Example:
34
39
  #
35
- # PackageTask.new("rake", "1.2.3") do |p|
40
+ # Rake::PackageTask.new("rake", "1.2.3") do |p|
36
41
  # p.need_tar = true
37
42
  # p.package_files.include("lib/**/*.rb")
38
43
  # end
@@ -47,16 +52,40 @@ module Rake
47
52
  # Directory used to store the package files (default is 'pkg').
48
53
  attr_accessor :package_dir
49
54
 
50
- # True if a gzipped tar file should be produced (default is false).
55
+ # True if a gzipped tar file (tgz) should be produced (default is
56
+ # false).
51
57
  attr_accessor :need_tar
52
58
 
59
+ # True if a gzipped tar file (tar.gz) should be produced (default
60
+ # is false).
61
+ attr_accessor :need_tar_gz
62
+
63
+ # True if a bzip2'd tar file (tar.bz2) should be produced (default
64
+ # is false).
65
+ attr_accessor :need_tar_bz2
66
+
67
+ # True if a xz'd tar file (tar.xz) should be produced (default is false)
68
+ attr_accessor :need_tar_xz
69
+
53
70
  # True if a zip file should be produced (default is false)
54
71
  attr_accessor :need_zip
55
72
 
56
73
  # List of files to be included in the package.
57
74
  attr_accessor :package_files
58
75
 
59
- # Create a Package Task with the given name and version.
76
+ # Tar command for gzipped or bzip2ed archives. The default is 'tar'.
77
+ attr_accessor :tar_command
78
+
79
+ # Zip command for zipped archives. The default is 'zip'.
80
+ attr_accessor :zip_command
81
+
82
+ # True if parent directory should be omitted (default is false)
83
+ attr_accessor :without_parent_dir
84
+
85
+ # Create a Package Task with the given name and version. Use +:noversion+
86
+ # as the version to build a package without a version or to provide a
87
+ # fully-versioned package name.
88
+
60
89
  def initialize(name=nil, version=nil)
61
90
  init(name, version)
62
91
  yield self if block_given?
@@ -68,9 +97,15 @@ module Rake
68
97
  @name = name
69
98
  @version = version
70
99
  @package_files = Rake::FileList.new
71
- @package_dir = 'pkg'
100
+ @package_dir = "pkg"
72
101
  @need_tar = false
102
+ @need_tar_gz = false
103
+ @need_tar_bz2 = false
104
+ @need_tar_xz = false
73
105
  @need_zip = false
106
+ @tar_command = "tar"
107
+ @zip_command = "zip"
108
+ @without_parent_dir = false
74
109
  end
75
110
 
76
111
  # Create the tasks defined by this task library.
@@ -80,73 +115,108 @@ module Rake
80
115
 
81
116
  desc "Build all the packages"
82
117
  task :package
83
-
118
+
84
119
  desc "Force a rebuild of the package files"
85
- task :repackage => [:clobber_package, :package]
86
-
87
- desc "Remove package products"
120
+ task repackage: [:clobber_package, :package]
121
+
122
+ desc "Remove package products"
88
123
  task :clobber_package do
89
- rm_r package_dir rescue nil
124
+ rm_r package_dir rescue nil
90
125
  end
91
126
 
92
- task :clobber => [:clobber_package]
93
-
94
- if need_tar
95
- task :package => ["#{package_dir}/#{tgz_file}"]
96
- file "#{package_dir}/#{tgz_file}" => [package_dir_path] + package_files do
97
- chdir(package_dir) do
98
- sh %{tar zcvf #{tgz_file} #{package_name}}
99
- end
100
- end
127
+ task clobber: [:clobber_package]
128
+
129
+ [
130
+ [need_tar, tgz_file, "z"],
131
+ [need_tar_gz, tar_gz_file, "z"],
132
+ [need_tar_bz2, tar_bz2_file, "j"],
133
+ [need_tar_xz, tar_xz_file, "J"]
134
+ ].each do |need, file, flag|
135
+ if need
136
+ task package: ["#{package_dir}/#{file}"]
137
+ file "#{package_dir}/#{file}" =>
138
+ [package_dir_path] + package_files do
139
+ chdir(working_dir) { sh @tar_command, "#{flag}cvf", file, target_dir }
140
+ mv "#{package_dir_path}/#{target_dir}", package_dir if without_parent_dir
141
+ end
142
+ end
101
143
  end
102
144
 
103
145
  if need_zip
104
- task :package => ["#{package_dir}/#{zip_file}"]
105
- file "#{package_dir}/#{zip_file}" => [package_dir_path] + package_files do
106
- chdir(package_dir) do
107
- sh %{zip -r #{zip_file} #{package_name}}
108
- end
109
- end
146
+ task package: ["#{package_dir}/#{zip_file}"]
147
+ file "#{package_dir}/#{zip_file}" =>
148
+ [package_dir_path] + package_files do
149
+ chdir(working_dir) { sh @zip_command, "-r", zip_file, target_dir }
150
+ mv "#{package_dir_path}/#{zip_file}", package_dir if without_parent_dir
151
+ end
110
152
  end
111
153
 
112
- directory package_dir
113
-
114
- file package_dir_path => @package_files do
115
- mkdir_p package_dir rescue nil
116
- @package_files.each do |fn|
117
- f = File.join(package_dir_path, fn)
118
- fdir = File.dirname(f)
119
- mkdir_p(fdir) if !File.exist?(fdir)
120
- if File.directory?(fn)
121
- mkdir_p(f)
122
- else
123
- rm_f f
124
- safe_ln(fn, f)
125
- end
126
- end
154
+ directory package_dir_path => @package_files do
155
+ @package_files.each do |fn|
156
+ f = File.join(package_dir_path, fn)
157
+ fdir = File.dirname(f)
158
+ mkdir_p(fdir) unless File.exist?(fdir)
159
+ if File.directory?(fn)
160
+ mkdir_p(f)
161
+ else
162
+ rm_f f
163
+ safe_ln(fn, f)
164
+ end
165
+ end
127
166
  end
128
167
  self
129
168
  end
130
169
 
131
- private
170
+ # The name of this package
132
171
 
133
172
  def package_name
134
173
  @version ? "#{@name}-#{@version}" : @name
135
174
  end
136
-
175
+
176
+ # The directory this package will be built in
177
+
137
178
  def package_dir_path
138
179
  "#{package_dir}/#{package_name}"
139
180
  end
140
181
 
182
+ # The package name with .tgz added
183
+
141
184
  def tgz_file
142
185
  "#{package_name}.tgz"
143
186
  end
144
187
 
188
+ # The package name with .tar.gz added
189
+
190
+ def tar_gz_file
191
+ "#{package_name}.tar.gz"
192
+ end
193
+
194
+ # The package name with .tar.bz2 added
195
+
196
+ def tar_bz2_file
197
+ "#{package_name}.tar.bz2"
198
+ end
199
+
200
+ # The package name with .tar.xz added
201
+
202
+ def tar_xz_file
203
+ "#{package_name}.tar.xz"
204
+ end
205
+
206
+ # The package name with .zip added
207
+
145
208
  def zip_file
146
209
  "#{package_name}.zip"
147
210
  end
211
+
212
+ def working_dir
213
+ without_parent_dir ? package_dir_path : package_dir
214
+ end
215
+
216
+ # target directory relative to working_dir
217
+ def target_dir
218
+ without_parent_dir ? "." : package_name
219
+ end
148
220
  end
149
221
 
150
222
  end
151
-
152
-
data/lib/rake/phony.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ # Defines a :phony task that you can use as a dependency. This allows
3
+ # file-based tasks to use non-file-based tasks as prerequisites
4
+ # without forcing them to rebuild.
5
+ #
6
+ # See FileTask#out_of_date? and Task#timestamp for more info.
7
+
8
+ require_relative "../rake"
9
+
10
+ task :phony
11
+
12
+ Rake::Task[:phony].tap do |task|
13
+ def task.timestamp # :nodoc:
14
+ Time.at 0
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # Include PrivateReader to use +private_reader+.
5
+ module PrivateReader # :nodoc: all
6
+
7
+ def self.included(base)
8
+ base.extend(ClassMethods)
9
+ end
10
+
11
+ module ClassMethods
12
+
13
+ # Declare a list of private accessors
14
+ def private_reader(*names)
15
+ attr_reader(*names)
16
+ private(*names)
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # A Promise object represents a promise to do work (a chore) in the
5
+ # future. The promise is created with a block and a list of
6
+ # arguments for the block. Calling value will return the value of
7
+ # the promised chore.
8
+ #
9
+ # Used by ThreadPool.
10
+ #
11
+ class Promise # :nodoc: all
12
+ NOT_SET = Object.new.freeze # :nodoc:
13
+
14
+ attr_accessor :recorder
15
+
16
+ # Create a promise to do the chore specified by the block.
17
+ def initialize(args, &block)
18
+ @mutex = Mutex.new
19
+ @result = NOT_SET
20
+ @error = NOT_SET
21
+ @args = args
22
+ @block = block
23
+ end
24
+
25
+ # Return the value of this promise.
26
+ #
27
+ # If the promised chore is not yet complete, then do the work
28
+ # synchronously. We will wait.
29
+ def value
30
+ unless complete?
31
+ stat :sleeping_on, item_id: object_id
32
+ @mutex.synchronize do
33
+ stat :has_lock_on, item_id: object_id
34
+ chore
35
+ stat :releasing_lock_on, item_id: object_id
36
+ end
37
+ end
38
+ error? ? raise(@error) : @result
39
+ end
40
+
41
+ # If no one else is working this promise, go ahead and do the chore.
42
+ def work
43
+ stat :attempting_lock_on, item_id: object_id
44
+ if @mutex.try_lock
45
+ stat :has_lock_on, item_id: object_id
46
+ chore
47
+ stat :releasing_lock_on, item_id: object_id
48
+ @mutex.unlock
49
+ else
50
+ stat :bailed_on, item_id: object_id
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ # Perform the chore promised
57
+ def chore
58
+ if complete?
59
+ stat :found_completed, item_id: object_id
60
+ return
61
+ end
62
+ stat :will_execute, item_id: object_id
63
+ begin
64
+ @result = @block.call(*@args)
65
+ rescue Exception => e
66
+ @error = e
67
+ end
68
+ stat :did_execute, item_id: object_id
69
+ discard
70
+ end
71
+
72
+ # Do we have a result for the promise
73
+ def result?
74
+ !@result.equal?(NOT_SET)
75
+ end
76
+
77
+ # Did the promise throw an error
78
+ def error?
79
+ !@error.equal?(NOT_SET)
80
+ end
81
+
82
+ # Are we done with the promise
83
+ def complete?
84
+ result? || error?
85
+ end
86
+
87
+ # free up these items for the GC
88
+ def discard
89
+ @args = nil
90
+ @block = nil
91
+ end
92
+
93
+ # Record execution statistics if there is a recorder
94
+ def stat(*args)
95
+ @recorder.call(*args) if @recorder
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ ##
5
+ # Exit status class for times the system just gives us a nil.
6
+ class PseudoStatus # :nodoc: all
7
+ attr_reader :exitstatus
8
+
9
+ def initialize(code=0)
10
+ @exitstatus = code
11
+ end
12
+
13
+ def to_i
14
+ @exitstatus << 8
15
+ end
16
+
17
+ def >>(n)
18
+ to_i >> n
19
+ end
20
+
21
+ def stopped?
22
+ false
23
+ end
24
+
25
+ def exited?
26
+ true
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+ require "rake/application"
3
+
4
+ module Rake
5
+
6
+ class << self
7
+ # Current Rake Application
8
+ def application
9
+ @application ||= Rake::Application.new
10
+ end
11
+
12
+ # Set the current Rake application object.
13
+ def application=(app)
14
+ @application = app
15
+ end
16
+
17
+ def suggested_thread_count # :nodoc:
18
+ @cpu_count ||= Rake::CpuCounter.count
19
+ @cpu_count + 4
20
+ end
21
+
22
+ # Return the original directory where the Rake application was started.
23
+ def original_dir
24
+ application.original_dir
25
+ end
26
+
27
+ # Load a rakefile.
28
+ def load_rakefile(path)
29
+ load(path)
30
+ end
31
+
32
+ # Add files to the rakelib list
33
+ def add_rakelib(*files)
34
+ application.options.rakelib ||= []
35
+ application.options.rakelib.concat(files)
36
+ end
37
+
38
+ # Make +block_application+ the default rake application inside a block so
39
+ # you can load rakefiles into a different application.
40
+ #
41
+ # This is useful when you want to run rake tasks inside a library without
42
+ # running rake in a sub-shell.
43
+ #
44
+ # Example:
45
+ #
46
+ # Dir.chdir 'other/directory'
47
+ #
48
+ # other_rake = Rake.with_application do |rake|
49
+ # rake.load_rakefile
50
+ # end
51
+ #
52
+ # puts other_rake.tasks
53
+
54
+ def with_application(block_application = Rake::Application.new)
55
+ orig_application = Rake.application
56
+
57
+ Rake.application = block_application
58
+
59
+ yield block_application
60
+
61
+ block_application
62
+ ensure
63
+ Rake.application = orig_application
64
+ end
65
+ end
66
+
67
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "file_list"
4
+
5
+ # Load the test files from the command line.
6
+ argv = ARGV.select do |argument|
7
+ case argument
8
+ when /^-/ then
9
+ argument
10
+ when /\*/ then
11
+ Rake::FileList[argument].to_a.each do |file|
12
+ require File.expand_path file
13
+ end
14
+
15
+ false
16
+ else
17
+ path = File.expand_path argument
18
+
19
+ abort "\nFile does not exist: #{path}\n\n" unless File.exist?(path)
20
+
21
+ require path
22
+
23
+ false
24
+ end
25
+ end
26
+
27
+ ARGV.replace argv
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # Error indicating a recursion overflow error in task selection.
5
+ class RuleRecursionOverflowError < StandardError
6
+ def initialize(*args)
7
+ super
8
+ @targets = []
9
+ end
10
+
11
+ def add_target(target)
12
+ @targets << target
13
+ end
14
+
15
+ def message
16
+ super + ": [" + @targets.reverse.join(" => ") + "]"
17
+ end
18
+ end
19
+
20
+ end
data/lib/rake/scope.rb ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+ class Scope < LinkedList # :nodoc: all
4
+
5
+ # Path for the scope.
6
+ def path
7
+ map(&:to_s).reverse.join(":")
8
+ end
9
+
10
+ # Path for the scope + the named path.
11
+ def path_with_task_name(task_name)
12
+ "#{path}:#{task_name}"
13
+ end
14
+
15
+ # Trim +n+ innermost scope levels from the scope. In no case will
16
+ # this trim beyond the toplevel scope.
17
+ def trim(n)
18
+ result = self
19
+ while n > 0 && !result.empty?
20
+ result = result.tail
21
+ n -= 1
22
+ end
23
+ result
24
+ end
25
+
26
+ # Scope lists always end with an EmptyScope object. See Null
27
+ # Object Pattern)
28
+ class EmptyScope < EmptyLinkedList
29
+ @parent = Scope
30
+
31
+ def path
32
+ ""
33
+ end
34
+
35
+ def path_with_task_name(task_name)
36
+ task_name
37
+ end
38
+ end
39
+
40
+ # Singleton null object for an empty scope.
41
+ EMPTY = EmptyScope.new
42
+ end
43
+ end