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
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "promise"
4
+ require "set"
5
+
6
+ module Rake
7
+
8
+ class ThreadPool # :nodoc: all
9
+
10
+ # Creates a ThreadPool object. The +thread_count+ parameter is the size
11
+ # of the pool.
12
+ def initialize(thread_count)
13
+ @max_active_threads = [thread_count, 0].max
14
+ @threads = Set.new
15
+ @threads_mon = Monitor.new
16
+ @queue = Queue.new
17
+ @join_cond = @threads_mon.new_cond
18
+
19
+ @history_start_time = nil
20
+ @history = []
21
+ @history_mon = Monitor.new
22
+ @total_threads_in_play = 0
23
+ end
24
+
25
+ # Creates a future executed by the +ThreadPool+.
26
+ #
27
+ # The args are passed to the block when executing (similarly to
28
+ # Thread#new) The return value is an object representing
29
+ # a future which has been created and added to the queue in the
30
+ # pool. Sending #value to the object will sleep the
31
+ # current thread until the future is finished and will return the
32
+ # result (or raise an exception thrown from the future)
33
+ def future(*args, &block)
34
+ promise = Promise.new(args, &block)
35
+ promise.recorder = lambda { |*stats| stat(*stats) }
36
+
37
+ @queue.enq promise
38
+ stat :queued, item_id: promise.object_id
39
+ start_thread
40
+ promise
41
+ end
42
+
43
+ # Waits until the queue of futures is empty and all threads have exited.
44
+ def join
45
+ @threads_mon.synchronize do
46
+ begin
47
+ stat :joining
48
+ @join_cond.wait unless @threads.empty?
49
+ stat :joined
50
+ rescue Exception => e
51
+ stat :joined
52
+ $stderr.puts e
53
+ $stderr.print "Queue contains #{@queue.size} items. " +
54
+ "Thread pool contains #{@threads.count} threads\n"
55
+ $stderr.print "Current Thread #{Thread.current} status = " +
56
+ "#{Thread.current.status}\n"
57
+ $stderr.puts e.backtrace.join("\n")
58
+ @threads.each do |t|
59
+ $stderr.print "Thread #{t} status = #{t.status}\n"
60
+ $stderr.puts t.backtrace.join("\n")
61
+ end
62
+ raise e
63
+ end
64
+ end
65
+ end
66
+
67
+ # Enable the gathering of history events.
68
+ def gather_history #:nodoc:
69
+ @history_start_time = Time.now if @history_start_time.nil?
70
+ end
71
+
72
+ # Return a array of history events for the thread pool.
73
+ #
74
+ # History gathering must be enabled to be able to see the events
75
+ # (see #gather_history). Best to call this when the job is
76
+ # complete (i.e. after ThreadPool#join is called).
77
+ def history # :nodoc:
78
+ @history_mon.synchronize { @history.dup }.
79
+ sort_by { |i| i[:time] }.
80
+ each { |i| i[:time] -= @history_start_time }
81
+ end
82
+
83
+ # Return a hash of always collected statistics for the thread pool.
84
+ def statistics # :nodoc:
85
+ {
86
+ total_threads_in_play: @total_threads_in_play,
87
+ max_active_threads: @max_active_threads,
88
+ }
89
+ end
90
+
91
+ private
92
+
93
+ # processes one item on the queue. Returns true if there was an
94
+ # item to process, false if there was no item
95
+ def process_queue_item #:nodoc:
96
+ return false if @queue.empty?
97
+
98
+ # Even though we just asked if the queue was empty, it
99
+ # still could have had an item which by this statement
100
+ # is now gone. For this reason we pass true to Queue#deq
101
+ # because we will sleep indefinitely if it is empty.
102
+ promise = @queue.deq(true)
103
+ stat :dequeued, item_id: promise.object_id
104
+ promise.work
105
+ return true
106
+
107
+ rescue ThreadError # this means the queue is empty
108
+ false
109
+ end
110
+
111
+ def start_thread # :nodoc:
112
+ @threads_mon.synchronize do
113
+ next unless @threads.count < @max_active_threads
114
+
115
+ t = Thread.new do
116
+ begin
117
+ loop do
118
+ break unless process_queue_item
119
+ end
120
+ ensure
121
+ @threads_mon.synchronize do
122
+ @threads.delete Thread.current
123
+ stat :ended, thread_count: @threads.count
124
+ @join_cond.broadcast if @threads.empty?
125
+ end
126
+ end
127
+ end
128
+
129
+ @threads << t
130
+ stat(
131
+ :spawned,
132
+ new_thread: t.object_id,
133
+ thread_count: @threads.count)
134
+ @total_threads_in_play = @threads.count if
135
+ @threads.count > @total_threads_in_play
136
+ end
137
+ end
138
+
139
+ def stat(event, data=nil) # :nodoc:
140
+ return if @history_start_time.nil?
141
+ info = {
142
+ event: event,
143
+ data: data,
144
+ time: Time.now,
145
+ thread: Thread.current.object_id,
146
+ }
147
+ @history_mon.synchronize { @history << info }
148
+ end
149
+
150
+ # for testing only
151
+
152
+ def __queue__ # :nodoc:
153
+ @queue
154
+ end
155
+ end
156
+
157
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+ module TraceOutput # :nodoc: all
4
+
5
+ # Write trace output to output stream +out+.
6
+ #
7
+ # The write is done as a single IO call (to print) to lessen the
8
+ # chance that the trace output is interrupted by other tasks also
9
+ # producing output.
10
+ def trace_on(out, *strings)
11
+ sep = $\ || "\n"
12
+ if strings.empty?
13
+ output = sep
14
+ else
15
+ output = strings.map { |s|
16
+ next if s.nil?
17
+ s.end_with?(sep) ? s : s + sep
18
+ }.join
19
+ end
20
+ out.print(output)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+ VERSION = "13.4.2"
4
+
5
+ module Version # :nodoc: all
6
+ MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split "."
7
+
8
+ NUMBERS = [MAJOR, MINOR, BUILD, *OTHER]
9
+ end
10
+ end
data/lib/rake/win32.rb ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require "rbconfig"
3
+
4
+ module Rake
5
+ # Win 32 interface methods for Rake. Windows specific functionality
6
+ # will be placed here to collect that knowledge in one spot.
7
+ module Win32 # :nodoc: all
8
+
9
+ class << self
10
+ # True if running on a windows system.
11
+ def windows?
12
+ RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
13
+ end
14
+ end
15
+
16
+ end
17
+ end