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,209 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #--
4
+ # Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #++
25
+ #
26
+ begin
27
+ require 'ftools'
28
+ rescue LoadError
29
+ end
30
+ require 'rbconfig'
31
+
32
+ ######################################################################
33
+ # Sys provides a number of file manipulation tools for the convenience
34
+ # of writing Rakefiles. All commands in this module will announce
35
+ # their activity on standard output if the $verbose flag is set
36
+ # ($verbose = true is the default). You can control this by globally
37
+ # setting $verbose or by using the +verbose+ and +quiet+ methods.
38
+ #
39
+ # Sys has been deprecated in favor of the FileUtils module available
40
+ # in Ruby 1.8.
41
+ #
42
+ module Sys
43
+ RUBY = Config::CONFIG['ruby_install_name']
44
+
45
+ # Install all the files matching +wildcard+ into the +dest_dir+
46
+ # directory. The permission mode is set to +mode+.
47
+ def install(wildcard, dest_dir, mode)
48
+ Dir[wildcard].each do |fn|
49
+ File.install(fn, dest_dir, mode, $verbose)
50
+ end
51
+ end
52
+
53
+ # Run the system command +cmd+.
54
+ def run(cmd)
55
+ log cmd
56
+ system(cmd) or fail "Command Failed: [#{cmd}]"
57
+ end
58
+
59
+ # Run a Ruby interpreter with the given arguments.
60
+ def ruby(*args)
61
+ run "#{RUBY} #{args.join(' ')}"
62
+ end
63
+
64
+ # Copy a single file from +file_name+ to +dest_file+.
65
+ def copy(file_name, dest_file)
66
+ log "Copying file #{file_name} to #{dest_file}"
67
+ File.copy(file_name, dest_file)
68
+ end
69
+
70
+ # Copy all files matching +wildcard+ into the directory +dest_dir+.
71
+ def copy_files(wildcard, dest_dir)
72
+ for_matching_files(wildcard, dest_dir) { |from, to| copy(from, to) }
73
+ end
74
+
75
+ # Link +file_name+ to +dest_file+.
76
+ def link(file_name, dest_file)
77
+ log "Linking file #{file_name} to #{dest_file}"
78
+ File.link(file_name, dest_file)
79
+ end
80
+
81
+ # Link all files matching +wildcard+ into the directory +dest_dir+.
82
+ def link_files(wildcard, dest_dir)
83
+ for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
84
+ end
85
+
86
+ # Symlink +file_name+ to +dest_file+.
87
+ def symlink(file_name, dest_file)
88
+ log "Symlinking file #{file_name} to #{dest_file}"
89
+ File.symlink(file_name, dest_file)
90
+ end
91
+
92
+ # Symlink all files matching +wildcard+ into the directory +dest_dir+.
93
+ def symlink_files(wildcard, dest_dir)
94
+ for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
95
+ end
96
+
97
+ # Remove all files matching +wildcard+. If a matching file is a
98
+ # directory, it must be empty to be removed. used +delete_all+ to
99
+ # recursively delete directories.
100
+ def delete(*wildcards)
101
+ wildcards.each do |wildcard|
102
+ Dir[wildcard].each do |fn|
103
+ if File.directory?(fn)
104
+ log "Deleting directory #{fn}"
105
+ Dir.delete(fn)
106
+ else
107
+ log "Deleting file #{fn}"
108
+ File.delete(fn)
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ # Recursively delete all files and directories matching +wildcard+.
115
+ def delete_all(*wildcards)
116
+ wildcards.each do |wildcard|
117
+ Dir[wildcard].each do |fn|
118
+ next if ! File.exist?(fn)
119
+ if File.directory?(fn)
120
+ Dir["#{fn}/*"].each do |subfn|
121
+ next if subfn=='.' || subfn=='..'
122
+ delete_all(subfn)
123
+ end
124
+ log "Deleting directory #{fn}"
125
+ Dir.delete(fn)
126
+ else
127
+ log "Deleting file #{fn}"
128
+ File.delete(fn)
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ # Make the directories given in +dirs+.
135
+ def makedirs(*dirs)
136
+ dirs.each do |fn|
137
+ log "Making directory #{fn}"
138
+ File.makedirs(fn)
139
+ end
140
+ end
141
+
142
+ # Make +dir+ the current working directory for the duration of
143
+ # executing the given block.
144
+ def indir(dir)
145
+ olddir = Dir.pwd
146
+ Dir.chdir(dir)
147
+ yield
148
+ ensure
149
+ Dir.chdir(olddir)
150
+ end
151
+
152
+ # Split a file path into individual directory names.
153
+ #
154
+ # For example:
155
+ # split_all("a/b/c") => ['a', 'b', 'c']
156
+ def split_all(path)
157
+ head, tail = File.split(path)
158
+ return [tail] if head == '.' || tail == '/'
159
+ return [head, tail] if head == '/'
160
+ return split_all(head) + [tail]
161
+ end
162
+
163
+ # Write a message to standard out if $verbose is enabled.
164
+ def log(msg)
165
+ print " " if $trace && $verbose
166
+ puts msg if $verbose
167
+ end
168
+
169
+ # Perform a block with $verbose disabled.
170
+ def quiet(&block)
171
+ with_verbose(false, &block)
172
+ end
173
+
174
+ # Perform a block with $verbose enabled.
175
+ def verbose(&block)
176
+ with_verbose(true, &block)
177
+ end
178
+
179
+ # Perform a block with each file matching a set of wildcards.
180
+ def for_files(*wildcards)
181
+ wildcards.each do |wildcard|
182
+ Dir[wildcard].each do |fn|
183
+ yield(fn)
184
+ end
185
+ end
186
+ end
187
+
188
+ extend(self)
189
+
190
+ private # ----------------------------------------------------------
191
+
192
+ def for_matching_files(wildcard, dest_dir)
193
+ Dir[wildcard].each do |fn|
194
+ dest_file = File.join(dest_dir, fn)
195
+ parent = File.dirname(dest_file)
196
+ makedirs(parent) if ! File.directory?(parent)
197
+ yield(fn, dest_file)
198
+ end
199
+ end
200
+
201
+ def with_verbose(v)
202
+ oldverbose = $verbose
203
+ $verbose = v
204
+ yield
205
+ ensure
206
+ $verbose = oldverbose
207
+ end
208
+
209
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Define a package task library to aid in the definition of GEM
4
+ # packages.
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/packagetask'
9
+ require 'rubygems/user_interaction'
10
+ require 'rubygems/builder'
11
+
12
+ module Rake
13
+
14
+ # Create a package based upon a Gem spec. Gem packages, as well as
15
+ # zip files and tar/gzipped packages can be produced by this task.
16
+ #
17
+ # In addition to the Rake targets generated by PackageTask, a
18
+ # GemPackageTask will also generate the following tasks:
19
+ #
20
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
21
+ # Create a Ruby GEM package with the given name and version.
22
+ #
23
+ # Example using a Ruby GEM spec:
24
+ #
25
+ # require 'rubygems'
26
+ #
27
+ # spec = Gem::Specification.new do |s|
28
+ # s.platform = Gem::Platform::RUBY
29
+ # s.summary = "Ruby based make-like utility."
30
+ # s.name = 'rake'
31
+ # s.version = PKG_VERSION
32
+ # s.requirements << 'none'
33
+ # s.require_path = 'lib'
34
+ # s.autorequire = 'rake'
35
+ # s.files = PKG_FILES
36
+ # s.description = <<EOF
37
+ # Rake is a Make-like program implemented in Ruby. Tasks
38
+ # and dependencies are specified in standard Ruby syntax.
39
+ # EOF
40
+ # end
41
+ #
42
+ # Rake::GemPackageTask.new(spec) do |pkg|
43
+ # pkg.need_zip = true
44
+ # pkg.need_tar = true
45
+ # end
46
+ #
47
+ class GemPackageTask < PackageTask
48
+ # Ruby GEM spec containing the metadata for this package. The
49
+ # name, version and package_files are automatically determined
50
+ # from the GEM spec and don't need to be explicitly provided.
51
+ attr_accessor :gem_spec
52
+
53
+ # Create a GEM Package task library. Automatically define the gem
54
+ # if a block is given. If no block is supplied, then +define+
55
+ # needs to be called to define the task.
56
+ def initialize(gem_spec)
57
+ init(gem_spec)
58
+ yield self if block_given?
59
+ define if block_given?
60
+ end
61
+
62
+ # Initialization tasks without the "yield self" or define
63
+ # operations.
64
+ def init(gem)
65
+ super(gem.name, gem.version)
66
+ @gem_spec = gem
67
+ @package_files += gem_spec.files if gem_spec.files
68
+ end
69
+
70
+ # Create the Rake tasks and actions specified by this
71
+ # GemPackageTask. (+define+ is automatically called if a block is
72
+ # given to +new+).
73
+ def define
74
+ super
75
+ task :package => [:gem]
76
+ desc "Build the gem file #{gem_file}"
77
+ task :gem => ["#{package_dir}/#{gem_file}"]
78
+ file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
79
+ when_writing("Creating GEM") {
80
+ Gem::Builder.new(gem_spec).build
81
+ verbose(true) {
82
+ mv gem_file, "#{package_dir}/#{gem_file}"
83
+ }
84
+ }
85
+ end
86
+ end
87
+
88
+ def gem_file
89
+ if @gem_spec.platform == Gem::Platform::RUBY
90
+ "#{package_name}.gem"
91
+ else
92
+ "#{package_name}-#{@gem_spec.platform}.gem"
93
+ end
94
+ end
95
+
96
+ end
97
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module Rake
4
+
5
+ # Makefile loader to be used with the import file loader.
6
+ class MakefileLoader
7
+ SPACE_MARK = "__&NBSP;__"
8
+
9
+ # Load the makefile dependencies in +fn+.
10
+ def load(fn)
11
+ open(fn) do |mf|
12
+ lines = mf.read
13
+ lines.gsub!(/\\ /, SPACE_MARK)
14
+ lines.gsub!(/#[^\n]*\n/m, "")
15
+ lines.gsub!(/\\\n/, ' ')
16
+ lines.split("\n").each do |line|
17
+ process_line(line)
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ # Process one logical line of makefile data.
25
+ def process_line(line)
26
+ file_tasks, args = line.split(':')
27
+ return if args.nil?
28
+ dependents = args.split.map { |d| respace(d) }
29
+ file_tasks.strip.split.each do |file_task|
30
+ file_task = respace(file_task)
31
+ file file_task => dependents
32
+ end
33
+ end
34
+
35
+ def respace(str)
36
+ str.gsub(/#{SPACE_MARK}/, ' ')
37
+ end
38
+ end
39
+
40
+ # Install the handler
41
+ Rake.application.add_loader('mf', MakefileLoader.new)
42
+ end
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Define a package task libarary to aid in the definition of
4
+ # redistributable package files.
5
+
6
+ require 'rake'
7
+ require 'rake/tasklib'
8
+
9
+ module Rake
10
+
11
+ # Create a packaging task that will package the project into
12
+ # distributable files (e.g zip archive or tar files).
13
+ #
14
+ # The PackageTask will create the following targets:
15
+ #
16
+ # [<b>:package</b>]
17
+ # Create all the requested package files.
18
+ #
19
+ # [<b>:clobber_package</b>]
20
+ # Delete all the package files. This target is automatically
21
+ # added to the main clobber target.
22
+ #
23
+ # [<b>:repackage</b>]
24
+ # Rebuild the package files from scratch, even if they are not out
25
+ # of date.
26
+ #
27
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</b>]
28
+ # Create a gzipped tar package (if <em>need_tar</em> is true).
29
+ #
30
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</b>]
31
+ # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
32
+ #
33
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</b>]
34
+ # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
35
+ #
36
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</b>]
37
+ # Create a zip package archive (if <em>need_zip</em> is true).
38
+ #
39
+ # Example:
40
+ #
41
+ # Rake::PackageTask.new("rake", "1.2.3") do |p|
42
+ # p.need_tar = true
43
+ # p.package_files.include("lib/**/*.rb")
44
+ # end
45
+ #
46
+ class PackageTask < TaskLib
47
+ # Name of the package (from the GEM Spec).
48
+ attr_accessor :name
49
+
50
+ # Version of the package (e.g. '1.3.2').
51
+ attr_accessor :version
52
+
53
+ # Directory used to store the package files (default is 'pkg').
54
+ attr_accessor :package_dir
55
+
56
+ # True if a gzipped tar file (tgz) should be produced (default is false).
57
+ attr_accessor :need_tar
58
+
59
+ # True if a gzipped tar file (tar.gz) should be produced (default is false).
60
+ attr_accessor :need_tar_gz
61
+
62
+ # True if a bzip2'd tar file (tar.bz2) should be produced (default is false).
63
+ attr_accessor :need_tar_bz2
64
+
65
+ # True if a zip file should be produced (default is false)
66
+ attr_accessor :need_zip
67
+
68
+ # List of files to be included in the package.
69
+ attr_accessor :package_files
70
+
71
+ # Tar command for gzipped or bzip2ed archives. The default is 'tar'.
72
+ attr_accessor :tar_command
73
+
74
+ # Zip command for zipped archives. The default is 'zip'.
75
+ attr_accessor :zip_command
76
+
77
+ # Create a Package Task with the given name and version.
78
+ def initialize(name=nil, version=nil)
79
+ init(name, version)
80
+ yield self if block_given?
81
+ define unless name.nil?
82
+ end
83
+
84
+ # Initialization that bypasses the "yield self" and "define" step.
85
+ def init(name, version)
86
+ @name = name
87
+ @version = version
88
+ @package_files = Rake::FileList.new
89
+ @package_dir = 'pkg'
90
+ @need_tar = false
91
+ @need_tar_gz = false
92
+ @need_tar_bz2 = false
93
+ @need_zip = false
94
+ @tar_command = 'tar'
95
+ @zip_command = 'zip'
96
+ end
97
+
98
+ # Create the tasks defined by this task library.
99
+ def define
100
+ fail "Version required (or :noversion)" if @version.nil?
101
+ @version = nil if :noversion == @version
102
+
103
+ desc "Build all the packages"
104
+ task :package
105
+
106
+ desc "Force a rebuild of the package files"
107
+ task :repackage => [:clobber_package, :package]
108
+
109
+ desc "Remove package products"
110
+ task :clobber_package do
111
+ rm_r package_dir rescue nil
112
+ end
113
+
114
+ task :clobber => [:clobber_package]
115
+
116
+ [
117
+ [need_tar, tgz_file, "z"],
118
+ [need_tar_gz, tar_gz_file, "z"],
119
+ [need_tar_bz2, tar_bz2_file, "j"]
120
+ ].each do |(need, file, flag)|
121
+ if need
122
+ task :package => ["#{package_dir}/#{file}"]
123
+ file "#{package_dir}/#{file}" => [package_dir_path] + package_files do
124
+ chdir(package_dir) do
125
+ sh %{#{@tar_command} #{flag}cvf #{file} #{package_name}}
126
+ end
127
+ end
128
+ end
129
+ end
130
+
131
+ if need_zip
132
+ task :package => ["#{package_dir}/#{zip_file}"]
133
+ file "#{package_dir}/#{zip_file}" => [package_dir_path] + package_files do
134
+ chdir(package_dir) do
135
+ sh %{#{@zip_command} -r #{zip_file} #{package_name}}
136
+ end
137
+ end
138
+ end
139
+
140
+ directory package_dir
141
+
142
+ file package_dir_path => @package_files do
143
+ mkdir_p package_dir rescue nil
144
+ @package_files.each do |fn|
145
+ f = File.join(package_dir_path, fn)
146
+ fdir = File.dirname(f)
147
+ mkdir_p(fdir) if !File.exist?(fdir)
148
+ if File.directory?(fn)
149
+ mkdir_p(f)
150
+ else
151
+ rm_f f
152
+ safe_ln(fn, f)
153
+ end
154
+ end
155
+ end
156
+ self
157
+ end
158
+
159
+ def package_name
160
+ @version ? "#{@name}-#{@version}" : @name
161
+ end
162
+
163
+ def package_dir_path
164
+ "#{package_dir}/#{package_name}"
165
+ end
166
+
167
+ def tgz_file
168
+ "#{package_name}.tgz"
169
+ end
170
+
171
+ def tar_gz_file
172
+ "#{package_name}.tar.gz"
173
+ end
174
+
175
+ def tar_bz2_file
176
+ "#{package_name}.tar.bz2"
177
+ end
178
+
179
+ def zip_file
180
+ "#{package_name}.zip"
181
+ end
182
+ end
183
+
184
+ end