sproutit-narwhal 0.1.106

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. data/DISTRIBUTION.yml +15 -0
  2. data/README.md +86 -0
  3. data/Rakefile +349 -0
  4. data/VERSION.yml +7 -0
  5. data/bin/activate +50 -0
  6. data/bin/activate.bash +50 -0
  7. data/bin/activate.cmd +3 -0
  8. data/bin/js +67 -0
  9. data/bin/json +2 -0
  10. data/bin/narwhal +67 -0
  11. data/bin/narwhal.cmd +29 -0
  12. data/bin/sea +45 -0
  13. data/bin/sea.cmd +25 -0
  14. data/bin/tusk +2 -0
  15. data/bin/tusk.cmd +5 -0
  16. data/catalog.json +902 -0
  17. data/docs/available-packages.md +32 -0
  18. data/docs/browser-api-plan.md +290 -0
  19. data/docs/browser-api.md +153 -0
  20. data/docs/download.md +25 -0
  21. data/docs/engines.md +32 -0
  22. data/docs/json-tool.md +121 -0
  23. data/docs/lib/binary.wiki +242 -0
  24. data/docs/lib/file.wiki +325 -0
  25. data/docs/lib/os/popen.md +70 -0
  26. data/docs/modules.md +38 -0
  27. data/docs/narwhal.md +487 -0
  28. data/docs/packages-howto.md +32 -0
  29. data/docs/packages.md +30 -0
  30. data/docs/posts/2009-07-29-hello-0.1.md +19 -0
  31. data/docs/quick-start.md +69 -0
  32. data/docs/sea.md +49 -0
  33. data/engines/browser/lib/binary.js +2 -0
  34. data/engines/browser/lib/reactor.js +21 -0
  35. data/engines/browser/lib/system.js +3 -0
  36. data/engines/default/lib/array.js +164 -0
  37. data/engines/default/lib/binary-engine.js +53 -0
  38. data/engines/default/lib/binary.js +755 -0
  39. data/engines/default/lib/date.js +8 -0
  40. data/engines/default/lib/file-engine.js +119 -0
  41. data/engines/default/lib/function.js +119 -0
  42. data/engines/default/lib/global.js +11 -0
  43. data/engines/default/lib/io-engine.js +26 -0
  44. data/engines/default/lib/json.js +488 -0
  45. data/engines/default/lib/object.js +69 -0
  46. data/engines/default/lib/os-engine.js +3 -0
  47. data/engines/default/lib/reactor.js +12 -0
  48. data/engines/default/lib/string.js +84 -0
  49. data/engines/default/lib/system.js +20 -0
  50. data/engines/default/lib/worker.js +133 -0
  51. data/engines/jsc/README.md +18 -0
  52. data/engines/jsc/bootstrap.js +53 -0
  53. data/engines/jsc/deps/http-parser/LICENSE +77 -0
  54. data/engines/jsc/deps/http-parser/README.md +145 -0
  55. data/engines/jsc/deps/http-parser/http_parser.c +6087 -0
  56. data/engines/jsc/deps/http-parser/http_parser.h +141 -0
  57. data/engines/jsc/deps/http-parser/http_parser.rl +500 -0
  58. data/engines/jsc/deps/http-parser/test.c +858 -0
  59. data/engines/jsc/include/binary-engine.h +11 -0
  60. data/engines/jsc/include/io-engine.h +23 -0
  61. data/engines/jsc/include/narwhal.h +427 -0
  62. data/engines/jsc/lib/file-engine.js +31 -0
  63. data/engines/jsc/lib/http.js +1 -0
  64. data/engines/jsc/lib/io-engine.js +202 -0
  65. data/engines/jsc/lib/os-engine.js +25 -0
  66. data/engines/jsc/lib/system.js +18 -0
  67. data/engines/jsc/lib/zip.js +1 -0
  68. data/engines/jsc/narwhal-jsc.c +273 -0
  69. data/engines/jsc/narwhal.c +29 -0
  70. data/engines/jsc/package.json +8 -0
  71. data/engines/jsc/src/binary-engine.cc +290 -0
  72. data/engines/jsc/src/file-engine.cc +405 -0
  73. data/engines/jsc/src/io-engine.cc +423 -0
  74. data/engines/jsc/src/jack/handler/jill.cc +710 -0
  75. data/engines/jsc/src/os-engine.cc +210 -0
  76. data/engines/rhino/bin/narwhal-rhino +68 -0
  77. data/engines/rhino/bin/narwhal-rhino.cmd +34 -0
  78. data/engines/rhino/bootstrap.js +119 -0
  79. data/engines/rhino/jars/jline.jar +0 -0
  80. data/engines/rhino/jars/jna.jar +0 -0
  81. data/engines/rhino/jars/js.jar +0 -0
  82. data/engines/rhino/lib/binary-engine.js +83 -0
  83. data/engines/rhino/lib/concurrency.js +6 -0
  84. data/engines/rhino/lib/event-queue.js +18 -0
  85. data/engines/rhino/lib/file-engine.js +216 -0
  86. data/engines/rhino/lib/http-client-engine.js +90 -0
  87. data/engines/rhino/lib/http-engine.js +10 -0
  88. data/engines/rhino/lib/io-engine.js +347 -0
  89. data/engines/rhino/lib/md5-engine.js +40 -0
  90. data/engines/rhino/lib/os-engine.js +150 -0
  91. data/engines/rhino/lib/packages-engine.js +71 -0
  92. data/engines/rhino/lib/sandbox-engine.js +70 -0
  93. data/engines/rhino/lib/system.js +38 -0
  94. data/engines/rhino/lib/worker-engine.js +23 -0
  95. data/engines/rhino/lib/zip.js +78 -0
  96. data/engines/rhino/package.json +4 -0
  97. data/engines/secure/lib/file.js +6 -0
  98. data/engines/secure/lib/system.js +6 -0
  99. data/engines/template/bin/narwhal-engine-name +32 -0
  100. data/engines/template/bootstrap.js +40 -0
  101. data/engines/template/lib/file-engine.js +118 -0
  102. data/engines/template/lib/system.js +17 -0
  103. data/examples/browser-deployment-jackconfig.js +35 -0
  104. data/examples/fibonacci-worker.js +35 -0
  105. data/examples/fibonacci.js +19 -0
  106. data/examples/hello +2 -0
  107. data/examples/narwhal +3 -0
  108. data/examples/not-quite-a-quine.js +1 -0
  109. data/extconf.rb +44 -0
  110. data/gem_bin/narwhal +5 -0
  111. data/gem_bin/sea +4 -0
  112. data/gem_bin/tusk +4 -0
  113. data/lib/args.js +849 -0
  114. data/lib/base16.js +16 -0
  115. data/lib/base64.js +120 -0
  116. data/lib/codec/base64.js +8 -0
  117. data/lib/crc32.js +60 -0
  118. data/lib/file-bootstrap.js +187 -0
  119. data/lib/file.js +659 -0
  120. data/lib/hash.js +28 -0
  121. data/lib/hashp.js +65 -0
  122. data/lib/html.js +16 -0
  123. data/lib/http-client.js +134 -0
  124. data/lib/http.js +17 -0
  125. data/lib/io.js +98 -0
  126. data/lib/jsmin.js +315 -0
  127. data/lib/jsonpath.js +89 -0
  128. data/lib/logger.js +55 -0
  129. data/lib/md4.js +146 -0
  130. data/lib/md5.js +164 -0
  131. data/lib/mime.js +166 -0
  132. data/lib/narwhal.js +102 -0
  133. data/lib/narwhal/client.js +261 -0
  134. data/lib/narwhal/compile.js +99 -0
  135. data/lib/narwhal/env.js +140 -0
  136. data/lib/narwhal/inline.js +106 -0
  137. data/lib/narwhal/json.js +324 -0
  138. data/lib/narwhal/json.md +178 -0
  139. data/lib/narwhal/repl.js +96 -0
  140. data/lib/narwhal/server-test.js +6 -0
  141. data/lib/narwhal/server.js +270 -0
  142. data/lib/narwhal/tusk.js +170 -0
  143. data/lib/narwhal/tusk/bin.js +13 -0
  144. data/lib/narwhal/tusk/bundle.js +0 -0
  145. data/lib/narwhal/tusk/catalog.js +22 -0
  146. data/lib/narwhal/tusk/clone.js +66 -0
  147. data/lib/narwhal/tusk/consolidate.js +25 -0
  148. data/lib/narwhal/tusk/create-catalog.js +80 -0
  149. data/lib/narwhal/tusk/engine.js +42 -0
  150. data/lib/narwhal/tusk/freeze.js +0 -0
  151. data/lib/narwhal/tusk/init.js +56 -0
  152. data/lib/narwhal/tusk/install.js +288 -0
  153. data/lib/narwhal/tusk/list.js +20 -0
  154. data/lib/narwhal/tusk/orphans.js +0 -0
  155. data/lib/narwhal/tusk/reheat.js +15 -0
  156. data/lib/narwhal/tusk/remove.js +15 -0
  157. data/lib/narwhal/tusk/search.js +145 -0
  158. data/lib/narwhal/tusk/update.js +21 -0
  159. data/lib/narwhal/tusk/upgrade.js +0 -0
  160. data/lib/os.js +33 -0
  161. data/lib/packages.js +423 -0
  162. data/lib/printf.js +169 -0
  163. data/lib/promise.js +352 -0
  164. data/lib/querystring.js +176 -0
  165. data/lib/ref-send.js +257 -0
  166. data/lib/regexp.js +12 -0
  167. data/lib/sandbox.js +422 -0
  168. data/lib/sha.js +112 -0
  169. data/lib/sha256.js +102 -0
  170. data/lib/struct.js +228 -0
  171. data/lib/term.js +179 -0
  172. data/lib/test/assert.js +95 -0
  173. data/lib/test/equiv.js +188 -0
  174. data/lib/test/jsdump.js +165 -0
  175. data/lib/test/runner.js +129 -0
  176. data/lib/unload.js +13 -0
  177. data/lib/uri.js +378 -0
  178. data/lib/url.js +5 -0
  179. data/lib/utf8.js +64 -0
  180. data/lib/util.js +985 -0
  181. data/lib/uuid.js +89 -0
  182. data/lib/xregexp.js +521 -0
  183. data/local.json.template +1 -0
  184. data/narwhal.gemspec +105 -0
  185. data/narwhal.js +213 -0
  186. data/package.json +26 -0
  187. data/packages/readline/engines/default/lib/readline.js +4 -0
  188. data/packages/readline/engines/rhino/lib/readline.js +6 -0
  189. data/packages/readline/package.json +5 -0
  190. data/sources.json +207 -0
  191. data/tests/all-tests.js +17 -0
  192. data/tests/args.js +31 -0
  193. data/tests/args/domain.js +215 -0
  194. data/tests/args/options.js +36 -0
  195. data/tests/args/shifting.js +92 -0
  196. data/tests/args/validation.js +31 -0
  197. data/tests/base64.js +23 -0
  198. data/tests/commonjs.js +3 -0
  199. data/tests/commonjs/all-tests.js +12 -0
  200. data/tests/commonjs/bytearray-encodings-tests.js +69 -0
  201. data/tests/commonjs/bytearray-tests.js +465 -0
  202. data/tests/commonjs/bytestring-encodings-tests.js +89 -0
  203. data/tests/commonjs/bytestring-tests.js +263 -0
  204. data/tests/commonjs/es5/all-tests.js +3 -0
  205. data/tests/commonjs/es5/bind.js +29 -0
  206. data/tests/commonjs/file-tests.js +315 -0
  207. data/tests/commonjs/file/dirname.js +31 -0
  208. data/tests/commonjs/file/extension.js +45 -0
  209. data/tests/commonjs/file/is-absolute.js +11 -0
  210. data/tests/commonjs/file/iterator.js +101 -0
  211. data/tests/commonjs/file/normal.js +27 -0
  212. data/tests/commonjs/file/path.js +17 -0
  213. data/tests/commonjs/file/relative.js +42 -0
  214. data/tests/commonjs/file/resolve.js +44 -0
  215. data/tests/commonjs/module-tests.js +9 -0
  216. data/tests/commonjs/modules/absolute/b.js +1 -0
  217. data/tests/commonjs/modules/absolute/program.js +5 -0
  218. data/tests/commonjs/modules/absolute/submodule/a.js +3 -0
  219. data/tests/commonjs/modules/absolute/test.js +9 -0
  220. data/tests/commonjs/modules/all-tests.js +47 -0
  221. data/tests/commonjs/modules/config.js +11 -0
  222. data/tests/commonjs/modules/cyclic/a.js +4 -0
  223. data/tests/commonjs/modules/cyclic/b.js +4 -0
  224. data/tests/commonjs/modules/cyclic/program.js +10 -0
  225. data/tests/commonjs/modules/cyclic/test.js +9 -0
  226. data/tests/commonjs/modules/determinism/program.js +3 -0
  227. data/tests/commonjs/modules/determinism/submodule/a.js +8 -0
  228. data/tests/commonjs/modules/determinism/submodule/b.js +2 -0
  229. data/tests/commonjs/modules/determinism/test.js +9 -0
  230. data/tests/commonjs/modules/exactExports/a.js +3 -0
  231. data/tests/commonjs/modules/exactExports/program.js +4 -0
  232. data/tests/commonjs/modules/exactExports/test.js +9 -0
  233. data/tests/commonjs/modules/hasOwnProperty/hasOwnProperty.js +0 -0
  234. data/tests/commonjs/modules/hasOwnProperty/program.js +3 -0
  235. data/tests/commonjs/modules/hasOwnProperty/test.js +9 -0
  236. data/tests/commonjs/modules/hasOwnProperty/toString.js +0 -0
  237. data/tests/commonjs/modules/method/a.js +12 -0
  238. data/tests/commonjs/modules/method/program.js +8 -0
  239. data/tests/commonjs/modules/method/test.js +9 -0
  240. data/tests/commonjs/modules/missing/program.js +8 -0
  241. data/tests/commonjs/modules/missing/test.js +9 -0
  242. data/tests/commonjs/modules/monkeys/a.js +1 -0
  243. data/tests/commonjs/modules/monkeys/program.js +4 -0
  244. data/tests/commonjs/modules/monkeys/test.js +9 -0
  245. data/tests/commonjs/modules/nested/a/b/c/d.js +3 -0
  246. data/tests/commonjs/modules/nested/program.js +3 -0
  247. data/tests/commonjs/modules/nested/test.js +9 -0
  248. data/tests/commonjs/modules/relative/program.js +5 -0
  249. data/tests/commonjs/modules/relative/submodule/a.js +1 -0
  250. data/tests/commonjs/modules/relative/submodule/b.js +2 -0
  251. data/tests/commonjs/modules/relative/test.js +9 -0
  252. data/tests/commonjs/modules/transitive/a.js +1 -0
  253. data/tests/commonjs/modules/transitive/b.js +1 -0
  254. data/tests/commonjs/modules/transitive/c.js +3 -0
  255. data/tests/commonjs/modules/transitive/program.js +3 -0
  256. data/tests/commonjs/modules/transitive/test.js +9 -0
  257. data/tests/file/all-tests.js +61 -0
  258. data/tests/file/fnmatch.js +102 -0
  259. data/tests/file/glob.js +466 -0
  260. data/tests/file/match.js +102 -0
  261. data/tests/global.js +6 -0
  262. data/tests/global/array.js +19 -0
  263. data/tests/hashes.js +94 -0
  264. data/tests/html.js +13 -0
  265. data/tests/io/stringio.js +21 -0
  266. data/tests/os/all-tests.js +4 -0
  267. data/tests/os/popen.js +41 -0
  268. data/tests/os/system.js +22 -0
  269. data/tests/printf.js +123 -0
  270. data/tests/query-string.js +87 -0
  271. data/tests/sandbox/byte-io.js +20 -0
  272. data/tests/sandbox/fileName.js +3 -0
  273. data/tests/sandbox/foo.js +0 -0
  274. data/tests/sandbox/reload.js +79 -0
  275. data/tests/string.js +35 -0
  276. data/tests/uri.js +41 -0
  277. data/tests/util/all-tests.js +79 -0
  278. data/tests/util/array.js +207 -0
  279. data/tests/util/array/is-arguments.js +29 -0
  280. data/tests/util/array/is-array-like.js +29 -0
  281. data/tests/util/case.js +9 -0
  282. data/tests/util/collection.js +104 -0
  283. data/tests/util/eq.js +57 -0
  284. data/tests/util/expand.js +45 -0
  285. data/tests/util/object.js +125 -0
  286. data/tests/util/operator.js +25 -0
  287. data/tests/util/range.js +19 -0
  288. data/tests/util/repr.js +26 -0
  289. data/tests/util/string.js +34 -0
  290. data/tests/util/unique.js +12 -0
  291. metadata +434 -0
data/DISTRIBUTION.yml ADDED
@@ -0,0 +1,15 @@
1
+ # This file lists all subprojects that need to be installed in the directory
2
+ # for release. The Rakefile will track Git hash codes for each project in
3
+ # the VERSION.yml file
4
+ #
5
+ # Each entry should have the following format:
6
+ #
7
+ # path/to/item:
8
+ # repo: GIT/SVN URL
9
+ # scm: git|svn <- type of source control system. defaults to git
10
+ #
11
+
12
+ engines/jsc:
13
+ repo: git://github.com/tlrobinson/narwhal-jsc.git
14
+
15
+
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ Narwhal
2
+ =======
3
+
4
+ A general purpose JavaScript platform
5
+ -------------------------------------
6
+
7
+ Narwhal is a cross-platform, multi-interpreter, general purpose JavaScript platform. It aims to provide a solid foundation for building JavaScript applications, primarily outside the web browser. Narwhal includes a package manager, module system, and standard library for multiple JavaScript interpreters. Currently Narwhal's [Rhino](http://www.mozilla.org/rhino/) support is the most complete, but [other engines](engines.html) are available too.
8
+
9
+ Narwhal's standard library conforms to the [CommonJS standard](http://wiki.commonjs.org). It is designed to work with multiple JavaScript interpreters, and to be easy to add support for new interpreters. Wherever possible, it is implemented in pure JavaScript to maximize reuse of code among engines.
10
+
11
+ Combined with [Jack](http://jackjs.org/), a [Rack](http://rack.rubyforge.org/)-like [JSGI](http://jackjs.org/jsgi-spec.html) compatible library, Narwhal provides a platform for creating server-side JavaScript web applications and frameworks such as [Nitro](http://www.nitrojs.org/).
12
+
13
+
14
+ ### Homepage:
15
+
16
+ * [http://narwhaljs.org/](http://narwhaljs.org/)
17
+
18
+ ### Source & Download:
19
+
20
+ * [http://github.com/tlrobinson/narwhal/](http://github.com/tlrobinson/narwhal/)
21
+
22
+ ### Mailing list:
23
+
24
+ * [http://groups.google.com/group/narwhaljs](http://groups.google.com/group/narwhaljs)
25
+
26
+ ### IRC:
27
+
28
+ * [\#narwhal on irc.freenode.net](http://webchat.freenode.net/?channels=narwhal)
29
+
30
+
31
+ Documentation
32
+ -------------
33
+
34
+ * [Quick Start](quick-start.html)
35
+ * [Packages](packages.html)
36
+ * [How to Install Packages](packages.html)
37
+ * [How to Build Packages](packages-howto.html)
38
+ * [Modules](modules.html)
39
+ * [Virtual Environments / Seas](sea.html)
40
+ * [How to Build Engines](engines.html)
41
+ * [How Narwhal Works](narwhal.html)
42
+
43
+
44
+ Contributors
45
+ ------------
46
+
47
+ * [Tom Robinson](http://tlrobinson.net/)
48
+ * [Kris Kowal](http://askawizard.blogspot.com/)
49
+ * [George Moschovitis](http://blog.gmosx.com/)
50
+ * [Kevin Dangoor](http://www.blueskyonmars.com/)
51
+ * Hannes Wallnöfer
52
+ * Sébastien Pierre
53
+ * Irakli Gozalishvili
54
+ * [Christoph Dorn](http://www.christophdorn.com/)
55
+ * Zach Carter
56
+ * Nathan L. Smith
57
+ * Jan Varwig
58
+ * Mark Porter
59
+ * [Isaac Z. Schlueter](http://blog.izs.me/)
60
+ * [Kris Zyp](http://www.sitepen.com/blog/author/kzyp/)
61
+ * [Nathan Stott](http://nathan.whiteboard-it.com/)
62
+ * [Toby Ho](http://tobyho.com)
63
+
64
+
65
+ License
66
+ -------
67
+
68
+ Copyright (c) 2009, 280 North Inc. <[280north.com](http://280north.com/)\>
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining a copy
71
+ of this software and associated documentation files (the "Software"), to
72
+ deal in the Software without restriction, including without limitation the
73
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
74
+ sell copies of the Software, and to permit persons to whom the Software is
75
+ furnished to do so, subject to the following conditions:
76
+
77
+ The above copyright notice and this permission notice shall be included in
78
+ all copies or substantial portions of the Software.
79
+
80
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
82
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
83
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
84
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
85
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86
+
data/Rakefile ADDED
@@ -0,0 +1,349 @@
1
+ # ===========================================================================
2
+ # Project: Narwhal Rakefile
3
+ # Copyright: ©2009 Apple Inc. and contributors
4
+ # ===========================================================================
5
+
6
+ # Rakefile used to build the Narwhal Gem. Requires Jeweler to function.
7
+
8
+ ROOT_PATH = File.dirname(__FILE__)
9
+ PKG_NAME = 'narwhal'
10
+
11
+ # files to ignore changes in
12
+ IGNORE_CHANGES = %w[.gitignore .gitmodules .DS_Store .gemspec VERSION.yml ^pkg ^tmp]
13
+
14
+ # Get the DISTRIBUTION info
15
+ require 'yaml'
16
+ DIST = YAML.load File.read(File.expand_path(File.join(ROOT_PATH, 'DISTRIBUTION.yml')))
17
+
18
+ # Make empty to not use sudo
19
+ SUDO = 'sudo'
20
+
21
+ ################################################
22
+ ## LOAD DEPENDENCIES
23
+ ##
24
+ begin
25
+ require 'rubygems'
26
+ require 'jeweler'
27
+ require 'extlib'
28
+ require 'fileutils'
29
+ require 'spec/rake/spectask'
30
+
31
+ $:.unshift(ROOT_PATH / 'lib')
32
+ require 'sproutcore'
33
+
34
+ rescue LoadError => e
35
+ $stderr.puts "WARN: some required gems are not installed (try rake init to setup)"
36
+ $stderr.puts e
37
+ end
38
+
39
+
40
+ ################################################
41
+ ## PROJECT DESCRIPTION
42
+ ##
43
+
44
+ Jeweler::Tasks.new do |gemspec|
45
+ gemspec.name = 'sproutit-narwhal'
46
+ gemspec.authors = 'Published by Sprout Systems Inc. Developed by Tom Robinson and contributors'
47
+ gemspec.email = 'contact@sproutcore.com'
48
+ gemspec.homepage = 'http://www.narwhaljs.com'
49
+ gemspec.summary = "JavaScript Command Line"
50
+
51
+ gemspec.add_development_dependency 'extlib', ">= 0.9.9"
52
+ gemspec.add_development_dependency 'gemcutter', ">= 0.1.0"
53
+ gemspec.add_development_dependency 'jeweler', ">= 1.0.0"
54
+
55
+ gemspec.rubyforge_project = "sproutit-narwhal"
56
+
57
+ gemspec.files.include *%w[engines/jsc/**/* extconf.rb]
58
+ gemspec.files.exclude *%w[.gitignore .gitmodules .DS_Store tmp .hashinfo .svn .git narwhal.conf Makefile]
59
+ gemspec.files.exclude *%w[engines/jsc/**/*.dylib engines/jsc/**/*.dylib.dSYM engines/jsc/**/*.so engines/jsc/**/*.dll engines/jsc/**/*.o engines/jsc/**/*.s engines/jsc/**/*.ii engines/jsc/bin/*]
60
+
61
+ gemspec.description = File.read(ROOT_PATH / 'README.md')
62
+
63
+ # name specifically b/c some of the ones in the bin dir aren't useful as gem
64
+ gemspec.executables = %w(narwhal sea tusk)
65
+ gemspec.extensions = ['extconf.rb']
66
+ gemspec.bindir = 'gem_bin'
67
+
68
+ end
69
+
70
+ Jeweler::RubyforgeTasks.new do |rubyforge|
71
+ rubyforge.doc_task = 'rdoc'
72
+ end
73
+
74
+ Jeweler::GemcutterTasks.new
75
+
76
+
77
+ def git(path, cmd, log=true)
78
+ $stdout.puts("#{path.sub(ROOT_PATH, '')}: git #{cmd}") if log
79
+ git_path = path / '.git'
80
+ git_index = git_path / 'index'
81
+
82
+ # The env can become polluted; breaking git. This will avoid that.
83
+ %x[GIT_DIR=#{git_path}; GIT_WORK_TREE=#{path}; GIT_INDEX_FILE=#{git_index}; git #{cmd}]
84
+ end
85
+
86
+ ################################################
87
+ ## CORE TASKS
88
+ ##
89
+
90
+ desc "performs an initial setup on the tools. Installs gems, checkout"
91
+ task :init => [:install_gems, 'dist:init', 'dist:update']
92
+
93
+ task :install_gems do
94
+ $stdout.puts "Installing gems (may ask for password)"
95
+ system %[#{SUDO} gem install jeweler gemcutter extlib] # dev req
96
+ end
97
+
98
+ namespace :dist do
99
+
100
+ desc "checkout any frameworks in the distribution"
101
+ task :init do
102
+ $stdout.puts "Setup distribution"
103
+
104
+ DIST.each do |rel_path, opts|
105
+ path = ROOT_PATH / rel_path
106
+ repo_url = opts['repo']
107
+
108
+ if !File.exists?(path / ".git")
109
+ $stdout.puts " Creating repo for #{rel_path}"
110
+ FileUtils.mkdir_p File.dirname(path)
111
+
112
+ $stdout.puts "\n> git clone #{repo_url} #{path}"
113
+ system "GIT_WORK_TREE=#{path}; cd #{File.dirname(path)}; git clone #{repo_url} #{File.basename(path)}"
114
+
115
+ else
116
+ $stdout.puts "Found #{rel_path}"
117
+ end
118
+ end
119
+ end
120
+
121
+ desc "make the version of each distribution item match the one in VERSION"
122
+ task :update => 'dist:init' do
123
+ $stdout.puts "Setup distribution"
124
+
125
+ # Use this to get the commit hash
126
+ version_file = ROOT_PATH / 'VERSION.yml'
127
+ if File.exist?(version_file)
128
+ versions = YAML.load File.read(version_file)
129
+ versions = (versions['dist'] || versions[:dist]) if versions
130
+ versions ||= {}
131
+ end
132
+
133
+ DIST.each do |rel_path, opts|
134
+ path = ROOT_PATH / rel_path
135
+
136
+ if File.exists?(path / ".git") && versions[rel_path]
137
+ sha = versions[rel_path]
138
+
139
+ $stdout.puts "\n> git fetch"
140
+ $stdout.puts git(path, 'fetch')
141
+
142
+ $stdout.puts "\n> git checkout #{sha}"
143
+ $stdout.puts git(path, 'checkout #{sha}')
144
+ else
145
+ $stdout.puts "WARN: cannot fix version for #{rel_path}"
146
+ end
147
+
148
+ end
149
+ end
150
+
151
+ end
152
+
153
+ namespace :release do
154
+
155
+ desc "tags the current repository and any distribution repositories. if you can push to distribution, then push tag as well"
156
+ task :tag => :update_version do
157
+ tag_name = "REL-#{RELEASE_VERSION}"
158
+ DIST.keys.push(PKG_NAME).each do |rel_path|
159
+ full_path = rel_path==PKG_NAME ? ROOT_PATH : (ROOT_PATH / rel_path)
160
+ git(full_path, "tag -f #{tag_name}")
161
+ end
162
+ end
163
+
164
+ task :push_tags => :tag do
165
+ tag_name = "REL-#{RELEASE_VERSION}"
166
+ DIST.keys.push(PKG_NAME).each do |rel_path|
167
+ full_path = rel_path==PKG_NAME ? ROOT_PATH : (ROOT_PATH / rel_path)
168
+ git(full_path, "push origin #{tag_name}")
169
+ end
170
+ end
171
+
172
+
173
+ desc "prepare release. verify clean, update version, tag"
174
+ task :prepare => ['git:verify_clean', :update_version, :tag, :push_tags]
175
+
176
+ desc "release to rubyforge for old skool folks"
177
+ task :rubyforge => [:prepare, 'rubyforge:release']
178
+
179
+ desc "release to gemcutter for new skool kids"
180
+ task :gemcutter => [:prepare, 'gemcutter:release']
181
+
182
+ desc "one release to rule them all"
183
+ task :all => [:prepare, 'release:gemcutter', 'release:rubyforge']
184
+
185
+ end
186
+
187
+ desc "computes the current hash of the code. used to autodetect build changes"
188
+ task :hash_content do
189
+
190
+ require 'yaml'
191
+ require 'digest/md5'
192
+
193
+ ignore = IGNORE_CHANGES.map do |x|
194
+ if x =~ /^\^/
195
+ /^#{Regexp.escape(ROOT_PATH / x[1..-1])}/
196
+ else
197
+ /#{Regexp.escape(x)}/
198
+ end
199
+ end
200
+
201
+ # First, get the hashinfo if it exists. use this to decide if we need to
202
+ # rehash
203
+ hashinfo_path = ROOT_PATH / '.hashinfo.yml'
204
+ hash_date = 0
205
+ hash_digest = nil
206
+
207
+ if File.exist?(hashinfo_path)
208
+ yaml = YAML.load_file(hashinfo_path)
209
+ hash_date = yaml['date'] || yaml[:date] || hash_date
210
+ hash_digest = yaml['digest'] || yaml[:digest] || hash_digest
211
+ end
212
+
213
+ # paths to search
214
+ paths = Dir.glob(File.join(ROOT_PATH, '**', '*')).reject do |path|
215
+ File.directory?(path) || (ignore.find { |i| path =~ i })
216
+ end
217
+
218
+ cur_date = 0
219
+ paths.each do |path|
220
+ mtime = File.mtime(path)
221
+ mtime = mtime.nil? ? 0 : mtime.to_i
222
+ $stdout.puts "detected file change: #{path.gsub(ROOT_PATH,'')}" if mtime > hash_date
223
+ cur_date = mtime if mtime > cur_date
224
+ end
225
+
226
+ if hash_digest.nil? || (cur_date != hash_date)
227
+ digests = paths.map do |path|
228
+ Digest::SHA1.hexdigest(File.read(path))
229
+ end
230
+ digests.compact!
231
+ hash_digest = Digest::SHA1.hexdigest(digests.join)
232
+ end
233
+ hash_date = cur_date
234
+
235
+ # write cache
236
+ File.open(hashinfo_path, 'w+') do |f|
237
+ YAML.dump({ :date => hash_date, :digest => hash_digest }, f)
238
+ end
239
+
240
+ # finally set the hash
241
+ CONTENT_HASH = hash_digest
242
+ $stdout.puts "CONTENT_HASH = #{CONTENT_HASH}"
243
+ end
244
+
245
+ desc "updates the VERSION file, bumbing the build rev if the current commit has changed"
246
+ task :update_version => 'hash_content' do
247
+
248
+ path = ROOT_PATH / 'VERSION.yml'
249
+
250
+ require 'yaml'
251
+
252
+ # first, load the current yaml if possible
253
+ major = 1
254
+ minor = 0
255
+ build = 99
256
+ rev = '-0-'
257
+ dist = {}
258
+
259
+ if File.exist?(path)
260
+ yaml = YAML.load_file(path)
261
+ major = yaml['major'] || yaml[:major] || major
262
+ minor = yaml['minor'] || yaml[:minor] || minor
263
+ build = yaml['patch'] || yaml[:patch] || build
264
+ rev = yaml['digest'] || yaml[:digest] || rev
265
+ end
266
+
267
+ build += 1 if rev != CONTENT_HASH #increment if needed
268
+ rev = CONTENT_HASH
269
+
270
+ # Update distribution versions
271
+ DIST.each do |rel_path, ignored|
272
+ dist_path = ROOT_PATH / rel_path
273
+ if File.exists?(dist_path)
274
+ dist_rev = git(dist_path, "log HEAD^..HEAD")
275
+ dist_rev = dist_rev.split("\n").first.scan(/commit ([^\s]+)/)
276
+ dist_rev = ((dist_rev || []).first || []).first
277
+
278
+ if dist_rev.nil?
279
+ $stdout.puts " WARN: cannot find revision for #{rel_path}"
280
+ else
281
+ dist[rel_path] = dist_rev
282
+ end
283
+ end
284
+ end
285
+
286
+ $stdout.puts "write version #{[major, minor, build].join('.')} => #{path}"
287
+ File.open(path, 'w+') do |f|
288
+ YAML.dump({
289
+ :major => major,
290
+ :minor => minor,
291
+ :patch => build,
292
+ :digest => rev,
293
+ :dist => dist
294
+ }, f)
295
+ end
296
+
297
+ RELEASE_VERSION = "#{major}.#{minor}.#{build}"
298
+
299
+ end
300
+
301
+ desc "cleanup the pkg dir"
302
+ task :clean do
303
+ path = ROOT_PATH / 'pkg'
304
+ FileUtils.rm_r(path) if File.directory?(path)
305
+ `rm #{ROOT_PATH / '*.gem'}`
306
+ end
307
+
308
+ namespace :git do
309
+
310
+ desc "verifies there are no pending changes to commit to git"
311
+ task :verify_clean do
312
+ DIST.keys.push(PKG_NAME).each do |repo_name|
313
+ full_path = repo_name==PKG_NAME ? ROOT_PATH : (ROOT_PATH / repo_name)
314
+
315
+ result = git(full_path, 'status')
316
+
317
+ if !(result =~ /nothing to commit \(working directory clean\)/)
318
+ if (repo_name != PKG_NAME) ||
319
+ (!(result =~ /#\n#\tmodified: VERSION.yml\n#\n/))
320
+ $stderr.puts "\nFATAL: Cannot complete task: changes are still pending in the '#{repo_name}' repository."
321
+ $stderr.puts " Commit your changes to git to continue.\n\n"
322
+ exit(1)
323
+ end
324
+ end
325
+ end
326
+ end
327
+
328
+ desc "Collects the current SHA1 commit hash into COMMIT_ID"
329
+ task :collect_commit do
330
+ log = `git log HEAD^..HEAD`
331
+ COMMIT_ID = log.split("\n").first.match(/commit ([\w]+)/).to_a[1]
332
+ if COMMIT_ID.empty?
333
+ $stderr.puts "\nFATAL: Cannot discover current commit id"
334
+ exit(1)
335
+ else
336
+ $stdout.puts "COMMIT_ID = #{COMMIT_ID}"
337
+ end
338
+ end
339
+
340
+ end
341
+
342
+ # Write a new version everytime we generate
343
+ task 'gemspec:generate' => :update_version
344
+ task 'rubyforge:setup' => :update_version
345
+
346
+ Spec::Rake::SpecTask.new
347
+
348
+
349
+ # EOF