ninjs 0.13.7 → 0.13.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. data/.bundle/config +2 -0
  2. data/CNAME +1 -0
  3. data/Gemfile +13 -0
  4. data/Gemfile.lock +36 -0
  5. data/LICENSE +29 -0
  6. data/README.md +348 -0
  7. data/VERSION +1 -1
  8. data/bin/ninjs +211 -0
  9. data/lib/ninjs.rb +10 -0
  10. data/lib/ninjs/command.rb +88 -0
  11. data/lib/ninjs/configuration.rb +82 -0
  12. data/lib/ninjs/dependencies.rb +16 -0
  13. data/lib/ninjs/generator.rb +57 -0
  14. data/lib/ninjs/helpers.rb +17 -0
  15. data/lib/ninjs/manifest.rb +9 -0
  16. data/lib/ninjs/notification.rb +37 -0
  17. data/lib/ninjs/project.rb +214 -0
  18. data/ninjs.gemspec +294 -5
  19. data/repository/jquery/1.1.4.js +2508 -0
  20. data/repository/jquery/1.2.6.js +32 -0
  21. data/repository/jquery/1.3.2.js +19 -0
  22. data/repository/jquery/1.4.2.js +154 -0
  23. data/repository/jquery/1.4.3.js +166 -0
  24. data/repository/jquery/1.4.4.js +167 -0
  25. data/repository/jquery/1.5.js +16 -0
  26. data/repository/jquery/fancybox/1.3.1.js +1079 -0
  27. data/repository/jquery/fancybox/assets/1.3.1/css/fancybox.css +363 -0
  28. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/blank.gif +0 -0
  29. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_close.png +0 -0
  30. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_loading.png +0 -0
  31. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_left.png +0 -0
  32. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_right.png +0 -0
  33. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_e.png +0 -0
  34. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_n.png +0 -0
  35. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_ne.png +0 -0
  36. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_nw.png +0 -0
  37. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_s.png +0 -0
  38. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_se.png +0 -0
  39. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_sw.png +0 -0
  40. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_w.png +0 -0
  41. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_left.png +0 -0
  42. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_main.png +0 -0
  43. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_over.png +0 -0
  44. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_right.png +0 -0
  45. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-x.png +0 -0
  46. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-y.png +0 -0
  47. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox.png +0 -0
  48. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/jquery.easing-1.3.pack.js +72 -0
  49. data/repository/jquery/fancybox/latest.js +1 -0
  50. data/repository/jquery/latest.js +1 -0
  51. data/repository/jquery/mobile/1.0a3.js +123 -0
  52. data/repository/jquery/mobile/1.0a3/assets/css/jquery.mobile.css +1652 -0
  53. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/ajax-loader.png +0 -0
  54. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-check-off.png +0 -0
  55. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-check-on.png +0 -0
  56. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-radio-off.png +0 -0
  57. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-radio-on.png +0 -0
  58. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icon-search-black.png +0 -0
  59. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-18-black.png +0 -0
  60. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-18-white.png +0 -0
  61. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-36-black.png +0 -0
  62. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-36-white.png +0 -0
  63. data/repository/jquery/mobile/latest.js +1 -0
  64. data/repository/jquery/mousewheel/3.0.2.js +11 -0
  65. data/repository/jquery/mousewheel/latest.js +1 -0
  66. data/repository/jquery/ui/1.8.7.js +783 -0
  67. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.accordion.css +19 -0
  68. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.all.css +11 -0
  69. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.autocomplete.css +53 -0
  70. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.base.css +11 -0
  71. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.button.css +38 -0
  72. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.core.css +41 -0
  73. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.datepicker.css +68 -0
  74. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.dialog.css +21 -0
  75. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.progressbar.css +11 -0
  76. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.resizable.css +20 -0
  77. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.selectable.css +10 -0
  78. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.slider.css +24 -0
  79. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.tabs.css +18 -0
  80. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.theme.css +252 -0
  81. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  82. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  83. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  84. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  85. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_dadada_1x400.png +0 -0
  86. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  87. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  88. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  89. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_222222_256x240.png +0 -0
  90. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_2e83ff_256x240.png +0 -0
  91. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_454545_256x240.png +0 -0
  92. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_888888_256x240.png +0 -0
  93. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_cd0a0a_256x240.png +0 -0
  94. data/repository/jquery/ui/latest.js +1 -0
  95. data/repository/json2.js +482 -0
  96. data/repository/modernizr/1.5.js +28 -0
  97. data/repository/modernizr/latest.js +1 -0
  98. data/repository/ninjs/core/.core.pdoc.yaml +0 -0
  99. data/repository/ninjs/core/.existence.pdoc.yaml +12 -0
  100. data/repository/ninjs/core/.extend.pdoc.yaml +0 -0
  101. data/repository/ninjs/core/.nin.pdoc.yaml +0 -0
  102. data/repository/ninjs/core/application.js +47 -0
  103. data/repository/ninjs/core/existence.js +277 -0
  104. data/repository/ninjs/core/extend.js +77 -0
  105. data/repository/ninjs/core/module.js +135 -0
  106. data/repository/ninjs/core/nin.js +4 -0
  107. data/repository/ninjs/docs/Data/ClassHierarchy.nd +0 -0
  108. data/repository/ninjs/docs/Data/ConfigFileInfo.nd +0 -0
  109. data/repository/ninjs/docs/Data/FileInfo.nd +16 -0
  110. data/repository/ninjs/docs/Data/ImageFileInfo.nd +0 -0
  111. data/repository/ninjs/docs/Data/ImageReferenceTable.nd +0 -0
  112. data/repository/ninjs/docs/Data/IndexInfo.nd +0 -0
  113. data/repository/ninjs/docs/Data/PreviousMenuState.nd +0 -0
  114. data/repository/ninjs/docs/Data/PreviousSettings.nd +0 -0
  115. data/repository/ninjs/docs/Data/SymbolTable.nd +0 -0
  116. data/repository/ninjs/docs/Languages.txt +113 -0
  117. data/repository/ninjs/docs/Menu.txt +63 -0
  118. data/repository/ninjs/docs/Topics.txt +81 -0
  119. data/repository/ninjs/docs/files/core/application-js.html +44 -0
  120. data/repository/ninjs/docs/files/core/existence-js.html +60 -0
  121. data/repository/ninjs/docs/files/core/extend-js.html +55 -0
  122. data/repository/ninjs/docs/files/core/module-js.html +80 -0
  123. data/repository/ninjs/docs/files/core/nin-js.html +38 -0
  124. data/repository/ninjs/docs/index.html +1 -0
  125. data/repository/ninjs/docs/index/Classes.html +33 -0
  126. data/repository/ninjs/docs/index/Files.html +45 -0
  127. data/repository/ninjs/docs/index/Functions.html +65 -0
  128. data/repository/ninjs/docs/index/General.html +85 -0
  129. data/repository/ninjs/docs/index/Variables.html +45 -0
  130. data/repository/ninjs/docs/javascript/main.js +841 -0
  131. data/repository/ninjs/docs/javascript/prettify.js +1526 -0
  132. data/repository/ninjs/docs/javascript/searchdata.js +152 -0
  133. data/repository/ninjs/docs/search/ClassesN.html +20 -0
  134. data/repository/ninjs/docs/search/FilesA.html +20 -0
  135. data/repository/ninjs/docs/search/FilesE.html +20 -0
  136. data/repository/ninjs/docs/search/FilesM.html +20 -0
  137. data/repository/ninjs/docs/search/FilesN.html +20 -0
  138. data/repository/ninjs/docs/search/FunctionsA.html +20 -0
  139. data/repository/ninjs/docs/search/FunctionsC.html +20 -0
  140. data/repository/ninjs/docs/search/FunctionsE.html +20 -0
  141. data/repository/ninjs/docs/search/FunctionsI.html +20 -0
  142. data/repository/ninjs/docs/search/FunctionsM.html +20 -0
  143. data/repository/ninjs/docs/search/FunctionsR.html +20 -0
  144. data/repository/ninjs/docs/search/FunctionsS.html +20 -0
  145. data/repository/ninjs/docs/search/FunctionsSymbols.html +20 -0
  146. data/repository/ninjs/docs/search/FunctionsU.html +20 -0
  147. data/repository/ninjs/docs/search/GeneralA.html +20 -0
  148. data/repository/ninjs/docs/search/GeneralC.html +20 -0
  149. data/repository/ninjs/docs/search/GeneralD.html +20 -0
  150. data/repository/ninjs/docs/search/GeneralE.html +20 -0
  151. data/repository/ninjs/docs/search/GeneralF.html +20 -0
  152. data/repository/ninjs/docs/search/GeneralI.html +20 -0
  153. data/repository/ninjs/docs/search/GeneralM.html +20 -0
  154. data/repository/ninjs/docs/search/GeneralN.html +20 -0
  155. data/repository/ninjs/docs/search/GeneralR.html +20 -0
  156. data/repository/ninjs/docs/search/GeneralS.html +20 -0
  157. data/repository/ninjs/docs/search/GeneralSymbols.html +20 -0
  158. data/repository/ninjs/docs/search/GeneralT.html +20 -0
  159. data/repository/ninjs/docs/search/GeneralU.html +20 -0
  160. data/repository/ninjs/docs/search/GeneralV.html +20 -0
  161. data/repository/ninjs/docs/search/NoResults.html +15 -0
  162. data/repository/ninjs/docs/search/VariablesD.html +20 -0
  163. data/repository/ninjs/docs/search/VariablesN.html +20 -0
  164. data/repository/ninjs/docs/search/VariablesR.html +20 -0
  165. data/repository/ninjs/docs/search/VariablesT.html +20 -0
  166. data/repository/ninjs/docs/styles/main.css +828 -0
  167. data/repository/ninjs/extensions/jquery.elements.js +60 -0
  168. data/repository/ninjs/tests/index.html +21 -0
  169. data/repository/ninjs/tests/ninjs.test.js +188 -0
  170. data/repository/ninjs/tests/ninjs.utilities.test.js +137 -0
  171. data/repository/ninjs/tests/qunit/qunit.css +197 -0
  172. data/repository/ninjs/tests/qunit/qunit.js +1415 -0
  173. data/repository/ninjs/utilities/all.js +5 -0
  174. data/repository/ninjs/utilities/array.js +29 -0
  175. data/repository/ninjs/utilities/cookie.js +0 -0
  176. data/repository/ninjs/utilities/css.js +51 -0
  177. data/repository/ninjs/utilities/number.js +11 -0
  178. data/repository/ninjs/utilities/string.js +61 -0
  179. data/repository/nullconsole.js +7 -0
  180. data/repository/qunit/assets/css/qunit.css +196 -0
  181. data/repository/qunit/qunit.js +1374 -0
  182. data/repository/selectivizr/1.0.js +5 -0
  183. data/repository/selectivizr/latest.js +1 -0
  184. data/repository/syntaxhighlighter/all.js +11 -0
  185. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCore.css +226 -0
  186. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDefault.css +328 -0
  187. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDjango.css +331 -0
  188. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEclipse.css +339 -0
  189. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEmacs.css +324 -0
  190. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreFadeToGrey.css +328 -0
  191. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMDUltra.css +324 -0
  192. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMidnight.css +324 -0
  193. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreRDark.css +324 -0
  194. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDefault.css +117 -0
  195. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDjango.css +120 -0
  196. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEclipse.css +128 -0
  197. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEmacs.css +113 -0
  198. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeFadeToGrey.css +117 -0
  199. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMDUltra.css +113 -0
  200. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMidnight.css +113 -0
  201. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeRDark.css +113 -0
  202. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCore.scss +216 -0
  203. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDefault.scss +2 -0
  204. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDjango.scss +2 -0
  205. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEclipse.scss +2 -0
  206. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEmacs.scss +2 -0
  207. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreFadeToGrey.scss +2 -0
  208. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMDUltra.scss +2 -0
  209. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMidnight.scss +2 -0
  210. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreRDark.scss +2 -0
  211. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDefault.scss +7 -0
  212. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDjango.scss +36 -0
  213. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEclipse.scss +48 -0
  214. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEmacs.scss +32 -0
  215. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeFadeToGrey.scss +36 -0
  216. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMDUltra.scss +32 -0
  217. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMidnight.scss +32 -0
  218. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeRDark.scss +32 -0
  219. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_theme_template.scss +120 -0
  220. data/repository/syntaxhighlighter/shAutoloader.js +17 -0
  221. data/repository/syntaxhighlighter/shBrushAS3.js +59 -0
  222. data/repository/syntaxhighlighter/shBrushAppleScript.js +75 -0
  223. data/repository/syntaxhighlighter/shBrushBash.js +59 -0
  224. data/repository/syntaxhighlighter/shBrushCSharp.js +65 -0
  225. data/repository/syntaxhighlighter/shBrushColdFusion.js +100 -0
  226. data/repository/syntaxhighlighter/shBrushCpp.js +97 -0
  227. data/repository/syntaxhighlighter/shBrushCss.js +91 -0
  228. data/repository/syntaxhighlighter/shBrushDelphi.js +55 -0
  229. data/repository/syntaxhighlighter/shBrushDiff.js +41 -0
  230. data/repository/syntaxhighlighter/shBrushErlang.js +52 -0
  231. data/repository/syntaxhighlighter/shBrushGroovy.js +67 -0
  232. data/repository/syntaxhighlighter/shBrushJScript.js +52 -0
  233. data/repository/syntaxhighlighter/shBrushJava.js +57 -0
  234. data/repository/syntaxhighlighter/shBrushJavaFX.js +58 -0
  235. data/repository/syntaxhighlighter/shBrushPerl.js +72 -0
  236. data/repository/syntaxhighlighter/shBrushPhp.js +88 -0
  237. data/repository/syntaxhighlighter/shBrushPlain.js +33 -0
  238. data/repository/syntaxhighlighter/shBrushPowerShell.js +74 -0
  239. data/repository/syntaxhighlighter/shBrushPython.js +64 -0
  240. data/repository/syntaxhighlighter/shBrushRuby.js +55 -0
  241. data/repository/syntaxhighlighter/shBrushSass.js +94 -0
  242. data/repository/syntaxhighlighter/shBrushScala.js +51 -0
  243. data/repository/syntaxhighlighter/shBrushSql.js +66 -0
  244. data/repository/syntaxhighlighter/shBrushVb.js +56 -0
  245. data/repository/syntaxhighlighter/shBrushXml.js +69 -0
  246. data/repository/syntaxhighlighter/shCore.js +17 -0
  247. data/repository/syntaxhighlighter/shLegacy.js +17 -0
  248. data/spec/command_spec.rb +9 -0
  249. data/spec/configuration_spec.rb +70 -0
  250. data/spec/dependencies_spec.rb +27 -0
  251. data/spec/fixtures/autoload.js +3 -0
  252. data/spec/fixtures/changed.ninjs.conf +6 -0
  253. data/spec/fixtures/compressed.myapp.js +39 -0
  254. data/spec/fixtures/core.js +6 -0
  255. data/spec/fixtures/dependencies.js +3 -0
  256. data/spec/fixtures/foo.elements.js +3 -0
  257. data/spec/fixtures/foo.js +17 -0
  258. data/spec/fixtures/foo.model.js +3 -0
  259. data/spec/fixtures/foo.module.js +13 -0
  260. data/spec/fixtures/hello.elements.js +3 -0
  261. data/spec/fixtures/hello.js +17 -0
  262. data/spec/fixtures/hello.model.js +3 -0
  263. data/spec/fixtures/hello.module.js +13 -0
  264. data/spec/fixtures/myapp.initial.js +535 -0
  265. data/spec/fixtures/myapp.js +710 -0
  266. data/spec/fixtures/new.ninjs.conf +6 -0
  267. data/spec/fixtures/ninjs.conf +6 -0
  268. data/spec/generator_spec.rb +34 -0
  269. data/spec/helpers_spec.rb +11 -0
  270. data/spec/manifest_spec.rb +8 -0
  271. data/spec/ninjs_spec.rb +20 -0
  272. data/spec/notification_spec.rb +27 -0
  273. data/spec/project_spec.rb +239 -0
  274. data/spec/spec_helper.rb +29 -0
  275. metadata +294 -50
data/lib/ninjs.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Ninjs
2
+ BASE_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+ LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__)))
4
+ ROOT_DIR = Dir.getwd
5
+ VERSION = File.open("#{BASE_DIR}/VERSION").readlines.join("")
6
+ end
7
+
8
+ %w(dependencies configuration helpers manifest project notification generator command).each do |lib|
9
+ require "#{Ninjs::LIB_DIR}/ninjs/#{lib}"
10
+ end
@@ -0,0 +1,88 @@
1
+ module Ninjs
2
+ module Command
3
+ def watch
4
+ require "fssm"
5
+
6
+ project_path = File.expand_path(Dir.getwd)
7
+ raise "ninjs.conf was not located in #{project_path}" unless File.exists? "#{project_path}/ninjs.conf"
8
+
9
+ puts Ninjs::Notification.log "Ninjs are watching for changes. Press Ctrl-C to stop."
10
+ project = Ninjs::Project.new
11
+ project.update
12
+
13
+ watch_dirs = Ninjs::Manifest.directories.reject { |dir| dir.match(/application|tests/) }
14
+ watch_hash = Hash.new
15
+
16
+ watch_dirs.each do |dir|
17
+ watch_hash["#{project_path}/#{dir}"] = "**/*.js"
18
+ end
19
+
20
+ watch_hash[project_path] = "**/*.conf"
21
+ watch_hash["#{Ninjs::BASE_DIR}/repository"] = "**/*.js"
22
+
23
+ FSSM.monitor do
24
+
25
+ watch_hash.each do |dir, g|
26
+
27
+ path "#{dir}" do
28
+ glob g
29
+
30
+ update do |base, relative|
31
+ puts Ninjs::Notification.event "change detected in #{relative}"
32
+ project.update
33
+ end
34
+
35
+ create do |base, relative|
36
+ puts Ninjs::Notification.event "#{relative} created"
37
+ project.update
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ def create(config)
48
+ raise 'you must specify a project name: ninjs create ProjectName' if config[:name].nil?
49
+
50
+ project = Ninjs::Project.new config[:name]
51
+ project.root = config[:directory] unless config[:directory].nil?
52
+ puts project.root
53
+ project.create
54
+ end
55
+
56
+ def compile(force_compress = false)
57
+ project_path = Dir.getwd << '/'
58
+ raise "ninjs.conf was not located in #{project_path}" unless File.exists? "#{project_path}/ninjs.conf"
59
+ project = Ninjs::Project.new
60
+ project.config.output = 'compressed' if force_compress
61
+ project.update
62
+ end
63
+
64
+ def generate(config)
65
+ begin
66
+ conf_path = "#{Dir.getwd}/ninjs.conf"
67
+ raise "ninjs.conf was not located in #{conf_path}" unless File.exists? "#{conf_path}"
68
+ generator = Ninjs::Generator.new(config)
69
+ generator.generate
70
+ end
71
+ end
72
+
73
+ def update
74
+ project_path = Dir.getwd << '/'
75
+ raise "ninjs.conf was not located in #{project_path}" unless File.exists? "#{project_path}ninjs.conf"
76
+
77
+ project = Ninjs::Project.new
78
+ project.create_ninjs_lib_file
79
+ project.create_utility_lib_file
80
+ end
81
+
82
+ module_function :create,
83
+ :watch,
84
+ :compile,
85
+ :generate,
86
+ :update
87
+ end
88
+ end
@@ -0,0 +1,82 @@
1
+ module Ninjs
2
+ class Configuration
3
+
4
+ attr_reader :path,
5
+ :settings,
6
+ :name,
7
+ :dependencies,
8
+ :autoload,
9
+ :src_dir,
10
+ :dest_dir
11
+
12
+ attr_accessor :output,
13
+ :root,
14
+ :asset_root
15
+
16
+ def initialize(project_path)
17
+ @root = File.expand_path project_path
18
+ @settings = Hash.new
19
+ @asset_root = @root
20
+
21
+ setting(:name, 'application')
22
+ setting(:src_dir, 'modules')
23
+ setting(:dest_dir, 'application')
24
+ setting(:output, 'expanded')
25
+ setting(:dependencies, ['<jquery/latest>'])
26
+ setting(:autoload, ['../lib/utilities'])
27
+
28
+ optional_settings.each do |label, setting|
29
+ setting(label, setting)
30
+ end
31
+
32
+ read if File.exists? "#{@root}/ninjs.conf"
33
+ end
34
+
35
+ def optional_settings
36
+ @settings.reject do |key, value|
37
+ key.to_s.match /name|src_dir|dest_dir|output|dependencies|autoload/
38
+ end
39
+ end
40
+
41
+ def setting(name, value)
42
+ instance_variable_set("@#{name}", value)
43
+ @settings[name] = value
44
+ end
45
+
46
+ def write
47
+ File.open("#{@root}/ninjs.conf", "w+") do |conf_file|
48
+ conf_file << "name: #{@name}\n"
49
+ conf_file << "src_dir: #{@src_dir}\n"
50
+ conf_file << "dest_dir: #{@dest_dir}\n"
51
+ conf_file << "output: #{@output}\n"
52
+ conf_file << "dependencies: #{array_to_yml @dependencies}\n"
53
+ conf_file << "autoload: #{array_to_yml @autoload}\n"
54
+
55
+ optional_settings.each do |setting, value|
56
+ conf_file << "setting: #{value}\n"
57
+ end
58
+ end
59
+
60
+ puts Ninjs::Notification.notify "ninjs.conf created", :added
61
+ end
62
+
63
+ def read
64
+ config = YAML.load_file("#{@project_path}ninjs.conf")
65
+
66
+ @name = config['name']
67
+ @output = config['output']
68
+ @src_dir = config['src_dir']
69
+ @dest_dir = config['dest_dir']
70
+
71
+ @dependencies = config['dependencies'] || Array.new
72
+ @autoload = config['autoload'] || Array.new
73
+
74
+ @asset_root = config['asset_root'] unless config['ass'].nil?
75
+ end
76
+
77
+ def array_to_yml(array)
78
+ yml = array.empty? ? '[]' : %Q{['#{array.join("', '")}']}
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,16 @@
1
+ begin
2
+ require 'yaml'
3
+ require 'jsmin'
4
+ require 'tempfile'
5
+ require 'sprockets'
6
+ require 'fileutils'
7
+ require 'time'
8
+ rescue LoadError
9
+ require 'rubygems'
10
+ require 'yaml'
11
+ require 'jsmin'
12
+ require 'tempfile'
13
+ require 'sprockets'
14
+ require 'fileutils'
15
+ require 'time'
16
+ end
@@ -0,0 +1,57 @@
1
+ module Ninjs
2
+ class Generator
3
+
4
+ attr_writer :alias, :app_name
5
+
6
+ def initialize(config)
7
+ @type = config[:type]
8
+ @project = Ninjs::Project.new
9
+ @name = config[:name]
10
+ @module_name = config[:name].gsub(/^_/, '')
11
+ @alias = config[:alias].nil? ? false : true
12
+ @app_name = config[:alias] || @project.config.name
13
+ @dest = config[:dest] || @project.config.src_dir.is_a?(String) ? @project.config.src_dir : @project.config.src_dir.first
14
+ @dependencies = config[:dependencies] || { :elements => false, :model => false }
15
+ end
16
+
17
+ def generate
18
+ generate_module_file if @type === 'module'
19
+ generate_elements_file if @type === 'elements' || @dependencies[:elements]
20
+ generate_model_file if @type === 'model' || @dependencies[:model]
21
+ end
22
+
23
+ def generate_module_file
24
+ File.open "#{@project.root}/#{@dest}/#{@name}.module.js", "w" do |file|
25
+ file << "(function(#{@app_name if @alias}) {\n"
26
+ file << "\tvar self = #{@app_name}.add_module('#{@name}');\n\n"
27
+ file << %Q(\t//= require "../elements/#{@name.downcase}.elements"\n\n) if @dependencies[:elements] || @type === 'elements'
28
+ file << %Q(\t//= require "../models/#{@name.downcase}.model"\n\n) if @dependencies[:model] || @type === 'model'
29
+ file << "\t#{@app_name}.#{@module_name}.actions = function() {\n\n\t};\n\n"
30
+ file << "\t#{@app_name}.#{@module_name}.run();\n"
31
+ file << "})(#{@project.config.name});" if @alias
32
+ puts Ninjs::Notification.added "created #{@name.downcase}.module.js"
33
+ end unless File.exists? "#{@project.root}/#{@dest}/#{@name}.module.js"
34
+
35
+ self
36
+ end
37
+
38
+ def generate_elements_file
39
+ File.open("#{@project.root}/elements/#{@module_name}" + ".elements.js", "w") do |file|
40
+ file << "#{@app_name}.#{@module_name}.elements({\n\n});"
41
+ puts Ninjs::Notification.added "created #{@module_name}.elements.js"
42
+ end unless File.exists? "#{@project.root}/elements/#{@module_name}.elements.js"
43
+
44
+ self
45
+ end
46
+
47
+ def generate_model_file
48
+ File.open "#{@project.root}/models/#{@module_name}.model.js", "w" do |file|
49
+ file << "#{@app_name}.#{@module_name}.set_data({\n\t\n});"
50
+ puts Ninjs::Notification.added "created #{@module_name}.model.js"
51
+ end unless File.exists? "#{@project.root}/models/#{@module_name}.model.js"
52
+
53
+ self
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ module Ninjs
2
+ module Helpers
3
+
4
+ def get_filename(module_path)
5
+ module_path = module_path.split(/[\\\/]/).last
6
+ split = module_path.split(/[\.\-\s]/)
7
+ module_filename = String.new
8
+ split.each do |piece|
9
+ module_filename << piece unless piece.match(/^module$|^js$/i)
10
+ end
11
+ module_filename
12
+ end
13
+
14
+ module_function :get_filename
15
+
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Ninjs
2
+ module Manifest
3
+ def directories
4
+ %w(application elements lib models modules plugins tests tests/qunit)
5
+ end
6
+
7
+ module_function :directories
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ module Ninjs
2
+ class Notification
3
+ @@growl_support = false
4
+ @@indicators = {
5
+ :none => "",
6
+ :log => "\e[32m>>>\e[0m ",
7
+ :event => "\e[33m<<<\e[0m ",
8
+ :added => "\e[32m+++\e[0m ",
9
+ :error => "\e[0;31m!!!\e[0m "
10
+ }
11
+
12
+ def self.notify(message, style)
13
+ @@indicators[style] + message
14
+ end
15
+
16
+ def self.notice(message)
17
+ self.notify(message, :none)
18
+ end
19
+
20
+ def self.log(message)
21
+ self.notify(message, :log)
22
+ end
23
+
24
+ def self.event(message)
25
+ self.notify(message, :event)
26
+ end
27
+
28
+ def self.added(message)
29
+ self.notify(message, :added)
30
+ end
31
+
32
+ def self.error(message)
33
+ self.notify(message, :error)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,214 @@
1
+ module Ninjs
2
+ class Project
3
+ attr_reader :root,
4
+ :config,
5
+ :modules
6
+
7
+
8
+ def initialize(name = nil)
9
+ if name.nil?
10
+ raise ArgumentError, "Ninjs::Project.new(name): name is required without a configuration file" unless File.exists? 'ninjs.conf'
11
+ end
12
+
13
+ @root = File.expand_path Dir.getwd
14
+ @modules = Array.new
15
+ @config = Ninjs::Configuration.new @root
16
+ @config.setting :name, name unless name.nil?
17
+ end
18
+
19
+ def root=(path)
20
+ @root = File.expand_path path
21
+ @config.root = @root
22
+ @config.asset_root = @root
23
+ end
24
+
25
+ def create
26
+ puts Ninjs::Notification.notice "Creating the #{@config.name} project in #{@root}"
27
+ create_project_scaffold
28
+ @config.write
29
+ create_ninjs_lib_file
30
+ create_utility_lib_file
31
+ create_ninjs_application_file
32
+ import_test_files
33
+ end
34
+
35
+ def create_project_scaffold
36
+ Dir.mkdir "#{@root}" unless File.exists? "#{@root}"
37
+ Ninjs::Manifest.directories.each do |folder|
38
+ puts Ninjs::Notification.added "#{folder} created" unless File.exists? "#{@root}/#{folder}"
39
+ Dir.mkdir "#{@root}/#{folder}" unless File.exists? "#{@root}/#{folder}"
40
+ end
41
+ end
42
+
43
+ def create_ninjs_lib_file
44
+ operation = File.exists?("#{@root}/lib/nin.js") ? 'updated' : 'created'
45
+ ninjs_lib_secretary = Sprockets::Secretary.new(
46
+ :root => "#{Ninjs::BASE_DIR}",
47
+ :load_path => ["repository"],
48
+ :source_files => ["repository/ninjs/core/nin.js"]
49
+ )
50
+
51
+ ninjs_lib_secretary.concatenation.save_to "#{@root}/lib/nin.js"
52
+
53
+ puts Ninjs::Notification.added "lib/nin.js #{operation}"
54
+ end
55
+
56
+ def create_utility_lib_file
57
+ utility_lib_secretary = Sprockets::Secretary.new(
58
+ :root => "#{Ninjs::BASE_DIR}",
59
+ :load_path => ["repository"],
60
+ :source_files => ["repository/ninjs/utilities/all.js"]
61
+ )
62
+
63
+ utility_lib_secretary.concatenation.save_to "#{@root}/lib/utilities.js"
64
+
65
+ puts Ninjs::Notification.added "lib/utilities.js created"
66
+ end
67
+
68
+ def create_ninjs_application_file
69
+ File.open("#{@root}/application/#{@config.name.downcase}.js", "w+") do |file|
70
+ file << "//-- Ninjs #{Time.now.to_s} --//\n"
71
+ file << File.open("#{@root}/lib/nin.js", 'r').readlines.join('')
72
+ file << "\nvar #{@config.name} = new NinjsApplication();"
73
+ end
74
+ end
75
+
76
+ def import_test_files
77
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/index.html", "#{@root}/tests"
78
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/ninjs.test.js", "#{@root}/tests"
79
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/ninjs.utilities.test.js", "#{@root}/tests"
80
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/qunit/qunit.js", "#{@root}/tests/qunit"
81
+ FileUtils.cp "#{Ninjs::BASE_DIR}/repository/ninjs/tests/qunit/qunit.css", "#{@root}/tests/qunit"
82
+ end
83
+
84
+ def update
85
+ get_modules
86
+ compile_modules
87
+ update_application_file
88
+ compress_application if @config.output == 'compressed'
89
+ puts Ninjs::Notification.log "application updated" unless @errors
90
+ @errors = false
91
+ end
92
+
93
+ def get_directory_script_files
94
+ script_files = Array.new
95
+ Dir["#{@root}/**/*.js"].each do |file|
96
+ script_files << file unless file.match(/application\/|tests\//)
97
+ end
98
+ end
99
+
100
+ def get_modules
101
+ @modules = Array.new
102
+ if @config.src_dir.is_a? Array
103
+ @config.src_dir.each do |directory|
104
+ add_scripts_to_models File.expand_path "#{directory}"
105
+ end
106
+ else
107
+ add_scripts_to_models File.expand_path "#{@config.src_dir}"
108
+ end
109
+ end
110
+
111
+ def add_scripts_to_models(directory)
112
+ Dir["#{directory}/*.js"].each do |file|
113
+ module_filename = file.gsub(directory, '')
114
+ @modules << "#{directory}#{module_filename}" unless module_filename.match(/^_/)
115
+ end
116
+ end
117
+
118
+ def compile_modules
119
+ @modules.each do |module_file|
120
+ module_filename = Ninjs::Helpers.get_filename module_file
121
+ compile_module module_file, module_filename
122
+ end
123
+ end
124
+
125
+ def compile_module(module_file, module_name)
126
+ begin
127
+ ninjs_lib_secretary = Sprockets::Secretary.new(
128
+ :root => "#{Ninjs::BASE_DIR}",
129
+ :asset_root => @config.asset_root,
130
+ :load_path => ["repository"],
131
+ :source_files => ["#{module_file}"]
132
+ )
133
+
134
+ module_file = ninjs_lib_secretary.concatenation
135
+ message = File.exists?("#{@root}/#{@config.dest_dir}/#{module_name}.js") ? "\e[32m>>>\e[0m #{@config.dest_dir}/#{module_name}.js updated" : "\e[32m>>>\e[0m #{@config.dest_dir}/#{module_name}.js created"
136
+ module_file.save_to "#{@root}/#{@config.dest_dir}/#{module_name}.js"
137
+ ninjs_lib_secretary.install_assets
138
+
139
+ rescue Exception => error
140
+ @errors = true
141
+ puts Ninjs::Notification.error "Sprockets error: #{error.message}"
142
+ end
143
+ end
144
+
145
+ def update_application_file
146
+ application_file = "#{@root}/#{@config.dest_dir}/#{@config.name.downcase}.js"
147
+
148
+ File.open(application_file, "w+") do |file|
149
+ write_dependencies(file)
150
+ write_core(file)
151
+ write_autoload(file)
152
+ end
153
+
154
+ compile_application_file application_file
155
+ end
156
+
157
+ def write_dependencies(file)
158
+ @config.dependencies.each do |dependency|
159
+ file << "/*---------- #{dependency} ----------*/"
160
+ file << "\n//= require #{dependency}\n\n" if dependency.match(/^\<.+\>$/)
161
+ file << "\n//= require \"#{dependency}\"\n\n" if dependency.match(/^[^\<].+|[^\>]$/)
162
+ end
163
+ end
164
+
165
+ def write_core(file)
166
+ file << "/*---------- Ninjs core ../lib/nin.js ----------*/\n"
167
+ file << "//= require \"../lib/nin.js\"\n\n"
168
+ file << "\nvar #{@config.name} = new NinjsApplication();\n\n"
169
+ end
170
+
171
+ def write_autoload(file)
172
+ @config.autoload.each do |auto_file|
173
+ file << "/*---------- Ninjs autoload #{auto_file} ----------*/"
174
+ file << "\n//= require #{auto_file}\n\n" if auto_file.match(/^\<.+\>$/)
175
+ file << "\n//= require \"#{auto_file}\"\n\n" if auto_file.match(/^[^\<].+|[^\>]$/)
176
+ end
177
+ end
178
+
179
+ def compile_application_file(file)
180
+ begin
181
+ ninjs_lib_secretary = Sprockets::Secretary.new(
182
+ :root => "#{Ninjs::BASE_DIR}",
183
+ :asset_root => @config.asset_root,
184
+ :load_path => ["repository"],
185
+ :source_files => ["#{file}"]
186
+ )
187
+
188
+ application_file = ninjs_lib_secretary.concatenation
189
+ ninjs_lib_secretary.install_assets
190
+ application_file.save_to "#{file}"
191
+ rescue Exception => error
192
+ @errors = true
193
+ puts Ninjs::Notification.error "Sprockets error: #{error.message}"
194
+ end
195
+ end
196
+
197
+ def compress_application
198
+ app_root = File.expand_path "#{@config.dest_dir}"
199
+ modules = Dir.entries(app_root)
200
+ modules.reject! { |file| file =~ /^\./ }
201
+
202
+ modules.each do |module_file|
203
+ full_path = "#{app_root}/#{module_file}"
204
+ uncompressed = File.open(full_path, "r").readlines.join('')
205
+ File.open(full_path, "w+") do |module_file|
206
+ module_file << JSMin.minify(uncompressed)
207
+ end
208
+ end
209
+ end
210
+
211
+ end
212
+ # class Project
213
+ end
214
+ #module Ninjs