spade-packager 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (316) hide show
  1. data/.gitignore +2 -0
  2. data/.gitmodules +6 -0
  3. data/bin/spadepkg +8 -0
  4. data/lib/libgems_ext.rb +8 -0
  5. data/lib/libgems_ext/config_file.rb +33 -0
  6. data/lib/libgems_ext/dependency_installer.rb +150 -0
  7. data/lib/libgems_ext/installer.rb +39 -0
  8. data/lib/libgems_ext/libgems.rb +39 -0
  9. data/lib/libgems_ext/spec_fetcher.rb +11 -0
  10. data/lib/spade-packager.rb +1 -0
  11. data/lib/spade/packager.rb +18 -0
  12. data/lib/spade/packager/cli.rb +9 -0
  13. data/lib/spade/packager/cli/base.rb +196 -0
  14. data/lib/spade/packager/cli/owner.rb +46 -0
  15. data/lib/spade/packager/cli/project_generator.rb +117 -0
  16. data/lib/spade/packager/credentials.rb +38 -0
  17. data/lib/spade/packager/local.rb +50 -0
  18. data/lib/spade/packager/package.rb +160 -0
  19. data/lib/spade/packager/remote.rb +98 -0
  20. data/lib/spade/packager/repository.rb +18 -0
  21. data/lib/spade/packager/version.rb +5 -0
  22. data/packages/coffee-script/.gitignore +8 -0
  23. data/packages/coffee-script/.npmignore +11 -0
  24. data/packages/coffee-script/Cakefile +229 -0
  25. data/packages/coffee-script/LICENSE +22 -0
  26. data/packages/coffee-script/README +47 -0
  27. data/packages/coffee-script/Rakefile +78 -0
  28. data/packages/coffee-script/bin/cake +7 -0
  29. data/packages/coffee-script/bin/coffee +7 -0
  30. data/packages/coffee-script/documentation/coffee/aliases.coffee +11 -0
  31. data/packages/coffee-script/documentation/coffee/array_comprehensions.coffee +2 -0
  32. data/packages/coffee-script/documentation/coffee/block_comment.coffee +6 -0
  33. data/packages/coffee-script/documentation/coffee/cake_tasks.coffee +9 -0
  34. data/packages/coffee-script/documentation/coffee/classes.coffee +25 -0
  35. data/packages/coffee-script/documentation/coffee/comparisons.coffee +5 -0
  36. data/packages/coffee-script/documentation/coffee/conditionals.coffee +13 -0
  37. data/packages/coffee-script/documentation/coffee/default_args.coffee +8 -0
  38. data/packages/coffee-script/documentation/coffee/do.coffee +4 -0
  39. data/packages/coffee-script/documentation/coffee/embedded.coffee +5 -0
  40. data/packages/coffee-script/documentation/coffee/existence.coffee +10 -0
  41. data/packages/coffee-script/documentation/coffee/expressions.coffee +9 -0
  42. data/packages/coffee-script/documentation/coffee/expressions_assignment.coffee +3 -0
  43. data/packages/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
  44. data/packages/coffee-script/documentation/coffee/expressions_try.coffee +7 -0
  45. data/packages/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
  46. data/packages/coffee-script/documentation/coffee/functions.coffee +2 -0
  47. data/packages/coffee-script/documentation/coffee/heredocs.coffee +7 -0
  48. data/packages/coffee-script/documentation/coffee/heregexes.coffee +11 -0
  49. data/packages/coffee-script/documentation/coffee/interpolation.coffee +6 -0
  50. data/packages/coffee-script/documentation/coffee/multiple_return_values.coffee +7 -0
  51. data/packages/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
  52. data/packages/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
  53. data/packages/coffee-script/documentation/coffee/objects_and_arrays.coffee +19 -0
  54. data/packages/coffee-script/documentation/coffee/objects_reserved.coffee +5 -0
  55. data/packages/coffee-script/documentation/coffee/overview.coffee +28 -0
  56. data/packages/coffee-script/documentation/coffee/parallel_assignment.coffee +6 -0
  57. data/packages/coffee-script/documentation/coffee/patterns_and_splats.coffee +7 -0
  58. data/packages/coffee-script/documentation/coffee/prototypes.coffee +3 -0
  59. data/packages/coffee-script/documentation/coffee/range_comprehensions.coffee +2 -0
  60. data/packages/coffee-script/documentation/coffee/scope.coffee +5 -0
  61. data/packages/coffee-script/documentation/coffee/slices.coffee +7 -0
  62. data/packages/coffee-script/documentation/coffee/soaks.coffee +1 -0
  63. data/packages/coffee-script/documentation/coffee/splats.coffee +27 -0
  64. data/packages/coffee-script/documentation/coffee/splices.coffee +5 -0
  65. data/packages/coffee-script/documentation/coffee/strings.coffee +8 -0
  66. data/packages/coffee-script/documentation/coffee/switch.coffee +10 -0
  67. data/packages/coffee-script/documentation/coffee/try.coffee +8 -0
  68. data/packages/coffee-script/documentation/coffee/while.coffee +10 -0
  69. data/packages/coffee-script/documentation/css/docs.css +374 -0
  70. data/packages/coffee-script/documentation/css/idle.css +64 -0
  71. data/packages/coffee-script/documentation/docs/browser.html +25 -0
  72. data/packages/coffee-script/documentation/docs/cake.html +43 -0
  73. data/packages/coffee-script/documentation/docs/coffee-script.html +51 -0
  74. data/packages/coffee-script/documentation/docs/command.html +161 -0
  75. data/packages/coffee-script/documentation/docs/docco.css +186 -0
  76. data/packages/coffee-script/documentation/docs/grammar.html +399 -0
  77. data/packages/coffee-script/documentation/docs/helpers.html +31 -0
  78. data/packages/coffee-script/documentation/docs/index.html +3 -0
  79. data/packages/coffee-script/documentation/docs/lexer.html +490 -0
  80. data/packages/coffee-script/documentation/docs/nodes.html +1338 -0
  81. data/packages/coffee-script/documentation/docs/optparse.html +78 -0
  82. data/packages/coffee-script/documentation/docs/repl.html +24 -0
  83. data/packages/coffee-script/documentation/docs/rewriter.html +251 -0
  84. data/packages/coffee-script/documentation/docs/scope.html +54 -0
  85. data/packages/coffee-script/documentation/docs/underscore.html +295 -0
  86. data/packages/coffee-script/documentation/images/background.png +0 -0
  87. data/packages/coffee-script/documentation/images/banding.png +0 -0
  88. data/packages/coffee-script/documentation/images/button_bg.png +0 -0
  89. data/packages/coffee-script/documentation/images/button_bg_dark.gif +0 -0
  90. data/packages/coffee-script/documentation/images/button_bg_green.gif +0 -0
  91. data/packages/coffee-script/documentation/images/favicon.ico +0 -0
  92. data/packages/coffee-script/documentation/images/logo.png +0 -0
  93. data/packages/coffee-script/documentation/images/screenshadow.png +0 -0
  94. data/packages/coffee-script/documentation/index.html.erb +1607 -0
  95. data/packages/coffee-script/documentation/js/aliases.js +17 -0
  96. data/packages/coffee-script/documentation/js/array_comprehensions.js +6 -0
  97. data/packages/coffee-script/documentation/js/block_comment.js +4 -0
  98. data/packages/coffee-script/documentation/js/cake_tasks.js +10 -0
  99. data/packages/coffee-script/documentation/js/classes.js +44 -0
  100. data/packages/coffee-script/documentation/js/comparisons.js +3 -0
  101. data/packages/coffee-script/documentation/js/conditionals.js +12 -0
  102. data/packages/coffee-script/documentation/js/default_args.js +7 -0
  103. data/packages/coffee-script/documentation/js/do.js +10 -0
  104. data/packages/coffee-script/documentation/js/embedded.js +4 -0
  105. data/packages/coffee-script/documentation/js/existence.js +6 -0
  106. data/packages/coffee-script/documentation/js/expressions.js +15 -0
  107. data/packages/coffee-script/documentation/js/expressions_assignment.js +2 -0
  108. data/packages/coffee-script/documentation/js/expressions_comprehension.js +9 -0
  109. data/packages/coffee-script/documentation/js/expressions_try.js +7 -0
  110. data/packages/coffee-script/documentation/js/fat_arrow.js +9 -0
  111. data/packages/coffee-script/documentation/js/functions.js +7 -0
  112. data/packages/coffee-script/documentation/js/heredocs.js +2 -0
  113. data/packages/coffee-script/documentation/js/heregexes.js +2 -0
  114. data/packages/coffee-script/documentation/js/interpolation.js +4 -0
  115. data/packages/coffee-script/documentation/js/multiple_return_values.js +5 -0
  116. data/packages/coffee-script/documentation/js/object_comprehensions.js +15 -0
  117. data/packages/coffee-script/documentation/js/object_extraction.js +10 -0
  118. data/packages/coffee-script/documentation/js/objects_and_arrays.js +17 -0
  119. data/packages/coffee-script/documentation/js/objects_reserved.js +4 -0
  120. data/packages/coffee-script/documentation/js/overview.js +35 -0
  121. data/packages/coffee-script/documentation/js/parallel_assignment.js +4 -0
  122. data/packages/coffee-script/documentation/js/patterns_and_splats.js +4 -0
  123. data/packages/coffee-script/documentation/js/prototypes.js +3 -0
  124. data/packages/coffee-script/documentation/js/range_comprehensions.js +9 -0
  125. data/packages/coffee-script/documentation/js/scope.js +8 -0
  126. data/packages/coffee-script/documentation/js/slices.js +4 -0
  127. data/packages/coffee-script/documentation/js/soaks.js +2 -0
  128. data/packages/coffee-script/documentation/js/splats.js +15 -0
  129. data/packages/coffee-script/documentation/js/splices.js +3 -0
  130. data/packages/coffee-script/documentation/js/strings.js +2 -0
  131. data/packages/coffee-script/documentation/js/switch.js +23 -0
  132. data/packages/coffee-script/documentation/js/try.js +8 -0
  133. data/packages/coffee-script/documentation/js/while.js +18 -0
  134. data/packages/coffee-script/documentation/vendor/jquery-1.4.2.js +6240 -0
  135. data/packages/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
  136. data/packages/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
  137. data/packages/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
  138. data/packages/coffee-script/examples/blocks.coffee +54 -0
  139. data/packages/coffee-script/examples/code.coffee +167 -0
  140. data/packages/coffee-script/examples/computer_science/README +4 -0
  141. data/packages/coffee-script/examples/computer_science/binary_search.coffee +25 -0
  142. data/packages/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
  143. data/packages/coffee-script/examples/computer_science/linked_list.coffee +108 -0
  144. data/packages/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
  145. data/packages/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
  146. data/packages/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
  147. data/packages/coffee-script/examples/poignant.coffee +181 -0
  148. data/packages/coffee-script/examples/potion.coffee +206 -0
  149. data/packages/coffee-script/examples/underscore.coffee +682 -0
  150. data/packages/coffee-script/examples/web_server.coffee +12 -0
  151. data/packages/coffee-script/extras/EXTRAS +7 -0
  152. data/packages/coffee-script/extras/coffee-script.js +8 -0
  153. data/packages/coffee-script/extras/jsl.conf +44 -0
  154. data/packages/coffee-script/index.html +2515 -0
  155. data/packages/coffee-script/lib/browser.js +52 -0
  156. data/packages/coffee-script/lib/cake.js +76 -0
  157. data/packages/coffee-script/lib/coffee-script.js +82 -0
  158. data/packages/coffee-script/lib/command.js +263 -0
  159. data/packages/coffee-script/lib/grammar.js +581 -0
  160. data/packages/coffee-script/lib/helpers.js +66 -0
  161. data/packages/coffee-script/lib/index.js +8 -0
  162. data/packages/coffee-script/lib/lexer.js +633 -0
  163. data/packages/coffee-script/lib/nodes.js +2165 -0
  164. data/packages/coffee-script/lib/optparse.js +111 -0
  165. data/packages/coffee-script/lib/parser.js +649 -0
  166. data/packages/coffee-script/lib/repl.js +42 -0
  167. data/packages/coffee-script/lib/rewriter.js +353 -0
  168. data/packages/coffee-script/lib/scope.js +120 -0
  169. data/packages/coffee-script/lib/spade-format.js +45 -0
  170. data/packages/coffee-script/package.json +26 -0
  171. data/packages/coffee-script/src/browser.coffee +43 -0
  172. data/packages/coffee-script/src/cake.coffee +69 -0
  173. data/packages/coffee-script/src/coffee-script.coffee +92 -0
  174. data/packages/coffee-script/src/command.coffee +214 -0
  175. data/packages/coffee-script/src/grammar.coffee +590 -0
  176. data/packages/coffee-script/src/helpers.coffee +56 -0
  177. data/packages/coffee-script/src/index.coffee +2 -0
  178. data/packages/coffee-script/src/lexer.coffee +653 -0
  179. data/packages/coffee-script/src/nodes.coffee +1754 -0
  180. data/packages/coffee-script/src/optparse.coffee +99 -0
  181. data/packages/coffee-script/src/repl.coffee +42 -0
  182. data/packages/coffee-script/src/rewriter.coffee +326 -0
  183. data/packages/coffee-script/src/scope.coffee +94 -0
  184. data/packages/coffee-script/test/arguments.coffee +127 -0
  185. data/packages/coffee-script/test/assignment.coffee +98 -0
  186. data/packages/coffee-script/test/break.coffee +18 -0
  187. data/packages/coffee-script/test/comments.coffee +201 -0
  188. data/packages/coffee-script/test/conditionals.coffee +181 -0
  189. data/packages/coffee-script/test/exception_handling.coffee +90 -0
  190. data/packages/coffee-script/test/helpers.coffee +96 -0
  191. data/packages/coffee-script/test/importing.coffee +18 -0
  192. data/packages/coffee-script/test/operators.coffee +225 -0
  193. data/packages/coffee-script/test/ranges_slices_and_splices.coffee +186 -0
  194. data/packages/coffee-script/test/regular_expressions.coffee +56 -0
  195. data/packages/coffee-script/test/test.html +123 -0
  196. data/packages/coffee-script/test/test_chaining.coffee +77 -0
  197. data/packages/coffee-script/test/test_classes.coffee +372 -0
  198. data/packages/coffee-script/test/test_compilation.coffee +26 -0
  199. data/packages/coffee-script/test/test_comprehensions.coffee +318 -0
  200. data/packages/coffee-script/test/test_existence.coffee +165 -0
  201. data/packages/coffee-script/test/test_functions.coffee +379 -0
  202. data/packages/coffee-script/test/test_heredocs.coffee +111 -0
  203. data/packages/coffee-script/test/test_literals.coffee +270 -0
  204. data/packages/coffee-script/test/test_option_parser.coffee +27 -0
  205. data/packages/coffee-script/test/test_pattern_matching.coffee +162 -0
  206. data/packages/coffee-script/test/test_returns.coffee +63 -0
  207. data/packages/coffee-script/test/test_splats.coffee +102 -0
  208. data/packages/coffee-script/test/test_strings.coffee +118 -0
  209. data/packages/coffee-script/test/test_switch.coffee +103 -0
  210. data/packages/coffee-script/test/test_while.coffee +71 -0
  211. data/packages/ivory/LICENSE.txt +1 -0
  212. data/packages/ivory/README.md +19 -0
  213. data/packages/ivory/lib/buffer.js +111 -0
  214. data/packages/ivory/lib/events.js +137 -0
  215. data/packages/ivory/lib/fs.js +266 -0
  216. data/packages/ivory/lib/main.js +13 -0
  217. data/packages/ivory/lib/path.js +158 -0
  218. data/packages/ivory/lib/ruby/buffer.rb +145 -0
  219. data/packages/ivory/lib/ruby/constants.rb +585 -0
  220. data/packages/ivory/lib/ruby/events.rb +32 -0
  221. data/packages/ivory/lib/ruby/fs.rb +245 -0
  222. data/packages/ivory/lib/ruby/process.rb +28 -0
  223. data/packages/ivory/lib/stream.js +115 -0
  224. data/packages/ivory/lib/util.js +414 -0
  225. data/packages/ivory/package.json +11 -0
  226. data/packages/ivory/spade-boot.js +78 -0
  227. data/packages/jquery/main.js +7179 -0
  228. data/packages/jquery/package.json +10 -0
  229. data/packages/json/lib/main.js +14 -0
  230. data/packages/json/package.json +8 -0
  231. data/packages/lproj/README.md +77 -0
  232. data/packages/lproj/examples/demo-app/en.lproj/localized.strings +2 -0
  233. data/packages/lproj/examples/demo-app/fr.lproj/localized.strings +3 -0
  234. data/packages/lproj/examples/demo-app/index.html +8 -0
  235. data/packages/lproj/examples/demo-app/lib/main.js +7 -0
  236. data/packages/lproj/examples/demo-app/package.json +9 -0
  237. data/packages/lproj/lib/main.js +78 -0
  238. data/packages/lproj/lib/strings-format.js +6 -0
  239. data/packages/lproj/package.json +9 -0
  240. data/packages/optparse/README.md +161 -0
  241. data/packages/optparse/TODO +1 -0
  242. data/packages/optparse/examples/browser-test.html +75 -0
  243. data/packages/optparse/examples/nodejs-test.js +90 -0
  244. data/packages/optparse/lib/optparse.js +309 -0
  245. data/packages/optparse/package.json +13 -0
  246. data/packages/optparse/seed.yml +5 -0
  247. data/packages/text/lib/main.js +8 -0
  248. data/packages/text/package.json +9 -0
  249. data/packages/web-file/README.md +7 -0
  250. data/packages/web-file/lib/errors.js +32 -0
  251. data/packages/web-file/lib/file-reader.js +10 -0
  252. data/packages/web-file/lib/file-system.js +234 -0
  253. data/packages/web-file/lib/file-writer.js +10 -0
  254. data/packages/web-file/lib/file.js +9 -0
  255. data/packages/web-file/lib/main.js +34 -0
  256. data/packages/web-file/lib/platform.js +25 -0
  257. data/packages/web-file/lib/ruby/file.rb +252 -0
  258. data/packages/web-file/lib/ruby/file_reader.rb +69 -0
  259. data/packages/web-file/lib/ruby/file_system.rb +134 -0
  260. data/packages/web-file/lib/ruby/file_writer.rb +78 -0
  261. data/packages/web-file/package.json +12 -0
  262. data/packages/web-typed-array/README.md +7 -0
  263. data/packages/web-typed-array/lib/array-buffer-view.js +9 -0
  264. data/packages/web-typed-array/lib/array-buffer.js +7 -0
  265. data/packages/web-typed-array/lib/main.js +33 -0
  266. data/packages/web-typed-array/lib/platform.js +20 -0
  267. data/packages/web-typed-array/lib/ruby/array_buffer.rb +31 -0
  268. data/packages/web-typed-array/lib/ruby/array_buffer_view.rb +130 -0
  269. data/packages/web-typed-array/lib/ruby/typed_array.rb +133 -0
  270. data/packages/web-typed-array/lib/typed-array.js +26 -0
  271. data/packages/web-typed-array/package.json +9 -0
  272. data/spade-packager.gemspec +39 -0
  273. data/spec/cli/build_spec.rb +57 -0
  274. data/spec/cli/install_spec.rb +119 -0
  275. data/spec/cli/installed_spec.rb +55 -0
  276. data/spec/cli/list_spec.rb +74 -0
  277. data/spec/cli/login_spec.rb +75 -0
  278. data/spec/cli/new_spec.rb +5 -0
  279. data/spec/cli/owner_spec.rb +114 -0
  280. data/spec/cli/push_spec.rb +73 -0
  281. data/spec/cli/uninstall_spec.rb +58 -0
  282. data/spec/cli/unpack_spec.rb +72 -0
  283. data/spec/cli/unyank_spec.rb +73 -0
  284. data/spec/cli/yank_spec.rb +73 -0
  285. data/spec/credentials_spec.rb +23 -0
  286. data/spec/fixtures/badrake-0.8.7.spd +0 -0
  287. data/spec/fixtures/builder-3.0.0.spd +0 -0
  288. data/spec/fixtures/bundler-1.1.pre.spd +0 -0
  289. data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
  290. data/spec/fixtures/core-test-0.4.3.spd +0 -0
  291. data/spec/fixtures/core-test/bin/cot +3 -0
  292. data/spec/fixtures/core-test/lib/main.js +1 -0
  293. data/spec/fixtures/core-test/resources/runner.css +0 -0
  294. data/spec/fixtures/core-test/tests/test.js +1 -0
  295. data/spec/fixtures/highline-1.6.1.spd +0 -0
  296. data/spec/fixtures/ivory-0.0.1.spd +0 -0
  297. data/spec/fixtures/jquery-1.4.3.spd +0 -0
  298. data/spec/fixtures/optparse-1.0.1.spd +0 -0
  299. data/spec/fixtures/package.json +30 -0
  300. data/spec/fixtures/rake-0.8.6.spd +0 -0
  301. data/spec/fixtures/rake-0.8.7.spd +0 -0
  302. data/spec/gauntlet_spec.rb +27 -0
  303. data/spec/package_spec.rb +267 -0
  304. data/spec/spec_helper.rb +32 -0
  305. data/spec/support/cli.rb +103 -0
  306. data/spec/support/fake.rb +48 -0
  307. data/spec/support/fake_gem_server.rb +67 -0
  308. data/spec/support/fake_gemcutter.rb +50 -0
  309. data/spec/support/matchers.rb +32 -0
  310. data/spec/support/path.rb +61 -0
  311. data/templates/project/LICENSE +19 -0
  312. data/templates/project/README.md +21 -0
  313. data/templates/project/lib/main.js +9 -0
  314. data/templates/project/project.json +31 -0
  315. data/templates/project/tests/main-test.js +8 -0
  316. metadata +484 -0
@@ -0,0 +1,32 @@
1
+ # ==========================================================================
2
+ # Project: Ivory
3
+ # Copyright: ©2010 Strobe Inc. All rights reserved.
4
+ # License: Licened under MIT license (see LICENSE)
5
+ # ==========================================================================
6
+
7
+ module Ivory
8
+ class EventEmitterExports < Spade::Runtime::Exports
9
+
10
+ class EventEmitter
11
+ attr_accessor :_events
12
+
13
+ def emit(e, *args)
14
+ return unless @_events
15
+ case notify = @_events[e]
16
+ when V8::Function
17
+ notify.methodcall(self, *args)
18
+ when V8::Array
19
+ notify.each {|listener| listener.methodcall(self, *args) if listener}
20
+ else
21
+ return false
22
+ end
23
+ return true
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+
32
+ Spade.exports = Ivory::EventEmitterExports
@@ -0,0 +1,245 @@
1
+ # ==========================================================================
2
+ # Project: Ivory
3
+ # Copyright: ©2010 Strobe Inc. All rights reserved.
4
+ # License: Licened under MIT license (see LICENSE)
5
+ # ==========================================================================
6
+
7
+ require 'fileutils'
8
+
9
+ module Ivory
10
+ class Fs < Spade::Runtime::Exports
11
+
12
+ def initialize(ctx)
13
+ @ctx = ctx
14
+ @descriptors = {}
15
+ @descriptors[STDOUT] = Class.new do
16
+ def self.write(chars)
17
+ $stdout.write(chars.pack("C*"))
18
+ end
19
+ end
20
+ end
21
+
22
+ def stdin
23
+ $stdin
24
+ end
25
+
26
+ def stdout
27
+ $stdout
28
+ end
29
+
30
+ def readFile(path, encoding, callback = nil)
31
+ async(callback) do
32
+ File.read(path)
33
+ end
34
+ end
35
+
36
+ def writeFile(path, data, encoding, callback=nil)
37
+ async(callback) do
38
+ File.open(path, 'w+') { |fd| fd.write(data); }
39
+ end
40
+ end
41
+
42
+ def chmod(path, mode, callback = nil)
43
+ async(callback) do
44
+ File.chmod(mode, path)
45
+ end
46
+ end
47
+
48
+ def exists(path)
49
+ File.exists?(path)
50
+ end
51
+
52
+ def open(path, flags, mode, callback = nil)
53
+ async(callback) do
54
+ file = File.new(path, flags, mode)
55
+ file.fileno.tap do |fd|
56
+ @descriptors[fd] = file
57
+ end
58
+ end
59
+ end
60
+
61
+ def close(fd, callback = nil)
62
+ async(callback) do
63
+ file(fd) do |f|
64
+ f.close()
65
+ @descriptors.delete(fd)
66
+ end
67
+ end
68
+ end
69
+
70
+ def read(fd, buffer, offset, length, position, callback = nil)
71
+ raise "Offset is out of bounds" unless offset <= buffer.length
72
+ raise "Length is extends beyond buffer" unless (offset + length) <= buffer.length
73
+ async(callback) do
74
+ file(fd) do |f|
75
+ f.seek(position) if position
76
+ data = buffer.send(:data)
77
+ bytes = f.read(length)
78
+ data[offset, bytes.length] = bytes.unpack('C*')
79
+ bytes.length
80
+ end
81
+ end
82
+ end
83
+
84
+ def write(fd, buffer, offset, length, position, callback = nil)
85
+ async(callback) do
86
+ file(fd) do |f|
87
+ f.seek(position) if position
88
+ data = buffer.send(:data)
89
+ f.write(data[offset, length])
90
+ end
91
+ length
92
+ end
93
+ end
94
+
95
+ def stat(path, callback = nil)
96
+ async(callback) do
97
+ Stats.new(File.stat(path))
98
+ end
99
+ end
100
+
101
+ def lstat(path, callback = nil)
102
+ async(callback) do
103
+ Stats.new(File.lstat(path))
104
+ end
105
+ end
106
+
107
+ def fstat(fd, callback = nil)
108
+ async(callback) do
109
+ file(fd) do |f|
110
+ Stats.new(f.stat)
111
+ end
112
+ end
113
+ end
114
+
115
+ def fsync(fd, callback = nil)
116
+ async(callback) do
117
+ file(fd) do |f|
118
+ f.fsync
119
+ end
120
+ end
121
+ end
122
+
123
+ def readlink(path, callback = nil)
124
+ async(callback) do
125
+ File.readlink(path)
126
+ end
127
+ end
128
+
129
+ def link(old_name, new_name, callback = nil)
130
+ async(callback) do
131
+ File.link(old_name, new_name)
132
+ end
133
+ end
134
+
135
+ def symlink(old_name, new_name, callback = nil)
136
+ async(callback) do
137
+ File.symlink(old_name, new_name)
138
+ end
139
+ end
140
+
141
+ def unlink(filename, callback = nil)
142
+ async(callback) do
143
+ File.unlink(filename)
144
+ end
145
+ end
146
+
147
+ def rename(old_name, new_name, callback = nil)
148
+ async(callback) do
149
+ File.rename(old_name, new_name)
150
+ end
151
+ end
152
+
153
+ def rmdir(dir, callback = nil)
154
+ async(callback) do
155
+ Dir.rmdir(dir)
156
+ end
157
+ end
158
+
159
+ def mkdir(name, mode, callback = nil)
160
+ async(callback) do
161
+ Dir.mkdir(name)
162
+ end
163
+ end
164
+
165
+ def mkdir_p(name, mode, callback = nil)
166
+ async(callback) do
167
+ FileUtils.mkdir_p(name, mode)
168
+ end
169
+ end
170
+
171
+ def readdir(path, callback = nil)
172
+ async(callback) do
173
+ Dir.entries(path).reject { |e| ['.', '..'].include?(e) }
174
+ end
175
+ end
176
+
177
+ #TODO: figure out how to call fdatasync from ruby
178
+ alias_method :fdatasync, :fsync
179
+
180
+ class Stats
181
+ def initialize(stat)
182
+ @stat = stat
183
+ end
184
+
185
+ def size
186
+ @stat.size
187
+ end
188
+
189
+ def mtime
190
+ @stat.mtime
191
+ end
192
+
193
+ def mode
194
+ @stat.mode
195
+ end
196
+
197
+ def isSymbolicLink(*a)
198
+ @stat.symlink?
199
+ end
200
+
201
+ def isDirectory(*a)
202
+ @stat.directory?
203
+ end
204
+
205
+ def dev
206
+ @stat.dev
207
+ end
208
+
209
+ def ino
210
+ @stat.ino
211
+ end
212
+ end
213
+
214
+ private
215
+
216
+ def file(fd)
217
+ if file = @descriptors[fd]
218
+ yield file
219
+ end
220
+ end
221
+
222
+ def async(callback)
223
+ if callback
224
+ begin
225
+ result = yield
226
+ begin
227
+ callback.call(false, result)
228
+ rescue Exception
229
+ end
230
+ rescue Exception => e
231
+ begin
232
+ callback.call(e,nil)
233
+ rescue Exception => e
234
+ end
235
+ end
236
+ else
237
+ yield
238
+ end
239
+ end
240
+ end
241
+ end
242
+
243
+ Spade.exports = Ivory::Fs
244
+
245
+
@@ -0,0 +1,28 @@
1
+ # ==========================================================================
2
+ # Project: Ivory
3
+ # Copyright: ©2010 Strobe Inc. All rights reserved.
4
+ # License: Licened under MIT license (see LICENSE)
5
+ # ==========================================================================
6
+
7
+ module Ivory
8
+
9
+ class Process
10
+
11
+ def initialize(ctx=nil)
12
+ @ctx = ctx
13
+ end
14
+
15
+ # *args req to make this appear as a func
16
+ def cwd(*args)
17
+ Dir.pwd
18
+ end
19
+
20
+ def stdout
21
+ $stdout
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
28
+ Spade.exports = Ivory::Process
@@ -0,0 +1,115 @@
1
+ // ==========================================================================
2
+ // Project: Ivory
3
+ // Copyright: ©2010 Strobe Inc. All rights reserved.
4
+ // License: Licened under MIT license
5
+ // ==========================================================================
6
+
7
+ var events = require('./events');
8
+ var util = require('./util');
9
+
10
+ function Stream() {
11
+ events.EventEmitter.call(this);
12
+ }
13
+ util.inherits(Stream, events.EventEmitter);
14
+ exports.Stream = Stream;
15
+
16
+ Stream.prototype.pipe = function(dest /* options, filter */) {
17
+ var source = this;
18
+
19
+ // parse arguments
20
+ var options, filter;
21
+ if (typeof arguments[1] == 'object') {
22
+ options = arguments[1];
23
+ filter = arguments[2];
24
+ } else {
25
+ filter = arguments[1];
26
+ }
27
+
28
+ function ondata(chunk) {
29
+ // FIXME shouldn't need to test writable - this is working around bug.
30
+ // .writable should not change before a 'end' event is fired.
31
+ if (dest.writable) {
32
+ if (false === dest.write(chunk)) source.pause();
33
+ }
34
+ }
35
+
36
+ if (!filter) {
37
+ source.on('data', ondata);
38
+ } else {
39
+ //
40
+ // TODO: needs tests
41
+ //
42
+ var wait = false;
43
+ var waitQueue = [];
44
+
45
+ function done () {
46
+ wait = false;
47
+ // Drain the waitQueue
48
+ if (dest.writable && waitQueue.length) {
49
+ wait = true;
50
+ filter(waitQueue.shift(), ondata, done);
51
+ }
52
+ }
53
+
54
+ source.on('data', function (d) {
55
+ if (wait) {
56
+ waitQueue.push(d);
57
+ source.pause();
58
+ } else {
59
+ wait = true;
60
+ filter(d, ondata, done);
61
+ }
62
+ });
63
+ }
64
+
65
+
66
+ function ondrain() {
67
+ if (source.readable) source.resume();
68
+ }
69
+
70
+ dest.on('drain', ondrain);
71
+
72
+ /*
73
+ * If the 'end' option is not supplied, dest.end() will be called when
74
+ * source gets the 'end' event.
75
+ */
76
+
77
+ if (!options || options.end !== false) {
78
+ function onend() {
79
+ dest.end();
80
+ }
81
+
82
+ source.on('end', onend);
83
+ }
84
+
85
+ dest.on('close', function() {
86
+ source.removeListener('data', ondata);
87
+ dest.removeListener('drain', ondrain);
88
+ source.removeListener('end', onend);
89
+ });
90
+
91
+
92
+ /*
93
+ * Questionable:
94
+ */
95
+
96
+ if (!source.pause) {
97
+ source.pause = function() {
98
+ source.emit('pause');
99
+ };
100
+ }
101
+
102
+ if (!source.resume) {
103
+ source.resume = function() {
104
+ source.emit('resume');
105
+ };
106
+ }
107
+
108
+ dest.on('pause', function() {
109
+ source.pause();
110
+ });
111
+
112
+ dest.on('resume', function() {
113
+ if (source.readable) source.resume();
114
+ });
115
+ };
@@ -0,0 +1,414 @@
1
+ // ==========================================================================
2
+ // Project: Ivory
3
+ // Copyright: ©2010 Strobe Inc. All rights reserved.
4
+ // License: Licened under MIT license
5
+ // ==========================================================================
6
+
7
+ var process = require('./ruby/process');
8
+ var events = require('./events');
9
+
10
+
11
+ exports.print = function() {
12
+ for (var i = 0, len = arguments.length; i < len; ++i) {
13
+ process.stdout.write(String(arguments[i]));
14
+ }
15
+ };
16
+
17
+
18
+ exports.puts = function() {
19
+ for (var i = 0, len = arguments.length; i < len; ++i) {
20
+ process.stdout.write(arguments[i] + '\n');
21
+ }
22
+ };
23
+
24
+ exports.println = exports.puts;
25
+
26
+ exports.debug = function(x) {
27
+ console.debug(x);
28
+ };
29
+
30
+
31
+ exports.error = function(x) {
32
+ console.error(x);
33
+ };
34
+ var error = exports.error;
35
+
36
+
37
+ /**
38
+ * Echos the value of a value. Trys to print the value out
39
+ * in the best way possible given the different types.
40
+ *
41
+ * @param {Object} obj The object to print out.
42
+ * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
43
+ * properties of objects.
44
+ * @param {Number} depth Depth in which to descend in object. Default is 2.
45
+ * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
46
+ * output. Default is false (no coloring).
47
+ */
48
+ exports.inspect = function(obj, showHidden, depth, colors) {
49
+ var seen = [];
50
+
51
+ var stylize = function(str, styleType) {
52
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
53
+ var styles =
54
+ { 'bold' : [1, 22],
55
+ 'italic' : [3, 23],
56
+ 'underline' : [4, 24],
57
+ 'inverse' : [7, 27],
58
+ 'white' : [37, 39],
59
+ 'grey' : [90, 39],
60
+ 'black' : [30, 39],
61
+ 'blue' : [34, 39],
62
+ 'cyan' : [36, 39],
63
+ 'green' : [32, 39],
64
+ 'magenta' : [35, 39],
65
+ 'red' : [31, 39],
66
+ 'yellow' : [33, 39] };
67
+
68
+ var style =
69
+ { 'special': 'cyan',
70
+ 'number': 'blue',
71
+ 'boolean': 'yellow',
72
+ 'undefined': 'grey',
73
+ 'null': 'bold',
74
+ 'string': 'green',
75
+ 'date': 'magenta',
76
+ // "name": intentionally not styling
77
+ 'regexp': 'red' }[styleType];
78
+
79
+ if (style) {
80
+ return '\033[' + styles[style][0] + 'm' + str +
81
+ '\033[' + styles[style][1] + 'm';
82
+ } else {
83
+ return str;
84
+ }
85
+ };
86
+ if (! colors) {
87
+ stylize = function(str, styleType) { return str; };
88
+ }
89
+
90
+ function format(value, recurseTimes) {
91
+ // Provide a hook for user-specified inspect functions.
92
+ // Check that value is an object with an inspect function on it
93
+ if (value && typeof value.inspect === 'function' &&
94
+ // Filter out the util module, it's inspect function is special
95
+ value !== exports &&
96
+ // Also filter out any prototype objects using the circular check.
97
+ !(value.constructor && value.constructor.prototype === value)) {
98
+ return value.inspect(recurseTimes);
99
+ }
100
+
101
+ // Primitive types cannot have properties
102
+ switch (typeof value) {
103
+ case 'undefined':
104
+ return stylize('undefined', 'undefined');
105
+
106
+ case 'string':
107
+ var simple = JSON.stringify(value).replace(/'/g, "\\'")
108
+ .replace(/\\"/g, '"')
109
+ .replace(/(^"|"$)/g, "'");
110
+ return stylize(simple, 'string');
111
+
112
+ case 'number':
113
+ return stylize('' + value, 'number');
114
+
115
+ case 'boolean':
116
+ return stylize('' + value, 'boolean');
117
+ }
118
+ // For some reason typeof null is "object", so special case here.
119
+ if (value === null) {
120
+ return stylize('null', 'null');
121
+ }
122
+
123
+ // Look up the keys of the object.
124
+ var visible_keys = Object.keys(value);
125
+ var keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys;
126
+
127
+ // Functions without properties can be shortcutted.
128
+ if (typeof value === 'function' && keys.length === 0) {
129
+ if (isRegExp(value)) {
130
+ return stylize('' + value, 'regexp');
131
+ } else {
132
+ var name = value.name ? ': ' + value.name : '';
133
+ return stylize('[Function' + name + ']', 'special');
134
+ }
135
+ }
136
+
137
+ // Dates without properties can be shortcutted
138
+ if (isDate(value) && keys.length === 0) {
139
+ return stylize(value.toUTCString(), 'date');
140
+ }
141
+
142
+ var base, type, braces;
143
+ // Determine the object type
144
+ if (isArray(value)) {
145
+ type = 'Array';
146
+ braces = ['[', ']'];
147
+ } else {
148
+ type = 'Object';
149
+ braces = ['{', '}'];
150
+ }
151
+
152
+ // Make functions say that they are functions
153
+ if (typeof value === 'function') {
154
+ var n = value.name ? ': ' + value.name : '';
155
+ base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';
156
+ } else {
157
+ base = '';
158
+ }
159
+
160
+ // Make dates with properties first say the date
161
+ if (isDate(value)) {
162
+ base = ' ' + value.toUTCString();
163
+ }
164
+
165
+ if (keys.length === 0) {
166
+ return braces[0] + base + braces[1];
167
+ }
168
+
169
+ if (recurseTimes < 0) {
170
+ if (isRegExp(value)) {
171
+ return stylize('' + value, 'regexp');
172
+ } else {
173
+ return stylize('[Object]', 'special');
174
+ }
175
+ }
176
+
177
+ seen.push(value);
178
+
179
+ var output = keys.map(function(key) {
180
+ var name, str;
181
+ if (value.__lookupGetter__) {
182
+ if (value.__lookupGetter__(key)) {
183
+ if (value.__lookupSetter__(key)) {
184
+ str = stylize('[Getter/Setter]', 'special');
185
+ } else {
186
+ str = stylize('[Getter]', 'special');
187
+ }
188
+ } else {
189
+ if (value.__lookupSetter__(key)) {
190
+ str = stylize('[Setter]', 'special');
191
+ }
192
+ }
193
+ }
194
+ if (visible_keys.indexOf(key) < 0) {
195
+ name = '[' + key + ']';
196
+ }
197
+ if (!str) {
198
+ if (seen.indexOf(value[key]) < 0) {
199
+ if (recurseTimes === null) {
200
+ str = format(value[key]);
201
+ } else {
202
+ str = format(value[key], recurseTimes - 1);
203
+ }
204
+ if (str.indexOf('\n') > -1) {
205
+ if (isArray(value)) {
206
+ str = str.split('\n').map(function(line) {
207
+ return ' ' + line;
208
+ }).join('\n').substr(2);
209
+ } else {
210
+ str = '\n' + str.split('\n').map(function(line) {
211
+ return ' ' + line;
212
+ }).join('\n');
213
+ }
214
+ }
215
+ } else {
216
+ str = stylize('[Circular]', 'special');
217
+ }
218
+ }
219
+ if (typeof name === 'undefined') {
220
+ if (type === 'Array' && key.match(/^\d+$/)) {
221
+ return str;
222
+ }
223
+ name = JSON.stringify('' + key);
224
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
225
+ name = name.substr(1, name.length - 2);
226
+ name = stylize(name, 'name');
227
+ } else {
228
+ name = name.replace(/'/g, "\\'")
229
+ .replace(/\\"/g, '"')
230
+ .replace(/(^"|"$)/g, "'");
231
+ name = stylize(name, 'string');
232
+ }
233
+ }
234
+
235
+ return name + ': ' + str;
236
+ });
237
+
238
+ seen.pop();
239
+
240
+ var numLinesEst = 0;
241
+ var length = output.reduce(function(prev, cur) {
242
+ numLinesEst++;
243
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
244
+ return prev + cur.length + 1;
245
+ }, 0);
246
+
247
+ if (length > (require('readline').columns || 50)) {
248
+ output = braces[0] +
249
+ (base === '' ? '' : base + '\n ') +
250
+ ' ' +
251
+ output.join(',\n ') +
252
+ ' ' +
253
+ braces[1];
254
+
255
+ } else {
256
+ output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
257
+ }
258
+
259
+ return output;
260
+ }
261
+ return format(obj, (typeof depth === 'undefined' ? 2 : depth));
262
+ };
263
+
264
+
265
+ function isArray(ar) {
266
+ return ar instanceof Array ||
267
+ Array.isArray(ar) ||
268
+ (ar && ar !== Object.prototype && isArray(ar.__proto__));
269
+ }
270
+
271
+
272
+ function isRegExp(re) {
273
+ var s = '' + re;
274
+ return re instanceof RegExp || // easy case
275
+ // duck-type for context-switching evalcx case
276
+ typeof(re) === 'function' &&
277
+ re.constructor.name === 'RegExp' &&
278
+ re.compile &&
279
+ re.test &&
280
+ re.exec &&
281
+ s.match(/^\/.*\/[gim]{0,3}$/);
282
+ }
283
+
284
+
285
+ function isDate(d) {
286
+ if (d instanceof Date) return true;
287
+ if (typeof d !== 'object') return false;
288
+ var properties = Date.prototype && Object.getOwnPropertyNames(Date.prototype);
289
+ var proto = d.__proto__ && Object.getOwnPropertyNames(d.__proto__);
290
+ return JSON.stringify(proto) === JSON.stringify(properties);
291
+ }
292
+
293
+
294
+ var pWarning;
295
+
296
+ exports.p = function() {
297
+ if (!pWarning) {
298
+ pWarning = 'util.p will be removed in future versions of Node. ' +
299
+ 'Use util.puts(util.inspect()) instead.\n';
300
+ exports.error(pWarning);
301
+ }
302
+ for (var i = 0, len = arguments.length; i < len; ++i) {
303
+ error(exports.inspect(arguments[i]));
304
+ }
305
+ };
306
+
307
+
308
+ function pad(n) {
309
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
310
+ }
311
+
312
+
313
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
314
+ 'Oct', 'Nov', 'Dec'];
315
+
316
+ // 26 Feb 16:19:34
317
+ function timestamp() {
318
+ var d = new Date();
319
+ var time = [pad(d.getHours()),
320
+ pad(d.getMinutes()),
321
+ pad(d.getSeconds())].join(':');
322
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
323
+ }
324
+
325
+
326
+ exports.log = function(msg) {
327
+ exports.puts(timestamp() + ' - ' + msg.toString());
328
+ };
329
+
330
+
331
+ var execWarning;
332
+ exports.exec = function() {
333
+ if (!execWarning) {
334
+ execWarning = 'util.exec has moved to the "child_process" module.' +
335
+ ' Please update your source code.';
336
+ error(execWarning);
337
+ }
338
+ return require('child_process').exec.apply(this, arguments);
339
+ };
340
+
341
+
342
+ exports.pump = function(readStream, writeStream, callback) {
343
+ var callbackCalled = false;
344
+
345
+ function call(a, b, c) {
346
+ if (callback && !callbackCalled) {
347
+ callback(a, b, c);
348
+ callbackCalled = true;
349
+ }
350
+ }
351
+
352
+ if (!readStream.pause) {
353
+ readStream.pause = function() {readStream.emit('pause');};
354
+ }
355
+
356
+ if (!readStream.resume) {
357
+ readStream.resume = function() {readStream.emit('resume');};
358
+ }
359
+
360
+ readStream.addListener('data', function(chunk) {
361
+ if (writeStream.write(chunk) === false) readStream.pause();
362
+ });
363
+
364
+ writeStream.addListener('pause', function() {
365
+ readStream.pause();
366
+ });
367
+
368
+ writeStream.addListener('drain', function() {
369
+ readStream.resume();
370
+ });
371
+
372
+ writeStream.addListener('resume', function() {
373
+ readStream.resume();
374
+ });
375
+
376
+ readStream.addListener('end', function() {
377
+ writeStream.end();
378
+ });
379
+
380
+ readStream.addListener('close', function() {
381
+ call();
382
+ });
383
+
384
+ readStream.addListener('error', function(err) {
385
+ writeStream.end();
386
+ call(err);
387
+ });
388
+
389
+ writeStream.addListener('error', function(err) {
390
+ readStream.destroy();
391
+ call(err);
392
+ });
393
+ };
394
+
395
+
396
+ /**
397
+ * Inherit the prototype methods from one constructor into another.
398
+ *
399
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
400
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
401
+ * during bootstrapping this function needs to be revritten using some native
402
+ * functions as prototype setup using normal JavaScript does not work as
403
+ * expected during bootstrapping (see mirror.js in r114903).
404
+ *
405
+ * @param {function} ctor Constructor function which needs to inherit the
406
+ * prototype.
407
+ * @param {function} superCtor Constructor function to inherit prototype from.
408
+ */
409
+ exports.inherits = function(ctor, superCtor) {
410
+ ctor.super_ = superCtor;
411
+ ctor.prototype = Object.create(superCtor.prototype, {
412
+ constructor: { value: ctor, enumerable: false }
413
+ });
414
+ };