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,34 @@
1
+ module BPM
2
+ class ProjectGenerator < BPM::Generator
3
+
4
+ source_root File.join(::BPM::TEMPLATES_DIR, 'project')
5
+
6
+ def run
7
+ return false if directory_exists?
8
+
9
+ empty_directory '.', :verbose => false
10
+
11
+ create_files
12
+
13
+ true
14
+ end
15
+
16
+ private
17
+
18
+ def create_files
19
+ template "LICENSE"
20
+ template "README.md"
21
+ template "index.html"
22
+ template "app.js"
23
+ end
24
+
25
+ def directory_exists?
26
+ return false unless File.exist? destination_root
27
+ say_status "Directory #{dir_name} already exists", nil, :red
28
+ true
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ BPM.register_generator(:default, :project, BPM::ProjectGenerator)
data/lib/bpm/remote.rb ADDED
@@ -0,0 +1,104 @@
1
+ module BPM
2
+ class Remote < Repository
3
+ include LibGems::UserInteraction
4
+
5
+ def login(email, password)
6
+ response = raw_request :get, "api/v1/api_key" do |req|
7
+ req.basic_auth email, password
8
+ end
9
+
10
+ case response
11
+ when Net::HTTPSuccess
12
+ creds.save(email, response.body)
13
+ true
14
+ else
15
+ false
16
+ end
17
+ end
18
+
19
+ def push(package)
20
+ begin
21
+ body = LibGems.read_binary package
22
+ LibGems::Format.from_file_by_path(package)
23
+ rescue Exception => ex
24
+ return "There was a problem opening your package.\n#{ex.class}: #{ex.to_s}"
25
+ end
26
+
27
+ request :post, "api/v1/gems" do |req|
28
+ req.body = body
29
+ req.add_field "Content-Length", body.size
30
+ req.add_field "Content-Type", "application/octet-stream"
31
+ req.add_field "Authorization", creds.api_key
32
+ end
33
+ end
34
+
35
+ def yank(package, version)
36
+ request :delete, "api/v1/gems/yank" do |req|
37
+ req.set_form_data 'gem_name' => package, 'version' => version
38
+ req.add_field "Authorization", creds.api_key
39
+ end
40
+ end
41
+
42
+ def unyank(package, version)
43
+ request :put, "api/v1/gems/unyank" do |req|
44
+ req.set_form_data 'gem_name' => package, 'version' => version
45
+ req.add_field "Authorization", creds.api_key
46
+ end
47
+ end
48
+
49
+ def add_owner(package, email)
50
+ request :post, "api/v1/gems/#{package}/owners" do |req|
51
+ req.set_form_data 'email' => email
52
+ req.add_field "Authorization", creds.api_key
53
+ end
54
+ end
55
+
56
+ def remove_owner(package, email)
57
+ request :delete, "api/v1/gems/#{package}/owners" do |req|
58
+ req.set_form_data 'email' => email
59
+ req.add_field "Authorization", creds.api_key
60
+ end
61
+ end
62
+
63
+ def list_owners(package)
64
+ request :get, "api/v1/gems/#{package}/owners.yaml" do |req|
65
+ req.add_field "Authorization", creds.api_key
66
+ end
67
+ end
68
+
69
+ def list_packages(packages, all, prerelease)
70
+ fetcher = LibGems::SpecFetcher.fetcher
71
+ fetcher.find_matching(dependency_for(packages), all, false, prerelease).map(&:first)
72
+ end
73
+
74
+ def find_package(package_name, package_version, prerelease)
75
+ fetcher = LibGems::SpecFetcher.fetcher
76
+ dep = LibGems::Dependency.new(package_name, package_version)
77
+ fetcher.find_matching(dep, true, false, prerelease).map(&:first)
78
+ end
79
+
80
+ def install(package, version, prerelease)
81
+ inst = LibGems::DependencyInstaller.new(:prerelease => prerelease)
82
+ inst.install package, LibGems::Requirement.new([version])
83
+ inst.installed_gems
84
+ end
85
+
86
+ private
87
+
88
+ def raw_request(method, path, &block)
89
+ require 'net/http'
90
+ host = ENV['SPADE_HOST'] || LibGems.host
91
+ uri = URI.parse "#{host}/#{path}"
92
+
93
+ request_method = Net::HTTP.const_get method.to_s.capitalize
94
+
95
+ LibGems::RemoteFetcher.fetcher.request(uri, request_method, &block)
96
+ end
97
+
98
+ def request(method, path, &block)
99
+ response = raw_request(method, path, &block)
100
+ response.body
101
+ end
102
+ end
103
+ end
104
+
@@ -0,0 +1,18 @@
1
+ module BPM
2
+ class Repository
3
+ attr_accessor :creds
4
+
5
+ def initialize
6
+ self.creds = Credentials.new
7
+ end
8
+
9
+ def logged_in?
10
+ !self.creds.api_key.nil?
11
+ end
12
+
13
+ def dependency_for(packages)
14
+ LibGems::Dependency.new(/(#{packages.join('|')})/, LibGems::Requirement.default)
15
+ end
16
+ end
17
+ end
18
+
data/lib/bpm/server.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'rack'
2
+ require 'sprockets'
3
+
4
+ module BPM
5
+
6
+ class Trial
7
+
8
+ def initialize(app)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ puts env.to_json
14
+ ret = @app.call(env)
15
+ puts "RET = \n #{ret * "\n "}"
16
+ ret
17
+ end
18
+ end
19
+
20
+ class Server < Rack::Server
21
+
22
+ def initialize(project, options=nil)
23
+ @project = project
24
+ super options
25
+ end
26
+
27
+ def self.start(project, options=nil)
28
+ new(project, options).start
29
+ end
30
+
31
+ attr_reader :project
32
+
33
+ def app
34
+ cur_project = @project
35
+
36
+ @app ||= Rack::Builder.new do
37
+ map '/assets' do
38
+ run BPM::Trial.new(BPM::Pipeline.new cur_project)
39
+ end
40
+ end.to_app
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module BPM
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,159 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe 'bpm add' do
5
+
6
+ before do
7
+ goto_home
8
+ set_host
9
+ start_fake(FakeGemServer.new)
10
+ FileUtils.cp_r(fixtures('hello_world'), '.')
11
+ cd home('hello_world')
12
+
13
+ bpm 'compile'
14
+ wait
15
+ end
16
+
17
+ it "must be called from within a project" do
18
+ cd home # outside of project
19
+ bpm "add", "jquery", :track_stderr => true
20
+ stderr.read.should include("inside of a bpm project")
21
+ end
22
+
23
+ it "should add a new hard dependency" do
24
+ bpm 'add', 'jquery'
25
+ wait
26
+
27
+ output = stdout.read
28
+ output.should include("Added package 'jquery' (1.4.3)")
29
+ has_dependency 'jquery', '1.4.3'
30
+ end
31
+
32
+ it "adds multiple package dependencies" do
33
+ bpm "add", "jquery", "rake"
34
+
35
+ output = stdout.read
36
+
37
+ %w(jquery:1.4.3 rake:0.8.7).each do |pkg|
38
+ pkg_name, pkg_version = pkg.split ':'
39
+ output.should include("Added package '#{pkg_name}' (#{pkg_version})")
40
+ has_dependency pkg_name, pkg_version
41
+ end
42
+ end
43
+
44
+ it "installs hard and soft dependencies" do
45
+ bpm 'add', 'coffee', '--pre'
46
+ wait
47
+
48
+ output = stdout.read
49
+
50
+ output.should include("Added package 'coffee' (1.0.1.pre)")
51
+ output.should include("Added package 'jquery' (1.4.3)")
52
+
53
+ has_dependency 'coffee', '1.0.1.pre', '>= 0-pre'
54
+ has_soft_dependency 'jquery', '1.4.3'
55
+ end
56
+
57
+ it "adds no packages when any are invalid" do
58
+ bpm "add", "jquery", "fake", :track_stderr => true
59
+
60
+ stderr.read.should include("Could not find package 'fake'")
61
+
62
+ no_dependency 'jquery'
63
+ no_dependency 'fake'
64
+ end
65
+
66
+ it "fails when adding invalid package" do
67
+ bpm "add", "fake", :track_stderr => true
68
+
69
+ stderr.read.should include("Could not find package 'fake'")
70
+ no_dependency 'fake'
71
+ end
72
+
73
+ it "fails if bpm can't write to the json or packages directory" do
74
+ FileUtils.mkdir_p home('hello_world', 'packages')
75
+ FileUtils.chmod 0555, home('hello_world', 'packages')
76
+ FileUtils.chmod 0555, home('hello_world', 'hello_world.json')
77
+
78
+ bpm "add", "jquery", :track_stderr => true
79
+ exit_status.should_not be_success
80
+ no_dependency 'jquery'
81
+
82
+ FileUtils.chmod 0755, home('hello_world', 'packages')
83
+ FileUtils.chmod 0755, home('hello_world', 'hello_world.json')
84
+ end
85
+
86
+ it "adds packages with different versions" do
87
+ bpm "add", "rake", "-v", "0.8.6"
88
+
89
+ stdout.read.should include("Added package 'rake' (0.8.6)")
90
+ has_dependency 'rake', '0.8.6', '0.8.6'
91
+ end
92
+
93
+ it "updates a package to latest version" do
94
+ bpm 'add', 'rake', '-v', '0.8.6'
95
+ wait
96
+ has_dependency 'rake', '0.8.6', '0.8.6' # precond
97
+
98
+ output = stdout.read
99
+ bpm 'add', 'rake'
100
+ wait
101
+
102
+ output = stdout.read
103
+ output.should_not include('Fetched spade') # not required 2nd time
104
+ output.should_not include("Added package 'spade' (0.5.0)")
105
+ output.should include("Added package 'rake' (0.8.7)")
106
+ has_dependency 'rake', '0.8.7'
107
+ end
108
+
109
+ it "adds a valid prerelease package" do
110
+ bpm "add", "bundler", "--pre", "--verbose"
111
+ wait
112
+ output = stdout.read
113
+ output.should include("Added package 'bundler' (1.1.pre)")
114
+ has_dependency 'bundler', '1.1.pre', '>= 0-pre'
115
+ end
116
+
117
+ it "does not add the normal package when asking for a prerelease" do
118
+ bpm "add", "rake", "--pre", :track_stderr => true
119
+ wait
120
+ stderr.read.should include("Could not find prerelease package 'rake'")
121
+ no_dependency 'rake'
122
+ end
123
+
124
+ it "requires at least one package to add" do
125
+ bpm "add", :track_stderr => true
126
+ stderr.read.should include("at least one package")
127
+ end
128
+
129
+ it "should make a soft dependency a hard dependency" do
130
+ bpm 'compile'
131
+ wait
132
+ has_soft_dependency 'ivory', '0.0.1' # precond
133
+
134
+ bpm 'add', 'ivory'
135
+ wait
136
+ has_dependency 'ivory', '0.0.1'
137
+ end
138
+
139
+ it "should use local package if available" do
140
+ no_dependency 'custom_package'
141
+
142
+ bpm "add", "custom_package"
143
+ output = stdout.read
144
+
145
+ output.should include("Using local package 'custom_package'")
146
+ has_dependency 'custom_package', '2.0.0'
147
+ has_soft_dependency 'rake', '0.8.6'
148
+ end
149
+
150
+ it "should fail if local package version is not compatible" do
151
+ bpm "add", "custom_package", "-v", "3.0.0", :track_stderr => true
152
+ output = stderr.read
153
+ output.should include("'custom_package' (2.0.0) is not compatible")
154
+ no_dependency 'custom_package'
155
+ end
156
+
157
+ it "should verify working with config-less projects"
158
+
159
+ end
@@ -0,0 +1,87 @@
1
+ require "spec_helper"
2
+ require "libgems/format"
3
+
4
+ describe "bpm build when logged in" do
5
+ let(:email) { "who@example.com" }
6
+
7
+ before do
8
+ goto_home
9
+ write_creds(email, "deadbeef")
10
+ end
11
+
12
+ it "builds a bpm from a given package.json" do
13
+ FileUtils.cp_r fixtures("core-test"), "."
14
+ cd "core-test"
15
+ bpm "build"
16
+
17
+ exit_status.should be_success
18
+ output = stdout.read
19
+ output.should include("Successfully built package: core-test-0.4.9.spd")
20
+
21
+ package = LibGems::Format.from_file_by_path("core-test-0.4.9.spd")
22
+ package.spec.name.should == "core-test"
23
+ package.spec.version.should == LibGems::Version.new("0.4.9")
24
+ package.spec.email.should == email
25
+ end
26
+ end
27
+
28
+ describe "bpm build without logging in" do
29
+ before do
30
+ goto_home
31
+ end
32
+
33
+ it "builds a bpm from a given package.json" do
34
+ FileUtils.cp_r fixtures("core-test"), "."
35
+ cd "core-test"
36
+ bpm "build", "-e", "joe@example.com"
37
+
38
+ exit_status.should be_success
39
+
40
+ package = LibGems::Format.from_file_by_path("core-test-0.4.9.spd")
41
+ package.spec.name.should == "core-test"
42
+ package.spec.version.should == LibGems::Version.new("0.4.9")
43
+ end
44
+
45
+ it "builds a bpm when given a path to a package" do
46
+ FileUtils.cp_r fixtures("core-test"), "."
47
+ bpm "build", "core-test", "-e", "joe@example.com"
48
+
49
+ exit_status.should be_success
50
+
51
+ cd 'core-test'
52
+ package = LibGems::Format.from_file_by_path("core-test-0.4.9.spd")
53
+ package.spec.name.should == "core-test"
54
+ package.spec.version.should == LibGems::Version.new("0.4.9")
55
+ end
56
+
57
+ it "sets the email address if one is given" do
58
+ FileUtils.cp_r fixtures("core-test"), "."
59
+ cd "core-test"
60
+ bpm "build", "-e", "lucy@allen.com"
61
+
62
+ exit_status.should be_success
63
+ output = stdout.read
64
+
65
+ package = LibGems::Format.from_file_by_path("core-test-0.4.9.spd")
66
+ package.spec.name.should == "core-test"
67
+ package.spec.version.should == LibGems::Version.new("0.4.9")
68
+ package.spec.email.should == "lucy@allen.com"
69
+ end
70
+ end
71
+
72
+ describe "bpm build with an invalid package.json" do
73
+ before do
74
+ goto_home
75
+ write_api_key("deadbeef")
76
+ end
77
+
78
+ it "reports error messages" do
79
+ FileUtils.touch "package.json"
80
+ bpm "build", :track_stderr => true
81
+
82
+ exit_status.should_not be_success
83
+ output = stderr.read
84
+ output.should include("BPM encountered the following problems building your package:")
85
+ output.should include("There was a problem parsing package.json")
86
+ end
87
+ end