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,328 @@
1
+ module Rake
2
+
3
+ # The TaskManager module is a mixin for managing tasks.
4
+ module TaskManager
5
+ # Track the last comment made in the Rakefile.
6
+ attr_accessor :last_description
7
+ alias :last_comment :last_description # Backwards compatibility
8
+
9
+ def initialize
10
+ super
11
+ @tasks = Hash.new
12
+ @rules = Array.new
13
+ @scope = Array.new
14
+ @last_description = nil
15
+ end
16
+
17
+ def create_rule(*args, &block)
18
+ pattern, arg_names, deps = resolve_args(args)
19
+ pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
20
+ @rules << [pattern, deps, block]
21
+ end
22
+
23
+ def define_task(task_class, *args, &block)
24
+ task_name, arg_names, deps = resolve_args(args)
25
+ task_name = task_class.scope_name(@scope, task_name)
26
+ deps = [deps] unless deps.respond_to?(:to_ary)
27
+ deps = deps.collect {|d| d.to_s }
28
+ task = intern(task_class, task_name)
29
+ task.set_arg_names(arg_names) unless arg_names.empty?
30
+ if Rake::TaskManager.record_task_metadata
31
+ add_location(task)
32
+ task.add_description(get_description(task))
33
+ end
34
+ task.enhance(deps, &block)
35
+ end
36
+
37
+ # Lookup a task. Return an existing task if found, otherwise
38
+ # create a task of the current type.
39
+ def intern(task_class, task_name)
40
+ @tasks[task_name.to_s] ||= task_class.new(task_name, self)
41
+ end
42
+
43
+ # Find a matching task for +task_name+.
44
+ def [](task_name, scopes=nil)
45
+ task_name = task_name.to_s
46
+ self.lookup(task_name, scopes) or
47
+ enhance_with_matching_rule(task_name) or
48
+ synthesize_file_task(task_name) or
49
+ fail "Don't know how to build task '#{task_name}'"
50
+ end
51
+
52
+ def synthesize_file_task(task_name)
53
+ return nil unless File.exist?(task_name)
54
+ define_task(Rake::FileTask, task_name)
55
+ end
56
+
57
+ # Resolve the arguments for a task/rule. Returns a triplet of
58
+ # [task_name, arg_name_list, prerequisites].
59
+ def resolve_args(args)
60
+ if args.last.is_a?(Hash)
61
+ deps = args.pop
62
+ resolve_args_with_dependencies(args, deps)
63
+ else
64
+ resolve_args_without_dependencies(args)
65
+ end
66
+ end
67
+
68
+ # Resolve task arguments for a task or rule when there are no
69
+ # dependencies declared.
70
+ #
71
+ # The patterns recognized by this argument resolving function are:
72
+ #
73
+ # task :t
74
+ # task :t, [:a]
75
+ # task :t, :a (deprecated)
76
+ #
77
+ def resolve_args_without_dependencies(args)
78
+ task_name = args.shift
79
+ if args.size == 1 && args.first.respond_to?(:to_ary)
80
+ arg_names = args.first.to_ary
81
+ else
82
+ arg_names = args
83
+ end
84
+ [task_name, arg_names, []]
85
+ end
86
+ private :resolve_args_without_dependencies
87
+
88
+ # Resolve task arguments for a task or rule when there are
89
+ # dependencies declared.
90
+ #
91
+ # The patterns recognized by this argument resolving function are:
92
+ #
93
+ # task :t => [:d]
94
+ # task :t, [a] => [:d]
95
+ # task :t, :needs => [:d] (deprecated)
96
+ # task :t, :a, :needs => [:d] (deprecated)
97
+ #
98
+ def resolve_args_with_dependencies(args, hash) # :nodoc:
99
+ fail "Task Argument Error" if hash.size != 1
100
+ key, value = hash.map { |k, v| [k,v] }.first
101
+ if args.empty?
102
+ task_name = key
103
+ arg_names = []
104
+ deps = value
105
+ elsif key == :needs
106
+ task_name = args.shift
107
+ arg_names = args
108
+ deps = value
109
+ else
110
+ task_name = args.shift
111
+ arg_names = key
112
+ deps = value
113
+ end
114
+ deps = [deps] unless deps.respond_to?(:to_ary)
115
+ [task_name, arg_names, deps]
116
+ end
117
+ private :resolve_args_with_dependencies
118
+
119
+ # If a rule can be found that matches the task name, enhance the
120
+ # task with the prerequisites and actions from the rule. Set the
121
+ # source attribute of the task appropriately for the rule. Return
122
+ # the enhanced task or nil of no rule was found.
123
+ def enhance_with_matching_rule(task_name, level=0)
124
+ fail Rake::RuleRecursionOverflowError,
125
+ "Rule Recursion Too Deep" if level >= 16
126
+ @rules.each do |pattern, extensions, block|
127
+ if md = pattern.match(task_name)
128
+ task = attempt_rule(task_name, extensions, block, level)
129
+ return task if task
130
+ end
131
+ end
132
+ nil
133
+ rescue Rake::RuleRecursionOverflowError => ex
134
+ ex.add_target(task_name)
135
+ fail ex
136
+ end
137
+
138
+ # List of all defined tasks in this application.
139
+ def tasks
140
+ @tasks.values.sort_by { |t| t.name }
141
+ end
142
+
143
+ # List of all the tasks defined in the given scope (and its
144
+ # sub-scopes).
145
+ def tasks_in_scope(scope)
146
+ prefix = scope.join(":")
147
+ tasks.select { |t|
148
+ /^#{prefix}:/ =~ t.name
149
+ }
150
+ end
151
+
152
+ # Clear all tasks in this application.
153
+ def clear
154
+ @tasks.clear
155
+ @rules.clear
156
+ end
157
+
158
+ # Lookup a task, using scope and the scope hints in the task name.
159
+ # This method performs straight lookups without trying to
160
+ # synthesize file tasks or rules. Special scope names (e.g. '^')
161
+ # are recognized. If no scope argument is supplied, use the
162
+ # current scope. Return nil if the task cannot be found.
163
+ def lookup(task_name, initial_scope=nil)
164
+ initial_scope ||= @scope
165
+ task_name = task_name.to_s
166
+ if task_name =~ /^rake:/
167
+ scopes = []
168
+ task_name = task_name.sub(/^rake:/, '')
169
+ elsif task_name =~ /^(\^+)/
170
+ scopes = initial_scope[0, initial_scope.size - $1.size]
171
+ task_name = task_name.sub(/^(\^+)/, '')
172
+ else
173
+ scopes = initial_scope
174
+ end
175
+ lookup_in_scope(task_name, scopes)
176
+ end
177
+
178
+ # Lookup the task name
179
+ def lookup_in_scope(name, scope)
180
+ n = scope.size
181
+ while n >= 0
182
+ tn = (scope[0,n] + [name]).join(':')
183
+ task = @tasks[tn]
184
+ return task if task
185
+ n -= 1
186
+ end
187
+ nil
188
+ end
189
+ private :lookup_in_scope
190
+
191
+ # Return the list of scope names currently active in the task
192
+ # manager.
193
+ def current_scope
194
+ @scope.dup
195
+ end
196
+
197
+ # Evaluate the block in a nested namespace named +name+. Create
198
+ # an anonymous namespace if +name+ is nil.
199
+ def in_namespace(name)
200
+ name ||= generate_name
201
+ @scope.push(name)
202
+ ns = NameSpace.new(self, @scope)
203
+ yield(ns)
204
+ ns
205
+ ensure
206
+ @scope.pop
207
+ end
208
+
209
+ private
210
+
211
+ # Add a location to the locations field of the given task.
212
+ def add_location(task)
213
+ loc = find_location
214
+ task.locations << loc if loc
215
+ task
216
+ end
217
+
218
+ # Find the location that called into the dsl layer.
219
+ def find_location
220
+ locations = caller
221
+ i = 0
222
+ while locations[i]
223
+ return locations[i+1] if locations[i] =~ /rake\/dsl.rb/
224
+ i += 1
225
+ end
226
+ nil
227
+ end
228
+
229
+ # Generate an anonymous namespace name.
230
+ def generate_name
231
+ @seed ||= 0
232
+ @seed += 1
233
+ "_anon_#{@seed}"
234
+ end
235
+
236
+ def trace_rule(level, message)
237
+ puts "#{" "*level}#{message}" if Rake.application.options.trace_rules
238
+ end
239
+
240
+ # Attempt to create a rule given the list of prerequisites.
241
+ def attempt_rule(task_name, extensions, block, level)
242
+ sources = make_sources(task_name, extensions)
243
+ prereqs = sources.collect { |source|
244
+ trace_rule level, "Attempting Rule #{task_name} => #{source}"
245
+ if File.exist?(source) || Rake::Task.task_defined?(source)
246
+ trace_rule level, "(#{task_name} => #{source} ... EXIST)"
247
+ source
248
+ elsif parent = enhance_with_matching_rule(source, level+1)
249
+ trace_rule level, "(#{task_name} => #{source} ... ENHANCE)"
250
+ parent.name
251
+ else
252
+ trace_rule level, "(#{task_name} => #{source} ... FAIL)"
253
+ return nil
254
+ end
255
+ }
256
+ task = FileTask.define_task({task_name => prereqs}, &block)
257
+ task.sources = prereqs
258
+ task
259
+ end
260
+
261
+ # Make a list of sources from the list of file name extensions /
262
+ # translation procs.
263
+ def make_sources(task_name, extensions)
264
+ extensions.collect { |ext|
265
+ case ext
266
+ when /%/
267
+ task_name.pathmap(ext)
268
+ when %r{/}
269
+ ext
270
+ when /^\./
271
+ task_name.ext(ext)
272
+ when String
273
+ ext
274
+ when Proc
275
+ if ext.arity == 1
276
+ ext.call(task_name)
277
+ else
278
+ ext.call
279
+ end
280
+ else
281
+ fail "Don't know how to handle rule dependent: #{ext.inspect}"
282
+ end
283
+ }.flatten
284
+ end
285
+
286
+
287
+ private
288
+
289
+ # Return the current description. If there isn't one, try to find it
290
+ # by reading in the source file and looking for a comment immediately
291
+ # prior to the task definition
292
+ def get_description(task)
293
+ desc = @last_description || find_preceding_comment_for_task(task)
294
+ @last_description = nil
295
+ desc
296
+ end
297
+
298
+ def find_preceding_comment_for_task(task)
299
+ loc = task.locations.last
300
+ file_name, line = parse_location(loc)
301
+ return nil unless file_name
302
+ comment_from_file(file_name, line)
303
+ end
304
+
305
+ def parse_location(loc)
306
+ if loc =~ /^(.*):(\d+)/
307
+ [ $1, Integer($2) ]
308
+ else
309
+ nil
310
+ end
311
+ end
312
+
313
+ def comment_from_file(file_name, line)
314
+ return if file_name == '(eval)'
315
+ @file_cache ||= {}
316
+ content = (@file_cache[file_name] ||= File.readlines(file_name))
317
+ line -= 2
318
+ return nil unless content[line] =~ /^\s*#\s*(.*)/
319
+ $1
320
+ end
321
+
322
+ class << self
323
+ attr_accessor :record_task_metadata
324
+ TaskManager.record_task_metadata = false
325
+ end
326
+ end
327
+
328
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+
5
+ module Rake
6
+
7
+ # Base class for Task Libraries.
8
+ class TaskLib
9
+ include Cloneable
10
+ include Rake::DSL
11
+
12
+ # Make a symbol by pasting two strings together.
13
+ #
14
+ # NOTE: DEPRECATED! This method is kinda stupid. I don't know why
15
+ # I didn't just use string interpolation. But now other task
16
+ # libraries depend on this so I can't remove it without breaking
17
+ # other people's code. So for now it stays for backwards
18
+ # compatibility. BUT DON'T USE IT.
19
+ def paste(a,b) # :nodoc:
20
+ (a.to_s + b.to_s).intern
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Define a task library for running unit tests.
4
+
5
+ require 'rake'
6
+ require 'rake/tasklib'
7
+
8
+ module Rake
9
+
10
+ # Create a task that runs a set of tests.
11
+ #
12
+ # Example:
13
+ #
14
+ # Rake::TestTask.new do |t|
15
+ # t.libs << "test"
16
+ # t.test_files = FileList['test/test*.rb']
17
+ # t.verbose = true
18
+ # end
19
+ #
20
+ # If rake is invoked with a "TEST=filename" command line option,
21
+ # then the list of test files will be overridden to include only the
22
+ # filename specified on the command line. This provides an easy way
23
+ # to run just one test.
24
+ #
25
+ # If rake is invoked with a "TESTOPTS=options" command line option,
26
+ # then the given options are passed to the test process after a
27
+ # '--'. This allows Test::Unit options to be passed to the test
28
+ # suite.
29
+ #
30
+ # Examples:
31
+ #
32
+ # rake test # run tests normally
33
+ # rake test TEST=just_one_file.rb # run just one test file.
34
+ # rake test TESTOPTS="-v" # run in verbose mode
35
+ # rake test TESTOPTS="--runner=fox" # use the fox test runner
36
+ #
37
+ class TestTask < TaskLib
38
+
39
+ # Name of test task. (default is :test)
40
+ attr_accessor :name
41
+
42
+ # List of directories to added to $LOAD_PATH before running the
43
+ # tests. (default is 'lib')
44
+ attr_accessor :libs
45
+
46
+ # True if verbose test output desired. (default is false)
47
+ attr_accessor :verbose
48
+
49
+ # Test options passed to the test suite. An explicit
50
+ # TESTOPTS=opts on the command line will override this. (default
51
+ # is NONE)
52
+ attr_accessor :options
53
+
54
+ # Request that the tests be run with the warning flag set.
55
+ # E.g. warning=true implies "ruby -w" used to run the tests.
56
+ attr_accessor :warning
57
+
58
+ # Glob pattern to match test files. (default is 'test/test*.rb')
59
+ attr_accessor :pattern
60
+
61
+ # Style of test loader to use. Options are:
62
+ #
63
+ # * :rake -- Rake provided test loading script (default).
64
+ # * :testrb -- Ruby provided test loading script.
65
+ # * :direct -- Load tests using command line loader.
66
+ #
67
+ attr_accessor :loader
68
+
69
+ # Array of commandline options to pass to ruby when running test loader.
70
+ attr_accessor :ruby_opts
71
+
72
+ # Explicitly define the list of test files to be included in a
73
+ # test. +list+ is expected to be an array of file names (a
74
+ # FileList is acceptable). If both +pattern+ and +test_files+ are
75
+ # used, then the list of test files is the union of the two.
76
+ def test_files=(list)
77
+ @test_files = list
78
+ end
79
+
80
+ # Create a testing task.
81
+ def initialize(name=:test)
82
+ @name = name
83
+ @libs = ["lib"]
84
+ @pattern = nil
85
+ @options = nil
86
+ @test_files = nil
87
+ @verbose = false
88
+ @warning = false
89
+ @loader = :rake
90
+ @ruby_opts = []
91
+ yield self if block_given?
92
+ @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
93
+ define
94
+ end
95
+
96
+ # Create the tasks defined by this task lib.
97
+ def define
98
+ desc "Run tests" + (@name==:test ? "" : " for #{@name}")
99
+ task @name do
100
+ RakeFileUtils.verbose(@verbose) do
101
+ ruby "#{ruby_opts_string} #{run_code} #{file_list_string} #{option_list}"
102
+ end
103
+ end
104
+ self
105
+ end
106
+
107
+ def option_list # :nodoc:
108
+ ENV['TESTOPTS'] || @options || ""
109
+ end
110
+
111
+ def ruby_opts_string
112
+ opts = @ruby_opts.dup
113
+ opts.unshift( "-I\"#{lib_path}\"" ) unless @libs.empty?
114
+ opts.unshift( "-w" ) if @warning
115
+ opts.join(" ")
116
+ end
117
+
118
+ def lib_path
119
+ @libs.join(File::PATH_SEPARATOR)
120
+ end
121
+
122
+ def file_list_string
123
+ file_list.collect { |fn| "\"#{fn}\"" }.join(' ')
124
+ end
125
+
126
+ def file_list # :nodoc:
127
+ if ENV['TEST']
128
+ FileList[ ENV['TEST'] ]
129
+ else
130
+ result = []
131
+ result += @test_files.to_a if @test_files
132
+ result << @pattern if @pattern
133
+ result
134
+ end
135
+ end
136
+
137
+ def fix # :nodoc:
138
+ case ruby_version
139
+ when '1.8.2'
140
+ "\"#{find_file 'rake/ruby182_test_unit_fix'}\""
141
+ else
142
+ nil
143
+ end || ''
144
+ end
145
+
146
+ def ruby_version
147
+ RUBY_VERSION
148
+ end
149
+
150
+ def run_code
151
+ case @loader
152
+ when :direct
153
+ "-e \"ARGV.each{|f| load f}\""
154
+ when :testrb
155
+ "-S testrb #{fix}"
156
+ when :rake
157
+ "\"#{rake_loader}\""
158
+ end
159
+ end
160
+
161
+ def rake_loader # :nodoc:
162
+ find_file('rake/rake_test_loader') or
163
+ fail "unable to find rake test loader"
164
+ end
165
+
166
+ def find_file(fn) # :nodoc:
167
+ $LOAD_PATH.each do |path|
168
+ file_path = File.join(path, "#{fn}.rb")
169
+ return file_path if File.exist? file_path
170
+ end
171
+ nil
172
+ end
173
+
174
+ end
175
+ end
@@ -0,0 +1,55 @@
1
+
2
+ module Rake
3
+ require 'rake/alt_system'
4
+
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
8
+
9
+ # Error indicating a problem in locating the home directory on a
10
+ # Win32 system.
11
+ class Win32HomeError < RuntimeError
12
+ end
13
+
14
+ class << self
15
+ # True if running on a windows system.
16
+ def windows?
17
+ AltSystem::WINDOWS
18
+ end
19
+
20
+ # Run a command line on windows.
21
+ def rake_system(*cmd)
22
+ AltSystem.system(*cmd)
23
+ end
24
+
25
+ # The standard directory containing system wide rake files on
26
+ # Win 32 systems. Try the following environment variables (in
27
+ # order):
28
+ #
29
+ # * HOME
30
+ # * HOMEDRIVE + HOMEPATH
31
+ # * APPDATA
32
+ # * USERPROFILE
33
+ #
34
+ # If the above are not defined, the return nil.
35
+ def win32_system_dir #:nodoc:
36
+ win32_shared_path = ENV['HOME']
37
+ if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH']
38
+ win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
39
+ end
40
+
41
+ win32_shared_path ||= ENV['APPDATA']
42
+ win32_shared_path ||= ENV['USERPROFILE']
43
+ raise Win32HomeError, "Unable to determine home path environment variable." if
44
+ win32_shared_path.nil? or win32_shared_path.empty?
45
+ normalize(File.join(win32_shared_path, 'Rake'))
46
+ end
47
+
48
+ # Normalize a win32 path so that the slashes are all forward slashes.
49
+ def normalize(path)
50
+ path.gsub(/\\/, '/')
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #--
4
+
5
+ # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by Jim Weirich (jim.weirich@gmail.com)
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to
9
+ # deal in the Software without restriction, including without limitation the
10
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
+ # sell copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
+ # IN THE SOFTWARE.
24
+ #++
25
+
26
+ RAKEVERSION = '0.8.99.3'
27
+
28
+ require 'rbconfig'
29
+ require 'fileutils'
30
+ require 'singleton'
31
+ require 'monitor'
32
+ require 'optparse'
33
+ require 'ostruct'
34
+
35
+ require 'rake/ext/module'
36
+ require 'rake/ext/string'
37
+ require 'rake/ext/time'
38
+
39
+ require 'rake/win32'
40
+
41
+ require 'rake/task_argument_error'
42
+ require 'rake/rule_recursion_overflow_error'
43
+ require 'rake/rake_module'
44
+ require 'rake/psuedo_status'
45
+ require 'rake/task_arguments'
46
+ require 'rake/invocation_chain'
47
+ require 'rake/task'
48
+ require 'rake/file_task'
49
+ require 'rake/file_creation_task'
50
+ require 'rake/multi_task'
51
+ require 'rake/dsl'
52
+ require 'rake/rake_file_utils'
53
+ require 'rake/file_list'
54
+ require 'rake/default_loader'
55
+ require 'rake/early_time'
56
+ require 'rake/name_space'
57
+ require 'rake/task_manager'
58
+ require 'rake/application'
59
+ require 'rake/environment'
60
+
61
+ $trace = false
62
+
63
+ # Alias FileList to be available at the top level.
64
+ FileList = Rake::FileList
65
+
66
+ # Include the FileUtils file manipulation functions in the top level module,
67
+ # but mark them private so that they don't unintentionally define methods on
68
+ # other objects.
69
+
70
+ include RakeFileUtils
71
+ private(*FileUtils.instance_methods(false))
72
+ private(*RakeFileUtils.instance_methods(false))
@@ -0,0 +1,19 @@
1
+ name: rake
2
+ document: http://rake.rubyforge.org
3
+ download: http://rubyforge.org/project/showfiles.php?group_id=50
4
+ description: >
5
+ <p>This package contains Rake, a simple ruby build program with
6
+ capabilities similar to make.</p>
7
+
8
+ <p> Rake has the following features: </p>
9
+
10
+ <ul>
11
+ <li>Rakefiles (rake&#8217;s version of Makefiles) are completely
12
+ defined in standard Ruby syntax. No XML files to edit. No quirky
13
+ Makefile syntax to worry about (is that a tab or a space?)</li>
14
+ <li>Users can specify tasks with prerequisites.</li>
15
+ <li>Rake supports rule patterns to sythesize implicit tasks.</li>
16
+ <li>Rake is lightweight. It can be distributed with other
17
+ projects as a single file. Projects that depend upon rake do not
18
+ require that rake be installed on target systems.</li>
19
+ </ul>