bpm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. data/.gitignore +4 -0
  2. data/.gitmodules +0 -0
  3. data/Gemfile +16 -0
  4. data/README.md +55 -0
  5. data/TODO.md +3 -0
  6. data/bin/bpm +8 -0
  7. data/bpm.gemspec +41 -0
  8. data/lib/bpm.rb +18 -0
  9. data/lib/bpm/cli.rb +6 -0
  10. data/lib/bpm/cli/base.rb +358 -0
  11. data/lib/bpm/cli/owner.rb +46 -0
  12. data/lib/bpm/credentials.rb +36 -0
  13. data/lib/bpm/default.json +9 -0
  14. data/lib/bpm/generator.rb +69 -0
  15. data/lib/bpm/init_generator.rb +43 -0
  16. data/lib/bpm/libgems_ext.rb +11 -0
  17. data/lib/bpm/libgems_ext/config_file.rb +33 -0
  18. data/lib/bpm/libgems_ext/dependency_installer.rb +150 -0
  19. data/lib/bpm/libgems_ext/installer.rb +39 -0
  20. data/lib/bpm/libgems_ext/libgems.rb +39 -0
  21. data/lib/bpm/libgems_ext/spec_fetcher.rb +11 -0
  22. data/lib/bpm/local.rb +76 -0
  23. data/lib/bpm/package.rb +277 -0
  24. data/lib/bpm/pipeline.rb +100 -0
  25. data/lib/bpm/pipeline/directive_processor.rb +47 -0
  26. data/lib/bpm/pipeline/generated_asset.rb +68 -0
  27. data/lib/bpm/pipeline/transport_processor.rb +32 -0
  28. data/lib/bpm/project.rb +427 -0
  29. data/lib/bpm/project_generator.rb +34 -0
  30. data/lib/bpm/remote.rb +104 -0
  31. data/lib/bpm/repository.rb +18 -0
  32. data/lib/bpm/server.rb +44 -0
  33. data/lib/bpm/version.rb +3 -0
  34. data/spec/cli/add_spec.rb +159 -0
  35. data/spec/cli/build_spec.rb +87 -0
  36. data/spec/cli/fetch_spec.rb +135 -0
  37. data/spec/cli/fetched_spec.rb +52 -0
  38. data/spec/cli/init_spec.rb +50 -0
  39. data/spec/cli/list_spec.rb +74 -0
  40. data/spec/cli/login_spec.rb +110 -0
  41. data/spec/cli/new_spec.rb +92 -0
  42. data/spec/cli/owner_spec.rb +114 -0
  43. data/spec/cli/push_spec.rb +73 -0
  44. data/spec/cli/remove_spec.rb +84 -0
  45. data/spec/cli/unpack_spec.rb +72 -0
  46. data/spec/cli/unyank_spec.rb +73 -0
  47. data/spec/cli/yank_spec.rb +73 -0
  48. data/spec/credentials_spec.rb +23 -0
  49. data/spec/fixtures/badrake-0.8.7.spd +0 -0
  50. data/spec/fixtures/builder-3.0.0.spd +0 -0
  51. data/spec/fixtures/bundler-1.1.pre.spd +0 -0
  52. data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
  53. data/spec/fixtures/core-test-0.4.9.spd +0 -0
  54. data/spec/fixtures/core-test/bin/cot +3 -0
  55. data/spec/fixtures/core-test/lib/main.js +1 -0
  56. data/spec/fixtures/core-test/package.json +46 -0
  57. data/spec/fixtures/core-test/resources/runner.css +1 -0
  58. data/spec/fixtures/core-test/tests/test.js +1 -0
  59. data/spec/fixtures/custom_generator-1.0.spd +0 -0
  60. data/spec/fixtures/custom_generator/lib/main.js +1 -0
  61. data/spec/fixtures/custom_generator/package.json +12 -0
  62. data/spec/fixtures/custom_generator/templates/init/project.json +19 -0
  63. data/spec/fixtures/custom_generator/templates/project/app.js +1 -0
  64. data/spec/fixtures/custom_generator/templates/project/lib/main.js +0 -0
  65. data/spec/fixtures/custom_generator/templates/project_generator.rb +20 -0
  66. data/spec/fixtures/hello_world/LICENSE +19 -0
  67. data/spec/fixtures/hello_world/README.md +21 -0
  68. data/spec/fixtures/hello_world/assets/bpm_packages.js +13 -0
  69. data/spec/fixtures/hello_world/assets/bpm_styles.css +14 -0
  70. data/spec/fixtures/hello_world/assets/papa-smurf.jpg +0 -0
  71. data/spec/fixtures/hello_world/hello_world.json +20 -0
  72. data/spec/fixtures/hello_world/lib/main.js +9 -0
  73. data/spec/fixtures/hello_world/packages/custom_package/assets/dummy.txt +1 -0
  74. data/spec/fixtures/hello_world/packages/custom_package/css/sample_styles.css +3 -0
  75. data/spec/fixtures/hello_world/packages/custom_package/custom_dir/basic-module.js +1 -0
  76. data/spec/fixtures/hello_world/packages/custom_package/lib/main.js +1 -0
  77. data/spec/fixtures/hello_world/packages/custom_package/package.json +22 -0
  78. data/spec/fixtures/hello_world/tests/main-test.js +8 -0
  79. data/spec/fixtures/highline-1.6.1.spd +0 -0
  80. data/spec/fixtures/ivory-0.0.1.spd +0 -0
  81. data/spec/fixtures/jquery-1.4.3.spd +0 -0
  82. data/spec/fixtures/optparse-1.0.1.spd +0 -0
  83. data/spec/fixtures/rake-0.8.6.spd +0 -0
  84. data/spec/fixtures/rake-0.8.7.spd +0 -0
  85. data/spec/fixtures/simple_hello/assets/bpm_packages.js +1 -0
  86. data/spec/fixtures/simple_hello/lib/main.js +1 -0
  87. data/spec/fixtures/spade-0.5.0.spd +0 -0
  88. data/spec/fixtures/src/README.txt +1 -0
  89. data/spec/fixtures/src/bundler-1.1.pre/.gitignore +22 -0
  90. data/spec/fixtures/src/bundler-1.1.pre/CHANGELOG.md +646 -0
  91. data/spec/fixtures/src/bundler-1.1.pre/ISSUES.md +47 -0
  92. data/spec/fixtures/src/bundler-1.1.pre/LICENSE +21 -0
  93. data/spec/fixtures/src/bundler-1.1.pre/README.md +29 -0
  94. data/spec/fixtures/src/bundler-1.1.pre/UPGRADING.md +103 -0
  95. data/spec/fixtures/src/bundler-1.1.pre/bin/bundle +20 -0
  96. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler.js +23 -0
  97. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/definition.js +14 -0
  98. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/dependency.js +15 -0
  99. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/dsl.js +9 -0
  100. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/ui.js +6 -0
  101. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-config.ronn +90 -0
  102. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-exec.ronn +111 -0
  103. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-install.ronn +314 -0
  104. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-package.ronn +59 -0
  105. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-update.ronn +176 -0
  106. data/spec/fixtures/src/bundler-1.1.pre/man/bundle.ronn +80 -0
  107. data/spec/fixtures/src/bundler-1.1.pre/man/gemfile.5.ronn +279 -0
  108. data/spec/fixtures/src/bundler-1.1.pre/man/index.txt +6 -0
  109. data/spec/fixtures/src/bundler-1.1.pre/package.json +19 -0
  110. data/spec/fixtures/src/coffee-1.0.1.pre/bin/cake +0 -0
  111. data/spec/fixtures/src/coffee-1.0.1.pre/bin/coffee +0 -0
  112. data/spec/fixtures/src/coffee-1.0.1.pre/lib/coffee.js +0 -0
  113. data/spec/fixtures/src/coffee-1.0.1.pre/lib/coffee/base.js +0 -0
  114. data/spec/fixtures/src/coffee-1.0.1.pre/lib/coffee/mocha/chai.js +0 -0
  115. data/spec/fixtures/src/coffee-1.0.1.pre/package.json +19 -0
  116. data/spec/fixtures/src/coffee-1.0.1.pre/qunit/coffee/test.js +0 -0
  117. data/spec/fixtures/src/coffee-1.0.1.pre/qunit/test.js +0 -0
  118. data/spec/fixtures/src/jquery/lib/main.js +7179 -0
  119. data/spec/fixtures/src/jquery/package.json +15 -0
  120. data/spec/fixtures/src/rake-0.8.6/CHANGES +436 -0
  121. data/spec/fixtures/src/rake-0.8.6/MIT-LICENSE +21 -0
  122. data/spec/fixtures/src/rake-0.8.6/README +196 -0
  123. data/spec/fixtures/src/rake-0.8.6/Rakefile +430 -0
  124. data/spec/fixtures/src/rake-0.8.6/TODO +20 -0
  125. data/spec/fixtures/src/rake-0.8.6/bin/rake +31 -0
  126. data/spec/fixtures/src/rake-0.8.6/doc/command_line_usage.rdoc +102 -0
  127. data/spec/fixtures/src/rake-0.8.6/doc/example/Rakefile1 +38 -0
  128. data/spec/fixtures/src/rake-0.8.6/doc/example/Rakefile2 +35 -0
  129. data/spec/fixtures/src/rake-0.8.6/doc/example/a.c +6 -0
  130. data/spec/fixtures/src/rake-0.8.6/doc/example/b.c +6 -0
  131. data/spec/fixtures/src/rake-0.8.6/doc/example/main.c +11 -0
  132. data/spec/fixtures/src/rake-0.8.6/doc/glossary.rdoc +51 -0
  133. data/spec/fixtures/src/rake-0.8.6/doc/jamis.rb +591 -0
  134. data/spec/fixtures/src/rake-0.8.6/doc/proto_rake.rdoc +127 -0
  135. data/spec/fixtures/src/rake-0.8.6/doc/rake.1.gz +0 -0
  136. data/spec/fixtures/src/rake-0.8.6/doc/rakefile.rdoc +534 -0
  137. data/spec/fixtures/src/rake-0.8.6/doc/rational.rdoc +151 -0
  138. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.4.14.rdoc +23 -0
  139. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.4.15.rdoc +35 -0
  140. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.5.0.rdoc +53 -0
  141. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.5.3.rdoc +78 -0
  142. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.5.4.rdoc +46 -0
  143. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.6.0.rdoc +141 -0
  144. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.0.rdoc +119 -0
  145. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.1.rdoc +59 -0
  146. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.2.rdoc +121 -0
  147. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.3.rdoc +47 -0
  148. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.0.rdoc +114 -0
  149. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.2.rdoc +165 -0
  150. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.3.rdoc +112 -0
  151. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.4.rdoc +147 -0
  152. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.5.rdoc +53 -0
  153. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.6.rdoc +55 -0
  154. data/spec/fixtures/src/rake-0.8.6/install.rb +88 -0
  155. data/spec/fixtures/src/rake-0.8.6/lib/rake.rb +2502 -0
  156. data/spec/fixtures/src/rake-0.8.6/lib/rake/alt_system.rb +108 -0
  157. data/spec/fixtures/src/rake-0.8.6/lib/rake/classic_namespace.rb +8 -0
  158. data/spec/fixtures/src/rake-0.8.6/lib/rake/clean.rb +33 -0
  159. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/compositepublisher.rb +24 -0
  160. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/ftptools.rb +153 -0
  161. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/publisher.rb +75 -0
  162. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  163. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/sshpublisher.rb +47 -0
  164. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/sys.rb +209 -0
  165. data/spec/fixtures/src/rake-0.8.6/lib/rake/gempackagetask.rb +97 -0
  166. data/spec/fixtures/src/rake-0.8.6/lib/rake/loaders/makefile.rb +42 -0
  167. data/spec/fixtures/src/rake-0.8.6/lib/rake/packagetask.rb +184 -0
  168. data/spec/fixtures/src/rake-0.8.6/lib/rake/rake_test_loader.rb +5 -0
  169. data/spec/fixtures/src/rake-0.8.6/lib/rake/rdoctask.rb +209 -0
  170. data/spec/fixtures/src/rake-0.8.6/lib/rake/ruby182_test_unit_fix.rb +23 -0
  171. data/spec/fixtures/src/rake-0.8.6/lib/rake/runtest.rb +23 -0
  172. data/spec/fixtures/src/rake-0.8.6/lib/rake/tasklib.rb +23 -0
  173. data/spec/fixtures/src/rake-0.8.6/lib/rake/testtask.rb +161 -0
  174. data/spec/fixtures/src/rake-0.8.6/lib/rake/win32.rb +55 -0
  175. data/spec/fixtures/src/rake-0.8.6/package.json +18 -0
  176. data/spec/fixtures/src/rake-0.8.6/test/capture_stdout.rb +26 -0
  177. data/spec/fixtures/src/rake-0.8.7/CHANGES +440 -0
  178. data/spec/fixtures/src/rake-0.8.7/MIT-LICENSE +21 -0
  179. data/spec/fixtures/src/rake-0.8.7/README +196 -0
  180. data/spec/fixtures/src/rake-0.8.7/Rakefile +430 -0
  181. data/spec/fixtures/src/rake-0.8.7/TODO +20 -0
  182. data/spec/fixtures/src/rake-0.8.7/bin/rake +31 -0
  183. data/spec/fixtures/src/rake-0.8.7/doc/command_line_usage.rdoc +102 -0
  184. data/spec/fixtures/src/rake-0.8.7/doc/example/Rakefile1 +38 -0
  185. data/spec/fixtures/src/rake-0.8.7/doc/example/Rakefile2 +35 -0
  186. data/spec/fixtures/src/rake-0.8.7/doc/example/a.c +6 -0
  187. data/spec/fixtures/src/rake-0.8.7/doc/example/b.c +6 -0
  188. data/spec/fixtures/src/rake-0.8.7/doc/example/main.c +11 -0
  189. data/spec/fixtures/src/rake-0.8.7/doc/glossary.rdoc +51 -0
  190. data/spec/fixtures/src/rake-0.8.7/doc/jamis.rb +591 -0
  191. data/spec/fixtures/src/rake-0.8.7/doc/proto_rake.rdoc +127 -0
  192. data/spec/fixtures/src/rake-0.8.7/doc/rake.1.gz +0 -0
  193. data/spec/fixtures/src/rake-0.8.7/doc/rakefile.rdoc +534 -0
  194. data/spec/fixtures/src/rake-0.8.7/doc/rational.rdoc +151 -0
  195. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.4.14.rdoc +23 -0
  196. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.4.15.rdoc +35 -0
  197. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.5.0.rdoc +53 -0
  198. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.5.3.rdoc +78 -0
  199. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.5.4.rdoc +46 -0
  200. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.6.0.rdoc +141 -0
  201. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.0.rdoc +119 -0
  202. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.1.rdoc +59 -0
  203. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.2.rdoc +121 -0
  204. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.3.rdoc +47 -0
  205. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.0.rdoc +114 -0
  206. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.2.rdoc +165 -0
  207. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.3.rdoc +112 -0
  208. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.4.rdoc +147 -0
  209. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.5.rdoc +53 -0
  210. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.6.rdoc +55 -0
  211. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.7.rdoc +55 -0
  212. data/spec/fixtures/src/rake-0.8.7/install.rb +88 -0
  213. data/spec/fixtures/src/rake-0.8.7/lib/rake.rb +2506 -0
  214. data/spec/fixtures/src/rake-0.8.7/lib/rake/alt_system.rb +108 -0
  215. data/spec/fixtures/src/rake-0.8.7/lib/rake/classic_namespace.rb +8 -0
  216. data/spec/fixtures/src/rake-0.8.7/lib/rake/clean.rb +33 -0
  217. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/compositepublisher.rb +24 -0
  218. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/ftptools.rb +153 -0
  219. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/publisher.rb +75 -0
  220. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  221. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/sshpublisher.rb +47 -0
  222. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/sys.rb +209 -0
  223. data/spec/fixtures/src/rake-0.8.7/lib/rake/gempackagetask.rb +97 -0
  224. data/spec/fixtures/src/rake-0.8.7/lib/rake/loaders/makefile.rb +42 -0
  225. data/spec/fixtures/src/rake-0.8.7/lib/rake/packagetask.rb +184 -0
  226. data/spec/fixtures/src/rake-0.8.7/lib/rake/rake_test_loader.rb +5 -0
  227. data/spec/fixtures/src/rake-0.8.7/lib/rake/rdoctask.rb +209 -0
  228. data/spec/fixtures/src/rake-0.8.7/lib/rake/ruby182_test_unit_fix.rb +23 -0
  229. data/spec/fixtures/src/rake-0.8.7/lib/rake/runtest.rb +23 -0
  230. data/spec/fixtures/src/rake-0.8.7/lib/rake/tasklib.rb +23 -0
  231. data/spec/fixtures/src/rake-0.8.7/lib/rake/testtask.rb +161 -0
  232. data/spec/fixtures/src/rake-0.8.7/lib/rake/win32.rb +55 -0
  233. data/spec/fixtures/src/rake-0.8.7/package.json +18 -0
  234. data/spec/fixtures/src/rake-0.8.7/test/capture_stdout.rb +26 -0
  235. data/spec/fixtures/src/spade/lib/main.js +1 -0
  236. data/spec/fixtures/src/spade/package.json +15 -0
  237. data/spec/fixtures/transporter/lib/main.js +3 -0
  238. data/spec/fixtures/transporter/packages/transport/lib/wrapper.js +5 -0
  239. data/spec/fixtures/transporter/packages/transport/package.json +21 -0
  240. data/spec/fixtures/transporter/transporter.json +18 -0
  241. data/spec/gauntlet_spec.rb +33 -0
  242. data/spec/package_spec.rb +319 -0
  243. data/spec/pipeline_spec.rb +213 -0
  244. data/spec/project_spec.rb +130 -0
  245. data/spec/spec_helper.rb +42 -0
  246. data/spec/support/cli.rb +93 -0
  247. data/spec/support/env.rb +18 -0
  248. data/spec/support/fake.rb +53 -0
  249. data/spec/support/fake_gem_server.rb +72 -0
  250. data/spec/support/fake_gemcutter.rb +50 -0
  251. data/spec/support/matchers.rb +32 -0
  252. data/spec/support/path.rb +63 -0
  253. data/spec/support/project.rb +43 -0
  254. data/templates/init/assets/bpm_packages.js +7 -0
  255. data/templates/init/assets/bpm_styles.css +7 -0
  256. data/templates/init/project.json +16 -0
  257. data/templates/project/LICENSE +19 -0
  258. data/templates/project/README.md +21 -0
  259. data/templates/project/app.js +1 -0
  260. data/templates/project/index.html +13 -0
  261. metadata +627 -0
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load the test files from the command line.
4
+
5
+ ARGV.each { |f| load f unless f =~ /^-/ }
@@ -0,0 +1,209 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require 'rake/tasklib'
5
+
6
+ module Rake
7
+
8
+ # Create a documentation task that will generate the RDoc files for
9
+ # a project.
10
+ #
11
+ # The RDocTask will create the following targets:
12
+ #
13
+ # [<b><em>rdoc</em></b>]
14
+ # Main task for this RDOC task.
15
+ #
16
+ # [<b>:clobber_<em>rdoc</em></b>]
17
+ # Delete all the rdoc files. This target is automatically
18
+ # added to the main clobber target.
19
+ #
20
+ # [<b>:re<em>rdoc</em></b>]
21
+ # Rebuild the rdoc files from scratch, even if they are not out
22
+ # of date.
23
+ #
24
+ # Simple Example:
25
+ #
26
+ # Rake::RDocTask.new do |rd|
27
+ # rd.main = "README.rdoc"
28
+ # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
29
+ # end
30
+ #
31
+ # The +rd+ object passed to the block is an RDocTask object. See the
32
+ # attributes list for the RDocTask class for available customization options.
33
+ #
34
+ # == Specifying different task names
35
+ #
36
+ # You may wish to give the task a different name, such as if you are
37
+ # generating two sets of documentation. For instance, if you want to have a
38
+ # development set of documentation including private methods:
39
+ #
40
+ # Rake::RDocTask.new(:rdoc_dev) do |rd|
41
+ # rd.main = "README.doc"
42
+ # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
43
+ # rd.options << "--all"
44
+ # end
45
+ #
46
+ # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
47
+ # :re<em>rdoc_dev</em>.
48
+ #
49
+ # If you wish to have completely different task names, then pass a Hash as
50
+ # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
51
+ # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
52
+ # For example:
53
+ #
54
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
55
+ #
56
+ # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
57
+ # <tt>:rdoc:force</tt>.
58
+ #
59
+ class RDocTask < TaskLib
60
+ # Name of the main, top level task. (default is :rdoc)
61
+ attr_accessor :name
62
+
63
+ # Name of directory to receive the html output files. (default is "html")
64
+ attr_accessor :rdoc_dir
65
+
66
+ # Title of RDoc documentation. (defaults to rdoc's default)
67
+ attr_accessor :title
68
+
69
+ # Name of file to be used as the main, top level file of the
70
+ # RDoc. (default is none)
71
+ attr_accessor :main
72
+
73
+ # Name of template to be used by rdoc. (defaults to rdoc's default)
74
+ attr_accessor :template
75
+
76
+ # List of files to be included in the rdoc generation. (default is [])
77
+ attr_accessor :rdoc_files
78
+
79
+ # Additional list of options to be passed rdoc. (default is [])
80
+ attr_accessor :options
81
+
82
+ # Whether to run the rdoc process as an external shell (default is false)
83
+ attr_accessor :external
84
+
85
+ attr_accessor :inline_source
86
+
87
+ # Create an RDoc task with the given name. See the RDocTask class overview
88
+ # for documentation.
89
+ def initialize(name = :rdoc) # :yield: self
90
+ if name.is_a?(Hash)
91
+ invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
92
+ if !invalid_options.empty?
93
+ raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
94
+ end
95
+ end
96
+
97
+ @name = name
98
+ @rdoc_files = Rake::FileList.new
99
+ @rdoc_dir = 'html'
100
+ @main = nil
101
+ @title = nil
102
+ @template = nil
103
+ @external = false
104
+ @inline_source = true
105
+ @options = []
106
+ yield self if block_given?
107
+ define
108
+ end
109
+
110
+ # Create the tasks defined by this task lib.
111
+ def define
112
+ if rdoc_task_name != "rdoc"
113
+ desc "Build the RDOC HTML Files"
114
+ else
115
+ desc "Build the #{rdoc_task_name} HTML Files"
116
+ end
117
+ task rdoc_task_name
118
+
119
+ desc "Force a rebuild of the RDOC files"
120
+ task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
121
+
122
+ desc "Remove rdoc products"
123
+ task clobber_task_name do
124
+ rm_r rdoc_dir rescue nil
125
+ end
126
+
127
+ task :clobber => [clobber_task_name]
128
+
129
+ directory @rdoc_dir
130
+ task rdoc_task_name => [rdoc_target]
131
+ file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
132
+ rm_r @rdoc_dir rescue nil
133
+ @before_running_rdoc.call if @before_running_rdoc
134
+ args = option_list + @rdoc_files
135
+ if @external
136
+ argstring = args.join(' ')
137
+ sh %{ruby -Ivendor vendor/rd #{argstring}}
138
+ else
139
+ require 'rdoc/rdoc'
140
+ RDoc::RDoc.new.document(args)
141
+ end
142
+ end
143
+ self
144
+ end
145
+
146
+ def option_list
147
+ result = @options.dup
148
+ result << "-o" << @rdoc_dir
149
+ result << "--main" << quote(main) if main
150
+ result << "--title" << quote(title) if title
151
+ result << "-T" << quote(template) if template
152
+ result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
153
+ result
154
+ end
155
+
156
+ def quote(str)
157
+ if @external
158
+ "'#{str}'"
159
+ else
160
+ str
161
+ end
162
+ end
163
+
164
+ def option_string
165
+ option_list.join(' ')
166
+ end
167
+
168
+ # The block passed to this method will be called just before running the
169
+ # RDoc generator. It is allowed to modify RDocTask attributes inside the
170
+ # block.
171
+ def before_running_rdoc(&block)
172
+ @before_running_rdoc = block
173
+ end
174
+
175
+ private
176
+
177
+ def rdoc_target
178
+ "#{rdoc_dir}/index.html"
179
+ end
180
+
181
+ def rdoc_task_name
182
+ case name
183
+ when Hash
184
+ (name[:rdoc] || "rdoc").to_s
185
+ else
186
+ name.to_s
187
+ end
188
+ end
189
+
190
+ def clobber_task_name
191
+ case name
192
+ when Hash
193
+ (name[:clobber_rdoc] || "clobber_rdoc").to_s
194
+ else
195
+ "clobber_#{name}"
196
+ end
197
+ end
198
+
199
+ def rerdoc_task_name
200
+ case name
201
+ when Hash
202
+ (name[:rerdoc] || "rerdoc").to_s
203
+ else
204
+ "re#{name}"
205
+ end
206
+ end
207
+
208
+ end
209
+ end
@@ -0,0 +1,23 @@
1
+ module Test
2
+ module Unit
3
+ module Collector
4
+ class Dir
5
+ undef collect_file
6
+ def collect_file(name, suites, already_gathered)
7
+ # loadpath = $:.dup
8
+ dir = File.dirname(File.expand_path(name))
9
+ $:.unshift(dir) unless $:.first == dir
10
+ if(@req)
11
+ @req.require(name)
12
+ else
13
+ require(name)
14
+ end
15
+ find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
16
+ ensure
17
+ # $:.replace(loadpath)
18
+ $:.delete_at $:.rindex(dir)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'test/unit/assertions'
5
+
6
+ module Rake
7
+ include Test::Unit::Assertions
8
+
9
+ def run_tests(pattern='test/test*.rb', log_enabled=false)
10
+ Dir["#{pattern}"].each { |fn|
11
+ puts fn if log_enabled
12
+ begin
13
+ load fn
14
+ rescue Exception => ex
15
+ puts "Error in #{fn}: #{ex.message}"
16
+ puts ex.backtrace
17
+ assert false
18
+ end
19
+ }
20
+ end
21
+
22
+ extend self
23
+ end
@@ -0,0 +1,23 @@
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
+
11
+ # Make a symbol by pasting two strings together.
12
+ #
13
+ # NOTE: DEPRECATED! This method is kinda stupid. I don't know why
14
+ # I didn't just use string interpolation. But now other task
15
+ # libraries depend on this so I can't remove it without breaking
16
+ # other people's code. So for now it stays for backwards
17
+ # compatibility. BUT DON'T USE IT.
18
+ def paste(a,b) # :nodoc:
19
+ (a.to_s + b.to_s).intern
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,161 @@
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
+ lib_path = @libs.join(File::PATH_SEPARATOR)
99
+ desc "Run tests" + (@name==:test ? "" : " for #{@name}")
100
+ task @name do
101
+ run_code = ''
102
+ RakeFileUtils.verbose(@verbose) do
103
+ run_code =
104
+ case @loader
105
+ when :direct
106
+ "-e 'ARGV.each{|f| load f}'"
107
+ when :testrb
108
+ "-S testrb #{fix}"
109
+ when :rake
110
+ rake_loader
111
+ end
112
+ @ruby_opts.unshift( "-I\"#{lib_path}\"" )
113
+ @ruby_opts.unshift( "-w" ) if @warning
114
+ ruby @ruby_opts.join(" ") +
115
+ " \"#{run_code}\" " +
116
+ file_list.collect { |fn| "\"#{fn}\"" }.join(' ') +
117
+ " #{option_list}"
118
+ end
119
+ end
120
+ self
121
+ end
122
+
123
+ def option_list # :nodoc:
124
+ ENV['TESTOPTS'] || @options || ""
125
+ end
126
+
127
+ def file_list # :nodoc:
128
+ if ENV['TEST']
129
+ FileList[ ENV['TEST'] ]
130
+ else
131
+ result = []
132
+ result += @test_files.to_a if @test_files
133
+ result += FileList[ @pattern ].to_a if @pattern
134
+ FileList[result]
135
+ end
136
+ end
137
+
138
+ def fix # :nodoc:
139
+ case RUBY_VERSION
140
+ when '1.8.2'
141
+ find_file 'rake/ruby182_test_unit_fix'
142
+ else
143
+ nil
144
+ end || ''
145
+ end
146
+
147
+ def rake_loader # :nodoc:
148
+ find_file('rake/rake_test_loader') or
149
+ fail "unable to find rake test loader"
150
+ end
151
+
152
+ def find_file(fn) # :nodoc:
153
+ $LOAD_PATH.each do |path|
154
+ file_path = File.join(path, "#{fn}.rb")
155
+ return file_path if File.exist? file_path
156
+ end
157
+ nil
158
+ end
159
+
160
+ end
161
+ end