necktie 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/README.rdoc +174 -0
  2. data/bin/necktie +2 -1
  3. data/lib/necktie/files.rb +29 -0
  4. data/lib/necktie/rake.rb +127 -0
  5. data/lib/necktie/services.rb +11 -7
  6. data/lib/necktie.rb +4 -54
  7. data/necktie.gemspec +3 -3
  8. data/vendor/rake/CHANGES +477 -0
  9. data/vendor/rake/MIT-LICENSE +21 -0
  10. data/vendor/rake/README.rdoc +194 -0
  11. data/vendor/rake/Rakefile +421 -0
  12. data/vendor/rake/TODO +20 -0
  13. data/vendor/rake/bin/rake +31 -0
  14. data/vendor/rake/doc/command_line_usage.rdoc +102 -0
  15. data/vendor/rake/doc/example/Rakefile1 +38 -0
  16. data/vendor/rake/doc/example/Rakefile2 +35 -0
  17. data/vendor/rake/doc/example/a.c +6 -0
  18. data/vendor/rake/doc/example/b.c +6 -0
  19. data/vendor/rake/doc/example/main.c +11 -0
  20. data/vendor/rake/doc/glossary.rdoc +51 -0
  21. data/vendor/rake/doc/jamis.rb +591 -0
  22. data/vendor/rake/doc/proto_rake.rdoc +127 -0
  23. data/vendor/rake/doc/rake.1.gz +0 -0
  24. data/vendor/rake/doc/rakefile.rdoc +566 -0
  25. data/vendor/rake/doc/rational.rdoc +151 -0
  26. data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
  27. data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
  28. data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
  29. data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
  30. data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
  31. data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
  32. data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
  33. data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
  34. data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
  35. data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
  36. data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
  37. data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
  38. data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
  39. data/vendor/rake/doc/release_notes/rake-0.8.4.rdoc +147 -0
  40. data/vendor/rake/doc/release_notes/rake-0.8.5.rdoc +53 -0
  41. data/vendor/rake/doc/release_notes/rake-0.8.6.rdoc +55 -0
  42. data/vendor/rake/doc/release_notes/rake-0.8.7.rdoc +55 -0
  43. data/vendor/rake/install.rb +88 -0
  44. data/vendor/rake/lib/rake/alt_system.rb +108 -0
  45. data/vendor/rake/lib/rake/application.rb +579 -0
  46. data/vendor/rake/lib/rake/classic_namespace.rb +9 -0
  47. data/vendor/rake/lib/rake/clean.rb +35 -0
  48. data/vendor/rake/lib/rake/cloneable.rb +25 -0
  49. data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
  50. data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
  51. data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
  52. data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  53. data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
  54. data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
  55. data/vendor/rake/lib/rake/default_loader.rb +10 -0
  56. data/vendor/rake/lib/rake/dsl.rb +136 -0
  57. data/vendor/rake/lib/rake/early_time.rb +18 -0
  58. data/vendor/rake/lib/rake/environment.rb +40 -0
  59. data/vendor/rake/lib/rake/ext/module.rb +60 -0
  60. data/vendor/rake/lib/rake/ext/string.rb +165 -0
  61. data/vendor/rake/lib/rake/ext/time.rb +14 -0
  62. data/vendor/rake/lib/rake/file_creation_task.rb +24 -0
  63. data/vendor/rake/lib/rake/file_list.rb +395 -0
  64. data/vendor/rake/lib/rake/file_task.rb +47 -0
  65. data/vendor/rake/lib/rake/file_utils.rb +108 -0
  66. data/vendor/rake/lib/rake/gempackagetask.rb +97 -0
  67. data/vendor/rake/lib/rake/invocation_chain.rb +51 -0
  68. data/vendor/rake/lib/rake/invocation_exception_mixin.rb +16 -0
  69. data/vendor/rake/lib/rake/lib/project.rake +24 -0
  70. data/vendor/rake/lib/rake/loaders/makefile.rb +44 -0
  71. data/vendor/rake/lib/rake/multi_task.rb +16 -0
  72. data/vendor/rake/lib/rake/name_space.rb +25 -0
  73. data/vendor/rake/lib/rake/packagetask.rb +184 -0
  74. data/vendor/rake/lib/rake/psuedo_status.rb +24 -0
  75. data/vendor/rake/lib/rake/rake_file_utils.rb +133 -0
  76. data/vendor/rake/lib/rake/rake_module.rb +25 -0
  77. data/vendor/rake/lib/rake/rake_test_loader.rb +15 -0
  78. data/vendor/rake/lib/rake/rdoctask.rb +209 -0
  79. data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +25 -0
  80. data/vendor/rake/lib/rake/rule_recursion_overflow_error.rb +20 -0
  81. data/vendor/rake/lib/rake/runtest.rb +23 -0
  82. data/vendor/rake/lib/rake/task.rb +318 -0
  83. data/vendor/rake/lib/rake/task_argument_error.rb +7 -0
  84. data/vendor/rake/lib/rake/task_arguments.rb +78 -0
  85. data/vendor/rake/lib/rake/task_manager.rb +328 -0
  86. data/vendor/rake/lib/rake/tasklib.rb +24 -0
  87. data/vendor/rake/lib/rake/testtask.rb +175 -0
  88. data/vendor/rake/lib/rake/win32.rb +55 -0
  89. data/vendor/rake/lib/rake.rb +72 -0
  90. data/vendor/rake/rake.blurb +19 -0
  91. data/vendor/rake/rake.gemspec +214 -0
  92. data/vendor/rake/rakelib/extra.rake +8 -0
  93. data/vendor/rake/rakelib/publish.rake +22 -0
  94. data/vendor/rake/rakelib/rbx.rake +82 -0
  95. data/vendor/rake/rakelib/ruby19.rake +88 -0
  96. data/vendor/rake/rakelib/tags.rake +18 -0
  97. data/vendor/rake/test/capture_stdout.rb +26 -0
  98. data/vendor/rake/test/check_expansion.rb +5 -0
  99. data/vendor/rake/test/check_no_expansion.rb +5 -0
  100. data/vendor/rake/test/contrib/test_sys.rb +47 -0
  101. data/vendor/rake/test/data/chains/Rakefile +15 -0
  102. data/vendor/rake/test/data/comments/Rakefile +18 -0
  103. data/vendor/rake/test/data/default/Rakefile +19 -0
  104. data/vendor/rake/test/data/dryrun/Rakefile +22 -0
  105. data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
  106. data/vendor/rake/test/data/imports/Rakefile +19 -0
  107. data/vendor/rake/test/data/imports/deps.mf +1 -0
  108. data/vendor/rake/test/data/multidesc/Rakefile +17 -0
  109. data/vendor/rake/test/data/namespace/Rakefile +66 -0
  110. data/vendor/rake/test/data/nosearch/dummy +1 -0
  111. data/vendor/rake/test/data/rakelib/test1.rb +5 -0
  112. data/vendor/rake/test/data/rakelib/test2.rake +3 -0
  113. data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
  114. data/vendor/rake/test/data/sample.mf +14 -0
  115. data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
  116. data/vendor/rake/test/data/sys/sys1.rake +3 -0
  117. data/vendor/rake/test/data/unittest/Rakefile +1 -0
  118. data/vendor/rake/test/data/unittest/subdir/README +0 -0
  119. data/vendor/rake/test/data/verbose/Rakefile +34 -0
  120. data/vendor/rake/test/filecreation.rb +32 -0
  121. data/vendor/rake/test/functional/functional_test.rb +15 -0
  122. data/vendor/rake/test/functional/session_based_tests.rb +442 -0
  123. data/vendor/rake/test/in_environment.rb +32 -0
  124. data/vendor/rake/test/lib/application_test.rb +769 -0
  125. data/vendor/rake/test/lib/clean_test.rb +15 -0
  126. data/vendor/rake/test/lib/definitions_test.rb +85 -0
  127. data/vendor/rake/test/lib/dsl_test.rb +41 -0
  128. data/vendor/rake/test/lib/earlytime_test.rb +35 -0
  129. data/vendor/rake/test/lib/environment_test.rb +18 -0
  130. data/vendor/rake/test/lib/extension_test.rb +63 -0
  131. data/vendor/rake/test/lib/file_creation_task_test.rb +62 -0
  132. data/vendor/rake/test/lib/file_task_test.rb +143 -0
  133. data/vendor/rake/test/lib/filelist_test.rb +623 -0
  134. data/vendor/rake/test/lib/fileutils_test.rb +251 -0
  135. data/vendor/rake/test/lib/ftp_test.rb +59 -0
  136. data/vendor/rake/test/lib/invocation_chain_test.rb +81 -0
  137. data/vendor/rake/test/lib/makefile_loader_test.rb +26 -0
  138. data/vendor/rake/test/lib/multitask_test.rb +53 -0
  139. data/vendor/rake/test/lib/namespace_test.rb +55 -0
  140. data/vendor/rake/test/lib/package_task_test.rb +118 -0
  141. data/vendor/rake/test/lib/pathmap_test.rb +210 -0
  142. data/vendor/rake/test/lib/pseudo_status_test.rb +26 -0
  143. data/vendor/rake/test/lib/rake_test.rb +41 -0
  144. data/vendor/rake/test/lib/rdoc_task_test.rb +88 -0
  145. data/vendor/rake/test/lib/require_test.rb +35 -0
  146. data/vendor/rake/test/lib/rules_test.rb +349 -0
  147. data/vendor/rake/test/lib/task_arguments_test.rb +89 -0
  148. data/vendor/rake/test/lib/task_manager_test.rb +173 -0
  149. data/vendor/rake/test/lib/task_test.rb +376 -0
  150. data/vendor/rake/test/lib/tasklib_test.rb +12 -0
  151. data/vendor/rake/test/lib/test_task_test.rb +77 -0
  152. data/vendor/rake/test/lib/testtask_test.rb +49 -0
  153. data/vendor/rake/test/lib/top_level_functions_test.rb +86 -0
  154. data/vendor/rake/test/lib/win32_test.rb +72 -0
  155. data/vendor/rake/test/rake_test_setup.rb +24 -0
  156. data/vendor/rake/test/reqfile.rb +3 -0
  157. data/vendor/rake/test/reqfile2.rb +3 -0
  158. data/vendor/rake/test/reqfile3.rake +3 -0
  159. data/vendor/rake/test/shellcommand.rb +3 -0
  160. data/vendor/rake/test/test_helper.rb +13 -0
  161. metadata +212 -56
  162. /data/{rush → vendor/rush}/README.rdoc +0 -0
  163. /data/{rush → vendor/rush}/Rakefile +0 -0
  164. /data/{rush → vendor/rush}/VERSION +0 -0
  165. /data/{rush → vendor/rush}/bin/rush +0 -0
  166. /data/{rush → vendor/rush}/bin/rushd +0 -0
  167. /data/{rush → vendor/rush}/lib/rush/access.rb +0 -0
  168. /data/{rush → vendor/rush}/lib/rush/array_ext.rb +0 -0
  169. /data/{rush → vendor/rush}/lib/rush/box.rb +0 -0
  170. /data/{rush → vendor/rush}/lib/rush/commands.rb +0 -0
  171. /data/{rush → vendor/rush}/lib/rush/config.rb +0 -0
  172. /data/{rush → vendor/rush}/lib/rush/dir.rb +0 -0
  173. /data/{rush → vendor/rush}/lib/rush/embeddable_shell.rb +0 -0
  174. /data/{rush → vendor/rush}/lib/rush/entry.rb +0 -0
  175. /data/{rush → vendor/rush}/lib/rush/exceptions.rb +0 -0
  176. /data/{rush → vendor/rush}/lib/rush/file.rb +0 -0
  177. /data/{rush → vendor/rush}/lib/rush/find_by.rb +0 -0
  178. /data/{rush → vendor/rush}/lib/rush/fixnum_ext.rb +0 -0
  179. /data/{rush → vendor/rush}/lib/rush/head_tail.rb +0 -0
  180. /data/{rush → vendor/rush}/lib/rush/local.rb +0 -0
  181. /data/{rush → vendor/rush}/lib/rush/process.rb +0 -0
  182. /data/{rush → vendor/rush}/lib/rush/process_set.rb +0 -0
  183. /data/{rush → vendor/rush}/lib/rush/remote.rb +0 -0
  184. /data/{rush → vendor/rush}/lib/rush/search_results.rb +0 -0
  185. /data/{rush → vendor/rush}/lib/rush/server.rb +0 -0
  186. /data/{rush → vendor/rush}/lib/rush/shell.rb +0 -0
  187. /data/{rush → vendor/rush}/lib/rush/ssh_tunnel.rb +0 -0
  188. /data/{rush → vendor/rush}/lib/rush/string_ext.rb +0 -0
  189. /data/{rush → vendor/rush}/lib/rush.rb +0 -0
  190. /data/{rush → vendor/rush}/rush.gemspec +0 -0
  191. /data/{rush → vendor/rush}/spec/access_spec.rb +0 -0
  192. /data/{rush → vendor/rush}/spec/array_ext_spec.rb +0 -0
  193. /data/{rush → vendor/rush}/spec/base.rb +0 -0
  194. /data/{rush → vendor/rush}/spec/box_spec.rb +0 -0
  195. /data/{rush → vendor/rush}/spec/commands_spec.rb +0 -0
  196. /data/{rush → vendor/rush}/spec/config_spec.rb +0 -0
  197. /data/{rush → vendor/rush}/spec/dir_spec.rb +0 -0
  198. /data/{rush → vendor/rush}/spec/embeddable_shell_spec.rb +0 -0
  199. /data/{rush → vendor/rush}/spec/entry_spec.rb +0 -0
  200. /data/{rush → vendor/rush}/spec/file_spec.rb +0 -0
  201. /data/{rush → vendor/rush}/spec/find_by_spec.rb +0 -0
  202. /data/{rush → vendor/rush}/spec/fixnum_ext_spec.rb +0 -0
  203. /data/{rush → vendor/rush}/spec/local_spec.rb +0 -0
  204. /data/{rush → vendor/rush}/spec/process_set_spec.rb +0 -0
  205. /data/{rush → vendor/rush}/spec/process_spec.rb +0 -0
  206. /data/{rush → vendor/rush}/spec/remote_spec.rb +0 -0
  207. /data/{rush → vendor/rush}/spec/rush_spec.rb +0 -0
  208. /data/{rush → vendor/rush}/spec/search_results_spec.rb +0 -0
  209. /data/{rush → vendor/rush}/spec/shell_spec.rb +0 -0
  210. /data/{rush → vendor/rush}/spec/ssh_tunnel_spec.rb +0 -0
  211. /data/{rush → vendor/rush}/spec/string_ext_spec.rb +0 -0
  212. /data/{session → vendor/session}/lib/session-2.4.0.rb +0 -0
  213. /data/{session → vendor/session}/lib/session.rb +0 -0
  214. /data/{session → vendor/session}/test/session.rb +0 -0
@@ -0,0 +1,579 @@
1
+ require 'shellwords'
2
+ require 'optparse'
3
+
4
+ require 'rake/task_manager'
5
+ require 'rake/win32'
6
+
7
+ module Rake
8
+
9
+ ######################################################################
10
+ # Rake main application object. When invoking +rake+ from the
11
+ # command line, a Rake::Application object is created and run.
12
+ #
13
+ class Application
14
+ include TaskManager
15
+
16
+ # The name of the application (typically 'rake')
17
+ attr_reader :name
18
+
19
+ # The original directory where rake was invoked.
20
+ attr_reader :original_dir
21
+
22
+ # Name of the actual rakefile used.
23
+ attr_reader :rakefile
24
+
25
+ # List of the top level task names (task names from the command line).
26
+ attr_reader :top_level_tasks
27
+
28
+ DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
29
+
30
+ # Initialize a Rake::Application object.
31
+ def initialize
32
+ super
33
+ @name = 'rake'
34
+ @rakefiles = DEFAULT_RAKEFILES.dup
35
+ @rakefile = nil
36
+ @pending_imports = []
37
+ @imported = []
38
+ @loaders = {}
39
+ @default_loader = Rake::DefaultLoader.new
40
+ @original_dir = Dir.pwd
41
+ @top_level_tasks = []
42
+ add_loader('rb', DefaultLoader.new)
43
+ add_loader('rf', DefaultLoader.new)
44
+ add_loader('rake', DefaultLoader.new)
45
+ @tty_output = STDOUT.tty?
46
+ end
47
+
48
+ # Run the Rake application. The run method performs the following
49
+ # three steps:
50
+ #
51
+ # * Initialize the command line options (+init+).
52
+ # * Define the tasks (+load_rakefile+).
53
+ # * Run the top level tasks (+run_tasks+).
54
+ #
55
+ # If you wish to build a custom rake command, you should call
56
+ # +init+ on your application. The define any tasks. Finally,
57
+ # call +top_level+ to run your top level tasks.
58
+ def run
59
+ standard_exception_handling do
60
+ init
61
+ load_rakefile
62
+ top_level
63
+ end
64
+ end
65
+
66
+ # Initialize the command line parameters and app name.
67
+ def init(app_name='rake')
68
+ standard_exception_handling do
69
+ @name = app_name
70
+ handle_options
71
+ collect_tasks
72
+ end
73
+ end
74
+
75
+ # Find the rakefile and then load it and any pending imports.
76
+ def load_rakefile
77
+ standard_exception_handling do
78
+ raw_load_rakefile
79
+ end
80
+ end
81
+
82
+ # Run the top level tasks of a Rake application.
83
+ def top_level
84
+ standard_exception_handling do
85
+ if options.show_tasks
86
+ display_tasks_and_comments
87
+ elsif options.show_prereqs
88
+ display_prerequisites
89
+ else
90
+ top_level_tasks.each { |task_name| invoke_task(task_name) }
91
+ end
92
+ end
93
+ end
94
+
95
+ # Add a loader to handle imported files ending in the extension
96
+ # +ext+.
97
+ def add_loader(ext, loader)
98
+ ext = ".#{ext}" unless ext =~ /^\./
99
+ @loaders[ext] = loader
100
+ end
101
+
102
+ # Application options from the command line
103
+ def options
104
+ @options ||= OpenStruct.new
105
+ end
106
+
107
+ # private ----------------------------------------------------------------
108
+
109
+ def invoke_task(task_string)
110
+ name, args = parse_task_string(task_string)
111
+ t = self[name]
112
+ t.invoke(*args)
113
+ end
114
+
115
+ def parse_task_string(string)
116
+ if string =~ /^([^\[]+)(\[(.*)\])$/
117
+ name = $1
118
+ args = $3.split(/\s*,\s*/)
119
+ else
120
+ name = string
121
+ args = []
122
+ end
123
+ [name, args]
124
+ end
125
+
126
+ # Provide standard execption handling for the given block.
127
+ def standard_exception_handling
128
+ begin
129
+ yield
130
+ rescue SystemExit => ex
131
+ # Exit silently with current status
132
+ raise
133
+ rescue OptionParser::InvalidOption => ex
134
+ $stderr.puts ex.message
135
+ exit(false)
136
+ rescue Exception => ex
137
+ # Exit with error message
138
+ display_error_message(ex)
139
+ exit(false)
140
+ end
141
+ end
142
+
143
+ # Display the error message that caused the exception.
144
+ def display_error_message(ex)
145
+ $stderr.puts "#{name} aborted!"
146
+ $stderr.puts ex.message
147
+ if options.trace
148
+ $stderr.puts ex.backtrace.join("\n")
149
+ else
150
+ $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
151
+ end
152
+ $stderr.puts "Tasks: #{ex.chain}" if has_chain?(ex)
153
+ $stderr.puts "(See full trace by running task with --trace)" unless options.trace
154
+ end
155
+
156
+ # Does the exception have a task invocation chain?
157
+ def has_chain?(exception)
158
+ exception.respond_to?(:chain) && exception.chain
159
+ end
160
+ private :has_chain?
161
+
162
+ # True if one of the files in RAKEFILES is in the current directory.
163
+ # If a match is found, it is copied into @rakefile.
164
+ def have_rakefile
165
+ @rakefiles.each do |fn|
166
+ if File.exist?(fn)
167
+ others = Dir.glob(fn, File::FNM_CASEFOLD)
168
+ return others.size == 1 ? others.first : fn
169
+ elsif fn == ''
170
+ return fn
171
+ end
172
+ end
173
+ return nil
174
+ end
175
+
176
+ # True if we are outputting to TTY, false otherwise
177
+ def tty_output?
178
+ @tty_output
179
+ end
180
+
181
+ # Override the detected TTY output state (mostly for testing)
182
+ def tty_output=( tty_output_state )
183
+ @tty_output = tty_output_state
184
+ end
185
+
186
+ # We will truncate output if we are outputting to a TTY or if we've been
187
+ # given an explicit column width to honor
188
+ def truncate_output?
189
+ tty_output? || ENV['RAKE_COLUMNS']
190
+ end
191
+
192
+ # Display the tasks and comments.
193
+ def display_tasks_and_comments
194
+ displayable_tasks = tasks.select { |t|
195
+ t.comment && t.name =~ options.show_task_pattern
196
+ }
197
+ case options.show_tasks
198
+ when :tasks
199
+ width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
200
+ max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
201
+ displayable_tasks.each do |t|
202
+ printf "#{name} %-#{width}s # %s\n",
203
+ t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
204
+ end
205
+ when :describe
206
+ displayable_tasks.each do |t|
207
+ puts "#{name} #{t.name_with_args}"
208
+ t.full_comment.split("\n").each do |line|
209
+ puts " #{line}"
210
+ end
211
+ puts
212
+ end
213
+ when :lines
214
+ displayable_tasks.each do |t|
215
+ t.locations.each do |loc|
216
+ printf "#{name} %-30s %s\n",t.name_with_args, loc
217
+ end
218
+ end
219
+ else
220
+ fail "Unknown show task mode: '#{options.show_tasks}'"
221
+ end
222
+ end
223
+
224
+ def terminal_width
225
+ if ENV['RAKE_COLUMNS']
226
+ result = ENV['RAKE_COLUMNS'].to_i
227
+ else
228
+ result = unix? ? dynamic_width : 80
229
+ end
230
+ (result < 10) ? 80 : result
231
+ rescue
232
+ 80
233
+ end
234
+
235
+ # Calculate the dynamic width of the
236
+ def dynamic_width
237
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
238
+ end
239
+
240
+ def dynamic_width_stty
241
+ %x{stty size 2>/dev/null}.split[1].to_i
242
+ end
243
+
244
+ def dynamic_width_tput
245
+ %x{tput cols 2>/dev/null}.to_i
246
+ end
247
+
248
+ def unix?
249
+ Config::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
250
+ end
251
+
252
+ def windows?
253
+ Win32.windows?
254
+ end
255
+
256
+ def truncate(string, width)
257
+ if string.length <= width
258
+ string
259
+ else
260
+ ( string[0, width-3] || "" ) + "..."
261
+ end
262
+ end
263
+
264
+ # Display the tasks and prerequisites
265
+ def display_prerequisites
266
+ tasks.each do |t|
267
+ puts "#{name} #{t.name}"
268
+ t.prerequisites.each { |pre| puts " #{pre}" }
269
+ end
270
+ end
271
+
272
+ # A list of all the standard options used in rake, suitable for
273
+ # passing to OptionParser.
274
+ def standard_rake_options
275
+ [
276
+ ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
277
+ lambda { |value|
278
+ require 'rake/classic_namespace'
279
+ options.classic_namespace = true
280
+ }
281
+ ],
282
+ ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
283
+ lambda { |value|
284
+ options.show_tasks = :describe
285
+ options.show_task_pattern = Regexp.new(value || '')
286
+ TaskManager.record_task_metadata = true
287
+ }
288
+ ],
289
+ ['--dry-run', '-n', "Do a dry run without executing actions.",
290
+ lambda { |value|
291
+ verbose(true)
292
+ nowrite(true)
293
+ options.dryrun = true
294
+ options.trace = true
295
+ }
296
+ ],
297
+ ['--execute', '-e CODE', "Execute some Ruby code and exit.",
298
+ lambda { |value|
299
+ eval(value)
300
+ exit
301
+ }
302
+ ],
303
+ ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
304
+ lambda { |value|
305
+ puts eval(value)
306
+ exit
307
+ }
308
+ ],
309
+ ['--execute-continue', '-E CODE',
310
+ "Execute some Ruby code, then continue with normal task processing.",
311
+ lambda { |value| eval(value) }
312
+ ],
313
+ ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
314
+ lambda { |value| $:.push(value) }
315
+ ],
316
+ ['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
317
+ lambda { |value| options.show_prereqs = true }
318
+ ],
319
+ ['--quiet', '-q', "Do not log messages to standard output.",
320
+ lambda { |value| verbose(false) }
321
+ ],
322
+ ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
323
+ lambda { |value|
324
+ value ||= ''
325
+ @rakefiles.clear
326
+ @rakefiles << value
327
+ }
328
+ ],
329
+ ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
330
+ "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
331
+ lambda { |value| options.rakelib = value.split(':') }
332
+ ],
333
+ ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
334
+ lambda { |value|
335
+ begin
336
+ require value
337
+ rescue LoadError => ex
338
+ begin
339
+ rake_require value
340
+ rescue LoadError => ex2
341
+ raise ex
342
+ end
343
+ end
344
+ }
345
+ ],
346
+ ['--rules', "Trace the rules resolution.",
347
+ lambda { |value| options.trace_rules = true }
348
+ ],
349
+ ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
350
+ lambda { |value| options.nosearch = true }
351
+ ],
352
+ ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
353
+ lambda { |value|
354
+ verbose(false)
355
+ options.silent = true
356
+ }
357
+ ],
358
+ ['--system', '-g',
359
+ "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
360
+ lambda { |value| options.load_system = true }
361
+ ],
362
+ ['--no-system', '--nosystem', '-G',
363
+ "Use standard project Rakefile search paths, ignore system wide rakefiles.",
364
+ lambda { |value| options.ignore_system = true }
365
+ ],
366
+ ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
367
+ lambda { |value|
368
+ options.show_tasks = :tasks
369
+ options.show_task_pattern = Regexp.new(value || '')
370
+ Rake::TaskManager.record_task_metadata = true
371
+ }
372
+ ],
373
+ ['--no-top-level-dsl', '-X', "Do no put Rake DSL commands in the top level scope.",
374
+ lambda { |value|
375
+ options.top_level_dsl = ! value
376
+ }
377
+ ],
378
+ ['--top-level-dsl', "Put Rake DSL commands in the top level scope (default).",
379
+ lambda { |value|
380
+ options.top_level_dsl = value
381
+ }
382
+ ],
383
+ ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
384
+ lambda { |value|
385
+ options.trace = true
386
+ verbose(true)
387
+ }
388
+ ],
389
+ ['--verbose', '-v', "Log message to standard output.",
390
+ lambda { |value| verbose(true) }
391
+ ],
392
+ ['--version', '-V', "Display the program version.",
393
+ lambda { |value|
394
+ puts "rake, version #{RAKEVERSION}"
395
+ exit
396
+ }
397
+ ],
398
+ ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
399
+ lambda { |value|
400
+ options.show_tasks = :lines
401
+ options.show_task_pattern = Regexp.new(value || '')
402
+ Rake::TaskManager.record_task_metadata = true
403
+ }
404
+ ],
405
+ ]
406
+ end
407
+
408
+ # Read and handle the command line options.
409
+ def handle_options
410
+ options.rakelib = ['rakelib']
411
+ options.top_level_dsl = true
412
+
413
+ OptionParser.new do |opts|
414
+ opts.banner = "rake [-f rakefile] {options} targets..."
415
+ opts.separator ""
416
+ opts.separator "Options are ..."
417
+
418
+ opts.on_tail("-h", "--help", "-H", "Display this help message.") do
419
+ puts opts
420
+ exit
421
+ end
422
+
423
+ standard_rake_options.each { |args| opts.on(*args) }
424
+ opts.environment('RAKEOPT')
425
+ end.parse!
426
+
427
+ Rake::DSL.include_in_top_scope if options.top_level_dsl
428
+
429
+ # If class namespaces are requested, set the global options
430
+ # according to the values in the options structure.
431
+ if options.classic_namespace
432
+ $show_tasks = options.show_tasks
433
+ $show_prereqs = options.show_prereqs
434
+ $trace = options.trace
435
+ $dryrun = options.dryrun
436
+ $silent = options.silent
437
+ end
438
+ end
439
+
440
+ # Similar to the regular Ruby +require+ command, but will check
441
+ # for *.rake files in addition to *.rb files.
442
+ def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
443
+ return false if loaded.include?(file_name)
444
+ paths.each do |path|
445
+ fn = file_name + ".rake"
446
+ full_path = File.join(path, fn)
447
+ if File.exist?(full_path)
448
+ Rake::Environment.load_rakefile(full_path)
449
+ loaded << fn
450
+ return true
451
+ end
452
+ end
453
+ fail LoadError, "Can't find #{file_name}"
454
+ end
455
+
456
+ def find_rakefile_location
457
+ here = Dir.pwd
458
+ while ! (fn = have_rakefile)
459
+ Dir.chdir("..")
460
+ if Dir.pwd == here || options.nosearch
461
+ return nil
462
+ end
463
+ here = Dir.pwd
464
+ end
465
+ [fn, here]
466
+ ensure
467
+ Dir.chdir(Rake.original_dir)
468
+ end
469
+
470
+ def raw_load_rakefile # :nodoc:
471
+ rakefile, location = find_rakefile_location
472
+ if (! options.ignore_system) &&
473
+ (options.load_system || rakefile.nil?) &&
474
+ system_dir && File.directory?(system_dir)
475
+ puts "(in #{Dir.pwd})" unless options.silent
476
+ glob("#{system_dir}/*.rake") do |name|
477
+ add_import name
478
+ end
479
+ else
480
+ fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if
481
+ rakefile.nil?
482
+ @rakefile = rakefile
483
+ Dir.chdir(location)
484
+ puts "(in #{Dir.pwd})" unless options.silent
485
+ $rakefile = @rakefile if options.classic_namespace
486
+ Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != ''
487
+ options.rakelib.each do |rlib|
488
+ glob("#{rlib}/*.rake") do |name|
489
+ add_import name
490
+ end
491
+ end
492
+ end
493
+ load_imports
494
+ end
495
+
496
+ def glob(path, &block)
497
+ Dir[path.gsub("\\", '/')].each(&block)
498
+ end
499
+ private :glob
500
+
501
+ # The directory path containing the system wide rakefiles.
502
+ def system_dir
503
+ @system_dir ||=
504
+ begin
505
+ if ENV['RAKE_SYSTEM']
506
+ ENV['RAKE_SYSTEM']
507
+ else
508
+ standard_system_dir
509
+ end
510
+ end
511
+ end
512
+
513
+ # The standard directory containing system wide rake files.
514
+ if Win32.windows?
515
+ def standard_system_dir #:nodoc:
516
+ Win32.win32_system_dir
517
+ end
518
+ else
519
+ def standard_system_dir #:nodoc:
520
+ File.join(File.expand_path('~'), '.rake')
521
+ end
522
+ end
523
+ private :standard_system_dir
524
+
525
+ # Collect the list of tasks on the command line. If no tasks are
526
+ # given, return a list containing only the default task.
527
+ # Environmental assignments are processed at this time as well.
528
+ def collect_tasks
529
+ @top_level_tasks = []
530
+ ARGV.each do |arg|
531
+ if arg =~ /^(\w+)=(.*)$/
532
+ ENV[$1] = $2
533
+ else
534
+ @top_level_tasks << arg unless arg =~ /^-/
535
+ end
536
+ end
537
+ @top_level_tasks.push("default") if @top_level_tasks.size == 0
538
+ end
539
+
540
+ # Add a file to the list of files to be imported.
541
+ def add_import(fn)
542
+ @pending_imports << fn
543
+ end
544
+
545
+ # Load the pending list of imported files.
546
+ def load_imports
547
+ while fn = @pending_imports.shift
548
+ next if @imported.member?(fn)
549
+ if fn_task = lookup(fn)
550
+ fn_task.invoke
551
+ end
552
+ ext = File.extname(fn)
553
+ loader = @loaders[ext] || @default_loader
554
+ loader.load(fn)
555
+ @imported << fn
556
+ end
557
+ end
558
+
559
+ # Warn about deprecated use of top level constant names.
560
+ def const_warning(const_name)
561
+ @const_warning ||= false
562
+ if ! @const_warning
563
+ $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } +
564
+ %{found at: #{rakefile_location}} # '
565
+ $stderr.puts %{ Use --classic-namespace on rake command}
566
+ $stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile}
567
+ end
568
+ @const_warning = true
569
+ end
570
+
571
+ def rakefile_location
572
+ begin
573
+ fail
574
+ rescue RuntimeError => ex
575
+ ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
576
+ end
577
+ end
578
+ end
579
+ end
@@ -0,0 +1,9 @@
1
+ # The following classes used to be in the top level namespace.
2
+ # Loading this file enables compatibility with older Rakefile that
3
+ # referenced Task from the top level.
4
+
5
+ puts "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake."
6
+ Task = Rake::Task
7
+ FileTask = Rake::FileTask
8
+ FileCreationTask = Rake::FileCreationTask
9
+ RakeApp = Rake::Application
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
4
+ # two rake tasks (:clean and :clobber).
5
+ #
6
+ # [:clean] Clean up the project by deleting scratch files and backup
7
+ # files. Add files to the CLEAN file list to have the :clean
8
+ # target handle them.
9
+ #
10
+ # [:clobber] Clobber all generated and non-source files in a project.
11
+ # The task depends on :clean, so all the clean files will
12
+ # be deleted as well as files in the CLOBBER file list.
13
+ # The intent of this task is to return a project to its
14
+ # pristine, just unpacked state.
15
+
16
+ require 'rake'
17
+
18
+ Rake::DSL.environment do
19
+ CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
20
+ CLEAN.clear_exclude.exclude { |fn|
21
+ fn.pathmap("%f") == 'core' && File.directory?(fn)
22
+ }
23
+
24
+ desc "Remove any temporary products."
25
+ task :clean do
26
+ CLEAN.each { |fn| rm_r fn rescue nil }
27
+ end
28
+
29
+ CLOBBER = Rake::FileList.new
30
+
31
+ desc "Remove any generated file."
32
+ task :clobber => [:clean] do
33
+ CLOBBER.each { |fn| rm_r fn rescue nil }
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ module Rake
2
+ # ##########################################################################
3
+ # Mixin for creating easily cloned objects.
4
+ #
5
+ module Cloneable
6
+ # Clone an object by making a new object and setting all the instance
7
+ # variables to the same values.
8
+ def dup
9
+ sibling = self.class.new
10
+ instance_variables.each do |ivar|
11
+ value = self.instance_variable_get(ivar)
12
+ new_value = value.clone rescue value
13
+ sibling.instance_variable_set(ivar, new_value)
14
+ end
15
+ sibling.taint if tainted?
16
+ sibling
17
+ end
18
+
19
+ def clone
20
+ sibling = dup
21
+ sibling.freeze if frozen?
22
+ sibling
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module Rake
4
+
5
+ # Manage several publishers as a single entity.
6
+ class CompositePublisher
7
+ def initialize
8
+ @publishers = []
9
+ end
10
+
11
+ # Add a publisher to the composite.
12
+ def add(pub)
13
+ @publishers << pub
14
+ end
15
+
16
+ # Upload all the individual publishers.
17
+ def upload
18
+ @publishers.each { |p| p.upload }
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+