rsence 2.0.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. data/INSTALL.rdoc +295 -0
  2. data/LICENSE +622 -0
  3. data/README.rdoc +24 -0
  4. data/VERSION +1 -0
  5. data/bin/build_client.rb +254 -0
  6. data/bin/help +6 -0
  7. data/bin/launch.rb +120 -0
  8. data/bin/rdoc.sh +2 -0
  9. data/bin/restart +6 -0
  10. data/bin/rsence +120 -0
  11. data/bin/run +6 -0
  12. data/bin/run.rb +6 -0
  13. data/bin/save +6 -0
  14. data/bin/start +6 -0
  15. data/bin/status +6 -0
  16. data/bin/stop +6 -0
  17. data/conf/config.ru +5 -0
  18. data/conf/default_conf.yaml +337 -0
  19. data/conf/default_strings.yaml +77 -0
  20. data/conf/local_conf.yaml +14 -0
  21. data/conf/unicorn.conf +78 -0
  22. data/js/comm/comm/autosync/autosync.js +18 -0
  23. data/js/comm/comm/autosync/js.inc +0 -0
  24. data/js/comm/comm/comm.js +195 -0
  25. data/js/comm/comm/js.inc +0 -0
  26. data/js/comm/comm/queue/js.inc +0 -0
  27. data/js/comm/comm/queue/queue.js +183 -0
  28. data/js/comm/comm/session/js.inc +0 -0
  29. data/js/comm/comm/session/session.js +51 -0
  30. data/js/comm/comm/sessionwatcher/js.inc +0 -0
  31. data/js/comm/comm/sessionwatcher/sessionwatcher.js +43 -0
  32. data/js/comm/comm/transporter/js.inc +0 -0
  33. data/js/comm/comm/transporter/transporter.js +257 -0
  34. data/js/comm/comm/urlresponder/js.inc +0 -0
  35. data/js/comm/comm/urlresponder/urlresponder.js +148 -0
  36. data/js/comm/comm/values/js.inc +0 -0
  37. data/js/comm/comm/values/values.js +432 -0
  38. data/js/comm/jsloader/js.inc +0 -0
  39. data/js/comm/jsloader/jsloader.js +114 -0
  40. data/js/comm/reloadapp/js.inc +0 -0
  41. data/js/comm/reloadapp/reloadapp.js +150 -0
  42. data/js/comm/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
  43. data/js/comm/reloadapp/themes/default/reloadapp_warning.png +0 -0
  44. data/js/comm/sha/js.inc +0 -0
  45. data/js/comm/sha/sha.js +432 -0
  46. data/js/comm/values/value/js.inc +0 -0
  47. data/js/comm/values/value/value.js +182 -0
  48. data/js/comm/values/valuematrix/js.inc +0 -0
  49. data/js/comm/values/valuematrix/valuematrix.js +138 -0
  50. data/js/controls/button/button.js +57 -0
  51. data/js/controls/button/js.inc +0 -0
  52. data/js/controls/button/themes/bright/button.css +89 -0
  53. data/js/controls/button/themes/bright/button.html +7 -0
  54. data/js/controls/button/themes/bright/button_parts1-ie6.gif +0 -0
  55. data/js/controls/button/themes/bright/button_parts1.png +0 -0
  56. data/js/controls/button/themes/default/button.css +89 -0
  57. data/js/controls/button/themes/default/button.html +7 -0
  58. data/js/controls/button/themes/default/button_parts1-ie6.gif +0 -0
  59. data/js/controls/button/themes/default/button_parts1.png +0 -0
  60. data/js/controls/checkbox/checkbox.js +47 -0
  61. data/js/controls/checkbox/js.inc +0 -0
  62. data/js/controls/checkbox/themes/default/checkbox.css +69 -0
  63. data/js/controls/checkbox/themes/default/checkbox.html +5 -0
  64. data/js/controls/checkbox/themes/default/checkbox_parts1-ie6.gif +0 -0
  65. data/js/controls/checkbox/themes/default/checkbox_parts1.png +0 -0
  66. data/js/controls/datetime/calendar/calendar.js +197 -0
  67. data/js/controls/datetime/calendar/js.inc +0 -0
  68. data/js/controls/datetime/calendar/themes/default/calendar.css +108 -0
  69. data/js/controls/datetime/calendar/themes/default/calendar.html +9 -0
  70. data/js/controls/datetime/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
  71. data/js/controls/datetime/calendar/themes/default/calendar_arrows.png +0 -0
  72. data/js/controls/datetime/datetimevalue/datetimevalue.js +246 -0
  73. data/js/controls/datetime/datetimevalue/js.inc +0 -0
  74. data/js/controls/datetime/timesheet/js.inc +0 -0
  75. data/js/controls/datetime/timesheet/themes/default/timesheet.css +30 -0
  76. data/js/controls/datetime/timesheet/themes/default/timesheet.html +2 -0
  77. data/js/controls/datetime/timesheet/timesheet.js +182 -0
  78. data/js/controls/datetime/timesheet_item/js.inc +0 -0
  79. data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.css +42 -0
  80. data/js/controls/datetime/timesheet_item/themes/default/timesheet_item.html +8 -0
  81. data/js/controls/datetime/timesheet_item/timesheet_item.js +247 -0
  82. data/js/controls/datetime/timesheet_item_edit/js.inc +0 -0
  83. data/js/controls/datetime/timesheet_item_edit/timesheet_item_edit.js +274 -0
  84. data/js/controls/dialogs/alert_sheet/alert_sheet.js +62 -0
  85. data/js/controls/dialogs/alert_sheet/js.inc +0 -0
  86. data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +36 -0
  87. data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
  88. data/js/controls/dialogs/sheet/js.inc +0 -0
  89. data/js/controls/dialogs/sheet/sheet.js +83 -0
  90. data/js/controls/dialogs/sheet/themes/default/sheet.css +64 -0
  91. data/js/controls/dialogs/sheet/themes/default/sheet.html +14 -0
  92. data/js/controls/dialogs/sheet/themes/default/sheet_bg-ie6.gif +0 -0
  93. data/js/controls/dialogs/sheet/themes/default/sheet_bg.png +0 -0
  94. data/js/controls/dialogs/sheet/themes/default/sheet_dim-ie6.gif +0 -0
  95. data/js/controls/dialogs/sheet/themes/default/sheet_dim.png +0 -0
  96. data/js/controls/dialogs/sheet/themes/default/sheet_parts1-ie6.gif +0 -0
  97. data/js/controls/dialogs/sheet/themes/default/sheet_parts1.png +0 -0
  98. data/js/controls/dialogs/sheet/themes/default/sheet_parts2-ie6.gif +0 -0
  99. data/js/controls/dialogs/sheet/themes/default/sheet_parts2.png +0 -0
  100. data/js/controls/dialogs/sheet/themes/default/sheet_warning-ie6.gif +0 -0
  101. data/js/controls/dialogs/sheet/themes/default/sheet_warning.png +0 -0
  102. data/js/controls/imageview/imageview.js +108 -0
  103. data/js/controls/imageview/js.inc +0 -0
  104. data/js/controls/imageview/themes/default/blank.gif +0 -0
  105. data/js/controls/lists/checkboxlist/checkboxlist.js +170 -0
  106. data/js/controls/lists/checkboxlist/js.inc +0 -0
  107. data/js/controls/lists/listitems/js.inc +0 -0
  108. data/js/controls/lists/listitems/listitems.js +65 -0
  109. data/js/controls/lists/radiobuttonlist/js.inc +0 -0
  110. data/js/controls/lists/radiobuttonlist/radiobuttonlist.js +126 -0
  111. data/js/controls/passwordcontrol/js.inc +0 -0
  112. data/js/controls/passwordcontrol/passwordcontrol.js +22 -0
  113. data/js/controls/passwordcontrol/themes/default/passwordcontrol.css +0 -0
  114. data/js/controls/passwordcontrol/themes/default/passwordcontrol.html +18 -0
  115. data/js/controls/progress/progressbar/js.inc +0 -0
  116. data/js/controls/progress/progressbar/progressbar.js +36 -0
  117. data/js/controls/progress/progressbar/themes/default/progressbar.css +16 -0
  118. data/js/controls/progress/progressbar/themes/default/progressbar.html +2 -0
  119. data/js/controls/progress/progressindicator/js.inc +0 -0
  120. data/js/controls/progress/progressindicator/progressindicator.js +43 -0
  121. data/js/controls/radiobutton/js.inc +0 -0
  122. data/js/controls/radiobutton/radiobutton.js +41 -0
  123. data/js/controls/radiobutton/themes/default/radiobutton.css +69 -0
  124. data/js/controls/radiobutton/themes/default/radiobutton.html +5 -0
  125. data/js/controls/radiobutton/themes/default/radiobutton_parts1-ie6.gif +0 -0
  126. data/js/controls/radiobutton/themes/default/radiobutton_parts1.png +0 -0
  127. data/js/controls/sliders/slider/js.inc +0 -0
  128. data/js/controls/sliders/slider/slider.js +356 -0
  129. data/js/controls/sliders/slider/themes/default/hslider_tracks-ie6.gif +0 -0
  130. data/js/controls/sliders/slider/themes/default/hslider_tracks.png +0 -0
  131. data/js/controls/sliders/slider/themes/default/slider.css +108 -0
  132. data/js/controls/sliders/slider/themes/default/slider.html +5 -0
  133. data/js/controls/sliders/slider/themes/default/slider_thumbs-ie6.gif +0 -0
  134. data/js/controls/sliders/slider/themes/default/slider_thumbs.png +0 -0
  135. data/js/controls/sliders/vslider/js.inc +0 -0
  136. data/js/controls/sliders/vslider/themes/default/vslider.css +52 -0
  137. data/js/controls/sliders/vslider/themes/default/vslider.html +5 -0
  138. data/js/controls/sliders/vslider/themes/default/vslider_tracks-ie6.gif +0 -0
  139. data/js/controls/sliders/vslider/themes/default/vslider_tracks.png +0 -0
  140. data/js/controls/sliders/vslider/vslider.js +40 -0
  141. data/js/controls/stepper/js.inc +0 -0
  142. data/js/controls/stepper/stepper.js +212 -0
  143. data/js/controls/stepper/themes/default/stepper-ie6.gif +0 -0
  144. data/js/controls/stepper/themes/default/stepper.css +14 -0
  145. data/js/controls/stepper/themes/default/stepper.html +2 -0
  146. data/js/controls/stepper/themes/default/stepper.png +0 -0
  147. data/js/controls/stringview/js.inc +0 -0
  148. data/js/controls/stringview/stringview.js +49 -0
  149. data/js/controls/stringview/themes/default/stringview.css +8 -0
  150. data/js/controls/stringview/themes/default/stringview.html +1 -0
  151. data/js/controls/tab/js.inc +0 -0
  152. data/js/controls/tab/tab.js +276 -0
  153. data/js/controls/tab/themes/bright/tab.css +76 -0
  154. data/js/controls/tab/themes/bright/tab.html +6 -0
  155. data/js/controls/tab/themes/bright/tab_bg_color-ie6.gif +0 -0
  156. data/js/controls/tab/themes/bright/tab_bg_color.png +0 -0
  157. data/js/controls/tab/themes/bright/tab_border_pattern-ie6.gif +0 -0
  158. data/js/controls/tab/themes/bright/tab_border_pattern.png +0 -0
  159. data/js/controls/tab/themes/bright/tab_parts1-ie6.gif +0 -0
  160. data/js/controls/tab/themes/bright/tab_parts1.png +0 -0
  161. data/js/controls/tab/themes/default/tab.css +77 -0
  162. data/js/controls/tab/themes/default/tab.html +6 -0
  163. data/js/controls/tab/themes/default/tab_bg_color-ie6.gif +0 -0
  164. data/js/controls/tab/themes/default/tab_bg_color.png +0 -0
  165. data/js/controls/tab/themes/default/tab_border_pattern-ie6.gif +0 -0
  166. data/js/controls/tab/themes/default/tab_border_pattern.png +0 -0
  167. data/js/controls/tab/themes/default/tab_parts1-ie6.gif +0 -0
  168. data/js/controls/tab/themes/default/tab_parts1.png +0 -0
  169. data/js/controls/textarea/js.inc +0 -0
  170. data/js/controls/textarea/textarea.js +23 -0
  171. data/js/controls/textarea/themes/default/textarea.css +21 -0
  172. data/js/controls/textarea/themes/default/textarea.html +18 -0
  173. data/js/controls/textcontrol/js.inc +0 -0
  174. data/js/controls/textcontrol/textcontrol.js +372 -0
  175. data/js/controls/textcontrol/themes/default/textcontrol.css +107 -0
  176. data/js/controls/textcontrol/themes/default/textcontrol.html +18 -0
  177. data/js/controls/textcontrol/themes/default/textcontrol_parts1-ie6.gif +0 -0
  178. data/js/controls/textcontrol/themes/default/textcontrol_parts1.png +0 -0
  179. data/js/controls/textcontrol/themes/default/textcontrol_parts2-ie6.gif +0 -0
  180. data/js/controls/textcontrol/themes/default/textcontrol_parts2.png +0 -0
  181. data/js/controls/textcontrol/themes/default/textcontrol_parts3-ie6.gif +0 -0
  182. data/js/controls/textcontrol/themes/default/textcontrol_parts3.png +0 -0
  183. data/js/controls/uploader/js.inc +0 -0
  184. data/js/controls/uploader/themes/default/upload_progress.gif +0 -0
  185. data/js/controls/uploader/themes/default/uploader.css +108 -0
  186. data/js/controls/uploader/themes/default/uploader.html +27 -0
  187. data/js/controls/uploader/uploader.js +153 -0
  188. data/js/controls/validatorview/js.inc +0 -0
  189. data/js/controls/validatorview/themes/default/validator-ie6.gif +0 -0
  190. data/js/controls/validatorview/themes/default/validator.png +0 -0
  191. data/js/controls/validatorview/themes/default/validatorview.css +0 -0
  192. data/js/controls/validatorview/themes/default/validatorview.html +0 -0
  193. data/js/controls/validatorview/validatorview.js +55 -0
  194. data/js/controls/window/js.inc +0 -0
  195. data/js/controls/window/themes/default/window.css +219 -0
  196. data/js/controls/window/themes/default/window.html +17 -0
  197. data/js/controls/window/themes/default/window_bg_active-ie6.gif +0 -0
  198. data/js/controls/window/themes/default/window_bg_active.png +0 -0
  199. data/js/controls/window/themes/default/window_bg_inactive-ie6.gif +0 -0
  200. data/js/controls/window/themes/default/window_bg_inactive.png +0 -0
  201. data/js/controls/window/themes/default/window_buttons-ie6.gif +0 -0
  202. data/js/controls/window/themes/default/window_buttons.png +0 -0
  203. data/js/controls/window/themes/default/window_parts1-ie6.gif +0 -0
  204. data/js/controls/window/themes/default/window_parts1.png +0 -0
  205. data/js/controls/window/themes/default/window_parts2-ie6.gif +0 -0
  206. data/js/controls/window/themes/default/window_parts2.png +0 -0
  207. data/js/controls/window/window.js +284 -0
  208. data/js/core/class/class.js +317 -0
  209. data/js/core/class/js.inc +0 -0
  210. data/js/core/elem/elem.js +1376 -0
  211. data/js/core/elem/js.inc +0 -0
  212. data/js/core/event/event.js +1021 -0
  213. data/js/core/event/js.inc +0 -0
  214. data/js/core/iefix/ie_css_element.htc +5 -0
  215. data/js/core/iefix/ie_css_style.htc +5 -0
  216. data/js/core/iefix/iefix.js +359 -0
  217. data/js/core/iefix/js.inc +0 -0
  218. data/js/debugg/debugg.js +43 -0
  219. data/js/debugg/js.inc +0 -0
  220. data/js/foundation/application/application.js +209 -0
  221. data/js/foundation/application/js.inc +0 -0
  222. data/js/foundation/control/control.js +342 -0
  223. data/js/foundation/control/controldefaults/controldefaults.js +59 -0
  224. data/js/foundation/control/controldefaults/js.inc +0 -0
  225. data/js/foundation/control/dummyvalue/dummyvalue.js +50 -0
  226. data/js/foundation/control/dummyvalue/js.inc +0 -0
  227. data/js/foundation/control/dyncontrol/dyncontrol.js +494 -0
  228. data/js/foundation/control/dyncontrol/js.inc +0 -0
  229. data/js/foundation/control/dyncontrol/themes/default/dyncontrol.css +0 -0
  230. data/js/foundation/control/dyncontrol/themes/default/dyncontrol.html +0 -0
  231. data/js/foundation/control/eventresponder/eventresponder.js +713 -0
  232. data/js/foundation/control/eventresponder/js.inc +0 -0
  233. data/js/foundation/control/js.inc +0 -0
  234. data/js/foundation/control/valueresponder/js.inc +0 -0
  235. data/js/foundation/control/valueresponder/valueresponder.js +77 -0
  236. data/js/foundation/geom/point/js.inc +0 -0
  237. data/js/foundation/geom/point/point.js +202 -0
  238. data/js/foundation/geom/rect/js.inc +0 -0
  239. data/js/foundation/geom/rect/rect.js +610 -0
  240. data/js/foundation/json_renderer/js.inc +0 -0
  241. data/js/foundation/json_renderer/json_renderer.js +231 -0
  242. data/js/foundation/system/js.inc +0 -0
  243. data/js/foundation/system/system.js +369 -0
  244. data/js/foundation/thememanager/js.inc +0 -0
  245. data/js/foundation/thememanager/thememanager.js +387 -0
  246. data/js/foundation/view/js.inc +0 -0
  247. data/js/foundation/view/markupview/js.inc +0 -0
  248. data/js/foundation/view/markupview/markupview.js +113 -0
  249. data/js/foundation/view/morphanimation/js.inc +0 -0
  250. data/js/foundation/view/morphanimation/morphanimation.js +236 -0
  251. data/js/foundation/view/view.js +1804 -0
  252. data/js/foundation/view/viewdefaults/js.inc +0 -0
  253. data/js/foundation/view/viewdefaults/viewdefaults.js +25 -0
  254. data/js/views/centerview/centerview.js +45 -0
  255. data/js/views/centerview/js.inc +0 -0
  256. data/js/views/inlineview/inlineview.js +14 -0
  257. data/js/views/inlineview/js.inc +0 -0
  258. data/js/views/scrollview/js.inc +0 -0
  259. data/js/views/scrollview/scrollview.js +39 -0
  260. data/lib/conf/default.rb +220 -0
  261. data/lib/conf/wizard.rb +303 -0
  262. data/lib/daemon/daemon.rb +293 -0
  263. data/lib/http/broker.rb +102 -0
  264. data/lib/http/rackup.rb +88 -0
  265. data/lib/http/request.rb +69 -0
  266. data/lib/http/response.rb +63 -0
  267. data/lib/plugins/gui_plugin.rb +129 -0
  268. data/lib/plugins/guiparser.rb +114 -0
  269. data/lib/plugins/plugin.rb +652 -0
  270. data/lib/plugins/plugin_plugins.rb +47 -0
  271. data/lib/plugins/plugin_sqlite_db.rb +72 -0
  272. data/lib/plugins/plugin_util.rb +96 -0
  273. data/lib/plugins/pluginmanager.rb +517 -0
  274. data/lib/plugins/servlet.rb +69 -0
  275. data/lib/session/msg.rb +291 -0
  276. data/lib/session/sessionmanager.rb +491 -0
  277. data/lib/session/sessionstorage.rb +314 -0
  278. data/lib/transporter/transporter.rb +254 -0
  279. data/lib/util/gzstring.rb +5 -0
  280. data/lib/values/hvalue.rb +323 -0
  281. data/lib/values/valuemanager.rb +152 -0
  282. data/plugins/client_pkg/client_pkg.rb +186 -0
  283. data/plugins/client_pkg/info.yaml +25 -0
  284. data/plugins/client_pkg/lib/client_pkg_build.rb +569 -0
  285. data/plugins/client_pkg/lib/client_pkg_cache.rb +50 -0
  286. data/plugins/client_pkg/lib/client_pkg_serve.rb +210 -0
  287. data/plugins/client_pkg/log/build_log +0 -0
  288. data/plugins/index_html/img/loading.gif +0 -0
  289. data/plugins/index_html/img/riassence.gif +0 -0
  290. data/plugins/index_html/index_html.rb +150 -0
  291. data/plugins/index_html/tmpl/index.html +22 -0
  292. data/plugins/index_html/tmpl/startup_index.html +29 -0
  293. data/plugins/legacy/disabled +0 -0
  294. data/plugins/legacy/disabled- +0 -0
  295. data/plugins/legacy/info.yaml +22 -0
  296. data/plugins/legacy/legacy.rb +15 -0
  297. data/plugins/main/js/riassence_ns.js +87 -0
  298. data/plugins/main/main.rb +234 -0
  299. data/plugins/main/values.yaml +8 -0
  300. data/plugins/ticketservices/lib/common.rb +300 -0
  301. data/plugins/ticketservices/lib/favicon.rb +38 -0
  302. data/plugins/ticketservices/lib/file.rb +58 -0
  303. data/plugins/ticketservices/lib/img.rb +50 -0
  304. data/plugins/ticketservices/lib/objblob.rb +66 -0
  305. data/plugins/ticketservices/lib/rsrc.rb +34 -0
  306. data/plugins/ticketservices/lib/upload.rb +206 -0
  307. data/plugins/ticketservices/ticketservices.rb +268 -0
  308. data/var/db/.git_include +0 -0
  309. data/var/log/.git_include +0 -0
  310. data/var/run/.git_include +0 -0
  311. metadata +390 -0
@@ -0,0 +1,186 @@
1
+ ## Riassence Framework
2
+ # Copyright 2007 Riassence Inc.
3
+ # http://riassence.com/
4
+ #
5
+ # You should have received a copy of the GNU General Public License along
6
+ # with this software package. If not, contact licensing@riassence.com
7
+ ##
8
+
9
+ # puts "Module.nesting: #{Module.nesting.inspect}"
10
+ # puts "Options: #{Options.inspect}"
11
+ # def method_missing( *foo )
12
+ # puts "variable missing: #{foo.inspect}"
13
+ # end
14
+ # BUNDLE_PATH = self.bundle_path
15
+ # puts "singleton_methods: #{singleton_methods.inspect}"
16
+
17
+ class ClientPkg < Servlet
18
+
19
+ # def accessor( *args )
20
+ # puts "accessor args: #{args.inspect}"
21
+ # end
22
+
23
+ # puts "----"
24
+ # puts bundle_path
25
+ #
26
+ # puts self.methods.inspect
27
+ #
28
+ # def class_variable_get( *foo )
29
+ # puts "*"
30
+ # puts foo.inspect
31
+ # end
32
+ # puts "="
33
+ #
34
+ # def self.method_missing( method_name, *args, &block )
35
+ # if method_name == :bundle_path
36
+ # return Module.nesting[1].bundle_path
37
+ # elsif method_name == :bundle_name
38
+ # return Module.nesting[1].bundle_name
39
+ # elsif method_name == :bundle_info
40
+ # return Module.nesting[1].bundle_info
41
+ # elsif method_name == :plugin_manager
42
+ # return Module.nesting[1].plugin_manager
43
+ # end
44
+ # end
45
+
46
+ # the library path of this plugin
47
+ lib_path = File.join( @@bundle_path, 'lib' )
48
+
49
+ # The ClientPkgCache class:
50
+ require File.join(lib_path,'client_pkg_cache')
51
+
52
+ # The ClientPkgServe module:
53
+ require File.join(lib_path,'client_pkg_serve')
54
+ include ClientPkgServe
55
+
56
+ # The ClientPkgBuild class:
57
+ require File.join(lib_path,'client_pkg_build')
58
+
59
+ class BuildLogger
60
+ def initialize( log_path )
61
+ @last_time = Time.now
62
+ @log_path = log_path
63
+ @log_file = nil
64
+ end
65
+ def log( str )
66
+ puts str
67
+ return
68
+ if @last_time < Time.now - 30
69
+ @last_time = Time.now
70
+ @log_file.write( %{--- #{@last_time.strftime("%Y-%m-%d %H:%M:%S")} ---\n} )
71
+ end
72
+ @log_file.write( "#{str}\n" )
73
+ @log_file.flush
74
+ end
75
+ def open
76
+ return if @log_file
77
+ @log_file = File.open( @log_path, 'a' )
78
+ end
79
+ def close
80
+ @log_file.close
81
+ @log_file = nil
82
+ end
83
+ end
84
+
85
+ def rebuild_client
86
+ until not @build_busy
87
+ puts "build busy, sleeping.."
88
+ sleep 0.5
89
+ end
90
+ @build_busy = true
91
+ @last_change = Time.now.to_i
92
+ @client_build.setup_dirs
93
+ @client_build.run
94
+ @client_cache.set_cache( @client_build.js, @client_build.gz, @client_build.themes )
95
+ @build_busy = false
96
+ end
97
+
98
+ def open
99
+ if not @thr and $DEBUG_MODE
100
+ @thr = Thread.new do
101
+ Thread.pass
102
+ while true
103
+ begin
104
+ if @client_build.bundle_changes( @last_change )
105
+ rebuild_client
106
+ puts "Autobuilt."
107
+ if ARGV.include?('-say')
108
+ Thread.new do
109
+ Thread.pass
110
+ system('say "Autobuilt."')
111
+ end
112
+ end
113
+ end
114
+ rescue => e
115
+ warn e.inspect
116
+ end
117
+ sleep 3
118
+ end
119
+ end
120
+ end
121
+
122
+ end
123
+
124
+ def add_src_dir( src_dir ); @client_build.add_src_dir( src_dir ); end
125
+ def add_src_dirs( src_dirs ); @client_build.add_src_dirs( src_dirs ); end
126
+ def del_src_dir( src_dir ); @client_build.del_src_dir( src_dir ); end
127
+ def del_src_dirs( src_dirs ); @client_build.del_src_dirs( src_dirs ); end
128
+
129
+ def add_theme( theme_name ); @client_build.add_theme( theme_name ); end
130
+ def add_themes( theme_names ); @client_build.add_themes( theme_names ); end
131
+ def del_theme( theme_name ); @client_build.del_theme( theme_name ); end
132
+ def del_themes( theme_names ); @client_build.del_themes( theme_names ); end
133
+
134
+ def add_package( pkg_name, pkg_items ); @client_build.add_package( pkg_name, pkg_items ); end
135
+ def add_packages( packages ); @client_build.add_packages( packages ); end
136
+ def del_package( pkg_name ); @client_build.del_package( pkg_name ); end
137
+ def del_packages( packages ); @client_build.del_packages( packages ); end
138
+
139
+ def add_reserved_name( reserved_name ); @client_build.add_reserved_name( reserved_name ); end
140
+ def add_reserved_names( reserved_names ); @client_build.add_reserved_names( reserved_names ); end
141
+ def del_reserved_name( reserved_name ); @client_build.del_reserved_name( reserved_name ); end
142
+ def del_reserved_names( reserved_names ); @client_build.del_reserved_names( reserved_names ); end
143
+
144
+ def add_gfx_format( gfx_format_name ); @client_build.add_gfx_format( gfx_format_name ); end
145
+ def add_gfx_formats( gfx_format_names ); @client_build.add_gfx_formats( gfx_format_names ); end
146
+ def del_gfx_format( gfx_format_name ); @client_build.del_gfx_format( gfx_format_name ); end
147
+ def del_gfx_formats( gfx_format_names ); @client_build.del_gfx_formats( gfx_format_names ); end
148
+
149
+ def client_build; @client_build; end
150
+
151
+ def client_cache; @client_cache; end
152
+
153
+ def close
154
+ if @thr
155
+ @thr.kill!
156
+ @thr = false
157
+ end
158
+ @client_build.flush
159
+ @client_build = nil
160
+ @client_cache = nil
161
+ @build_logger.close
162
+ end
163
+
164
+ def squeeze( js )
165
+ return @client_build.squeeze( js )
166
+ end
167
+
168
+ def init
169
+
170
+ @thr = false
171
+
172
+ @build_logger = BuildLogger.new( File.join(@path,'log','build_log') )
173
+ @build_logger.open
174
+
175
+ @client_build = ClientPkgBuild.new( ::RSence.config[:client_pkg], @build_logger )
176
+ @client_cache = ClientPkgCache.new
177
+
178
+ @build_busy = false
179
+ rebuild_client
180
+
181
+ end
182
+
183
+ end
184
+
185
+ ClientPkg.new
186
+
@@ -0,0 +1,25 @@
1
+
2
+ # The human-readable product name of the package
3
+ title: Client Resource Package
4
+
5
+ # The human-readable version of the package
6
+ version: 2.0.0
7
+
8
+ # A brief description of the package (rdoc formatting supported)
9
+ description: |
10
+ This Bundle contains:
11
+ - The ClientPkg Servlet for managing client builds and serving the results.
12
+ - The ClientPkgBuild class for doing the builds.
13
+ - The ClientPkgCache class for storing the build results.
14
+ - The ClientPkgServe module that handles the request handling.
15
+
16
+ # A flag (when false) prevents the plugin from automatically reload when changed.
17
+ reloadable: false
18
+
19
+ # A flag (when false) enables automatic construction
20
+ # of the Plugin and Servlet classes contained.
21
+ inits_self: true
22
+
23
+ # System version requirement.
24
+ sys_version: '>= 2.0.0'
25
+
@@ -0,0 +1,569 @@
1
+ ## Riassence Framework
2
+ # Copyright 2009 Riassence Inc.
3
+ # http://riassence.com/
4
+ #
5
+ # You should have received a copy of the GNU General Public License along
6
+ # with this software package. If not, contact licensing@riassence.com
7
+ ##
8
+
9
+
10
+ class ClientPkgBuild
11
+
12
+ require 'jsmin_c'
13
+ require 'jscompress'
14
+ require 'html_min'
15
+ require 'util/gzstring'
16
+
17
+ def read_file( path )
18
+ filehandle = open( path, 'rb' )
19
+ filedata = filehandle.read
20
+ filehandle.close
21
+ return filedata
22
+ end
23
+
24
+ def gzip_string( string )
25
+ gz_string = GZString.new('')
26
+ gz_writer = Zlib::GzipWriter.new( gz_string, @gz_strategy )
27
+ gz_writer.write( string )
28
+ gz_writer.close
29
+ return gz_string
30
+ end
31
+
32
+ def read_css( src_path )
33
+ css_data = read_file( src_path )
34
+ unless @debug
35
+ unless @no_whitespace_removal
36
+ css_data = @html_min.minimize( css_data )
37
+ if @css_min
38
+ css_data = CSSMin.minify( css_data )
39
+ end
40
+ end
41
+ end
42
+ if @no_gzip
43
+ gz_css = false
44
+ else
45
+ gz_css = gzip_string( css_data )
46
+ end
47
+ return [css_data, gz_css]
48
+ end
49
+
50
+ def read_html( src_path )
51
+ html_data = read_file( src_path )
52
+ unless @debug
53
+ unless @no_whitespace_removal
54
+ html_data = @html_min.minimize( html_data )
55
+ end
56
+ end
57
+ if @no_gzip
58
+ gz_html = false
59
+ else
60
+ gz_html = gzip_string( html_data )
61
+ end
62
+ return [html_data, gz_html]
63
+ end
64
+
65
+ def read_gfx( src_path_theme, tgt_hash_gfx )
66
+ gfx_size = 0
67
+ src_files_gfx_path = File.join( src_path_theme, 'gfx' )
68
+ [ src_path_theme, src_files_gfx_path ].each do |src_files_gfx|
69
+ if File.exist?( src_files_gfx )
70
+ Dir.entries( src_files_gfx ).each do |src_gfx_filename|
71
+ src_file_gfx = File.join( src_files_gfx, src_gfx_filename )
72
+ if @gfx_formats.include?( src_file_gfx[-4..-1] )
73
+ tgt_hash_gfx[src_gfx_filename] = read_file( src_file_gfx )
74
+ gfx_size += File.stat( src_file_gfx ).size
75
+ end
76
+ end
77
+ end
78
+ end
79
+ return gfx_size
80
+ end
81
+
82
+ # processes theme-related files
83
+ def read_theme( bundle_dir, bundle_name )
84
+ @theme_names.each do |theme_name|
85
+ @theme_sizes[ theme_name ] = {
86
+ :css => [0,0],
87
+ :html => [0,0],
88
+ :gfx => 0
89
+ } unless @theme_sizes.has_key?( theme_name )
90
+ tgt_hash_theme = @themes[theme_name]
91
+ src_path_theme = File.join( bundle_dir, 'themes', theme_name )
92
+ [ File.join( src_path_theme, bundle_name+'.css' ),
93
+ File.join( src_path_theme, 'css', bundle_name+'.css' )
94
+ ].each do |src_file_css|
95
+ if File.exist?( src_file_css )
96
+ ( css_data, gz_css ) = read_css( src_file_css )
97
+ tgt_hash_css = tgt_hash_theme[:css][bundle_name] = {
98
+ :data => css_data,
99
+ :gzip => gz_css
100
+ }
101
+ @theme_sizes[ theme_name ][:css][0] += File.stat( src_file_css ).size
102
+ @theme_sizes[ theme_name ][:css][1] += css_data.size
103
+ @css_by_theme[ theme_name ][ bundle_name ] = css_data
104
+ end
105
+ end
106
+ [ File.join( src_path_theme, bundle_name+'.html' ),
107
+ File.join( src_path_theme, 'html', bundle_name+'.html' )
108
+ ].each do |src_file_html|
109
+ if File.exist?( src_file_html )
110
+ ( html_data, gz_html ) = read_html( src_file_html )
111
+ tgt_hash_html = tgt_hash_theme[:html][bundle_name] = {
112
+ :data => html_data,
113
+ :gzip => gz_html
114
+ }
115
+ @theme_sizes[ theme_name ][:html][0] += File.stat( src_file_html ).size
116
+ @theme_sizes[ theme_name ][:html][1] += html_data.size
117
+ @html_by_theme[ theme_name ][ bundle_name ] = html_data
118
+ end
119
+ end
120
+ tgt_hash_gfx = tgt_hash_theme[:gfx]
121
+ gfx_size = read_gfx( src_path_theme, tgt_hash_gfx )
122
+ @theme_sizes[ theme_name ][:gfx] += gfx_size
123
+ end
124
+ end
125
+
126
+ def add_bundle( bundle_name, bundle_path, entries )
127
+ has_themes = entries.include?( 'themes' ) and File.directory?( File.join( bundle_path, 'themes' ) )
128
+ if @bundles_found.has_key?( bundle_name )
129
+ @logger.log( "JSBuilder ERROR: duplicate bundles with the name #{bundle_name.inspect} found." )
130
+ @logger.log( " The first encountered is #{@bundles_found[ bundle_name ].inspect}" )
131
+ @logger.log( " The second encountered is #{bundle_path.inspect}" )
132
+ @logger.log( "abort." )
133
+ return false
134
+ end
135
+ unless @destinations.include?( bundle_name )
136
+ warn "JSBuilder WARNING: bundle name #{bundle_name.inspect} does not belong to any package, skipping.." if ARGV.include?('-d')
137
+ return true
138
+ end
139
+ js_data = read_file( File.join( bundle_path, bundle_name+'.js' ) )
140
+ @bundles_found[ bundle_name ] = {
141
+ :path => bundle_path,
142
+ :js_data => js_data,
143
+ :js_size => js_data.size,
144
+ :has_themes => has_themes
145
+ }
146
+ if has_themes
147
+ read_theme( bundle_path, bundle_name )
148
+ end
149
+ return true
150
+ end
151
+
152
+ def find_bundles( src_dir )
153
+ # makes sure the src_dir exists and is a directory
154
+ if File.exist?( src_dir ) and File.directory?( src_dir )
155
+ # array of item names in dir
156
+ dir_entries = Dir.entries( src_dir )
157
+ # the name of src_dir (src_dir itself is a full path)
158
+ dir_name = File.split( src_dir )[1]
159
+ # bundles are defined as directories with a js file of the same name plus the 'js.inc' tagfile
160
+ is_bundle = dir_entries.include?( @js_inc ) and dir_entries.include?( dir_name+'.js' )
161
+ # if src_dir is detected as a bundle, handle it in add_bundle
162
+ if is_bundle
163
+ add_bundle( dir_name, src_dir, dir_entries )
164
+ end
165
+ # descend into the sub-directory:
166
+ dir_entries.each do | dir_entry |
167
+ # don't descend into themes or hidden dirs:
168
+ next if dir_entry[0].chr == '.' or dir_entry == 'themes'
169
+ sub_dir = File.join( src_dir, dir_entry )
170
+ find_bundles( sub_dir ) if File.directory?( sub_dir )
171
+ end
172
+ end
173
+ end
174
+
175
+ def build_indexes
176
+ indexes = []
177
+ @destination_files.each_key do | package_name |
178
+ indexes.push( @destination_files[ package_name ] )
179
+ end
180
+ @jscompress.build_indexes( indexes.join("\n") ) unless @no_obfuscation
181
+ end
182
+
183
+ def pre_convert(jsc_data)
184
+ return @jscompress.compress( jsc_data )
185
+ end
186
+
187
+ def minimize_data
188
+ unless @quiet
189
+ @logger.log( "JS Package....................: Original | Minimized | Compressed" )
190
+ @logger.log( " : | |" )
191
+ end
192
+ @destination_files.each_key do | package_name |
193
+ jsc_data = @destination_files[package_name]
194
+ unless @debug
195
+ unless @no_whitespace_removal
196
+ jsc_data = @jsmin.minimize( jsc_data ) #.strip
197
+ end
198
+ unless @no_obfuscation
199
+ jsc_data = pre_convert( jsc_data )
200
+ end
201
+ end
202
+ @js[package_name] = jsc_data.strip
203
+ unless @no_gzip
204
+ gz_data = gzip_string( @js[package_name] )
205
+ @gz[package_name] = gz_data
206
+ end
207
+ unless @quiet
208
+ js_size = @destination_files[ package_name ].size
209
+ jsc_size = jsc_data.size
210
+ if @no_gzip
211
+ gz_size = -1
212
+ else
213
+ gz_size = gz_data.size
214
+ end
215
+ print_stat( package_name, js_size, jsc_size, gz_size )
216
+ end
217
+ end
218
+ end
219
+
220
+ def squeeze( js )
221
+ unless @no_whitespace_removal
222
+ begin
223
+ js = @jsmin.minimize( js )#.strip
224
+ rescue IndexError => e
225
+ warn "js can't get smaller using js; just ignoring jsmin"
226
+ end
227
+ end
228
+ unless @no_obfuscation
229
+ @jscompress.build_indexes( js )
230
+ js = @jscompress.compress( js )
231
+ end
232
+ return js.strip
233
+ end
234
+
235
+ def build_themes
236
+ unless @quiet
237
+ @logger.log( '' )
238
+ @logger.log( "Theme name and part...........: Original | Minimized | Compressed" )
239
+ @logger.log( " : | |" )
240
+ end
241
+ # compile "all-in-one" css and html resources
242
+ @theme_names.each do |theme_name|
243
+ html_templates = @html_by_theme[ theme_name ]
244
+ css_templates = @css_by_theme[ theme_name ]
245
+ theme_css_template_data = css_templates.values.join("\n")
246
+ theme_html_js_arr = []
247
+ theme_html_js_arr.push "HThemeManager._tmplCache[#{theme_name.to_json}]=#{html_templates.to_json}; "
248
+ theme_html_js_arr.push "HNoComponentCSS.push(#{theme_name.to_json});"
249
+ theme_html_js_arr.push "HNoCommonCSS.push(#{theme_name.to_json});"
250
+ theme_html_js_arr.push "HThemeManager._cssUrl( #{theme_name.to_json}, #{(theme_name+'_theme').to_json}, HThemeManager.themePath, null );"
251
+ theme_html_js_arr.push "HThemeManager.useCSS(#{theme_css_template_data.to_json}); "
252
+ theme_html_js = theme_html_js_arr.join('')
253
+ unless @debug
254
+ unless @no_whitespace_removal
255
+ theme_html_js = @jsmin.minimize( theme_html_js ) #.strip
256
+ end
257
+ unless @no_obfuscation
258
+ theme_html_js = pre_convert( theme_html_js )
259
+ end
260
+ end
261
+ @js[theme_name+'_theme'] = theme_html_js.strip
262
+ unless @no_gzip
263
+ theme_html_gz = gzip_string( @js[theme_name+'_theme'] )
264
+ @gz[theme_name+'_theme'] = theme_html_gz
265
+ end
266
+ unless @quiet
267
+ print_stat( "#{theme_name}/html", @theme_sizes[theme_name][:html][0], @theme_sizes[theme_name][:html][1], theme_html_gz.size )
268
+ end
269
+ @themes[theme_name][:css][theme_name+'_theme'] = {
270
+ :data => theme_css_template_data,
271
+ :gzip => false
272
+ }
273
+ unless @no_gzip
274
+ theme_css_template_data_gz = gzip_string( theme_css_template_data )
275
+ @themes[theme_name][:css][theme_name+'_theme'][:gzip] = theme_css_template_data_gz
276
+ end
277
+ unless @quiet
278
+ print_stat( "#{theme_name}/css", @theme_sizes[theme_name][:css][0], @theme_sizes[theme_name][:css][1], theme_css_template_data_gz.size )
279
+ print_stat( "#{theme_name}/gfx", @theme_sizes[theme_name][:gfx], -1, -1 )
280
+ end
281
+ end
282
+ end
283
+
284
+ def run
285
+ # hash of bundles per bundle name per theme; @html_by_theme[theme_name][bundle_name] = bundle_data
286
+ @html_by_theme = {}
287
+ @css_by_theme = {}
288
+ @theme_names.each do | theme_name |
289
+ @html_by_theme[ theme_name ] = {}
290
+ @css_by_theme[ theme_name ] = {}
291
+ end
292
+ @theme_sizes = {}
293
+ # hash of bundle -> package mappings (reverse @packages)
294
+ @destinations = {}
295
+ @package_names.each do | package_name |
296
+ @packages[ package_name ].each do |bundle_name|
297
+ @destinations[ bundle_name ] = [] unless @destinations.include?( bundle_name )
298
+ @destinations[ bundle_name ].push( package_name )
299
+ end
300
+ end
301
+ @bundles_found = {} # populated by add_bundle
302
+ @conversion_stats = {} # populated by add_hints
303
+ @src_dirs.each do | src_dir |
304
+ find_bundles( src_dir )
305
+ end
306
+ @destination_files = {} # rename to package_products
307
+ @package_names.each do |package_name|
308
+ @packages[package_name].each do |bundle_name|
309
+ if @bundles_found.has_key?( bundle_name )
310
+ @destination_files[ package_name ] = [] unless @destination_files.has_key?( package_name )
311
+ @destination_files[ package_name ].push( @bundles_found[bundle_name][:js_data] )
312
+ end
313
+ end
314
+ end
315
+ @destination_files.each do | package_name, package_array |
316
+ package_data = package_array.join('')
317
+ @destination_files[ package_name ] = package_data
318
+ end
319
+ build_indexes
320
+ minimize_data
321
+ build_themes
322
+
323
+ #save_file( File.join( @js_dst_dir, 'built' ), Time.now.to_i.to_s )
324
+
325
+ end
326
+
327
+ def setup_dirs
328
+ # make sure the src_dirs contain only absolute paths.
329
+ # if not, use current working dir as a logical prefix
330
+ @src_dirs.map! do |src_dir|
331
+ if src_dir[0].chr == '/'
332
+ src_dir
333
+ else
334
+ File.join( File.expand_path( Dir.pwd ), src_dir )
335
+ end
336
+ end
337
+
338
+ @src_dirs.each do |src_dir|
339
+ # exit with error if the src dir does not exist
340
+ unless File.exist?( src_dir )
341
+ @logger.log( "JSBuilder ERROR: the source directory #{src_dir.inspect} does not exist." )
342
+ @logger.log( "abort." )
343
+ return false
344
+ end
345
+
346
+ end
347
+
348
+ @package_names.each do |package_name|
349
+ @js[package_name] = ''
350
+ @gz[package_name] = ''
351
+ end
352
+
353
+ # ensures the destination directories of various theme parts exist
354
+ @theme_names.each do |theme_name|
355
+ @themes[theme_name] = {
356
+ :css => {},
357
+ :html => {},
358
+ :gfx => {}
359
+ }
360
+ end
361
+
362
+ return true
363
+
364
+ end
365
+
366
+ def add_src_dir( src_dir )
367
+ @src_dirs.push( src_dir ) unless @src_dirs.include? src_dir
368
+ end
369
+ def add_src_dirs( src_dirs )
370
+ src_dirs.each { |src_dir| add_src_dir( src_dir ) }
371
+ end
372
+ def del_src_dir( src_dir )
373
+ @src_dirs.delete( src_dir ) if @src_dirs.include? src_dir
374
+ end
375
+ def del_src_dirs( src_dirs )
376
+ src_dirs.each { |src_dir| del_src_dir( src_dir ) }
377
+ end
378
+
379
+ def add_theme( theme_name )
380
+ @theme_names.push( theme_name ) unless @theme_names.include? theme_name
381
+ end
382
+ def add_themes( theme_names )
383
+ theme_names.each { |theme_name| add_theme( theme_name ) }
384
+ end
385
+ def del_theme( theme_name )
386
+ @theme_names.delete( theme_name ) if @theme_names.include? theme_name
387
+ end
388
+ def del_themes( theme_names )
389
+ theme_names.each { |theme_name| del_theme( theme_name ) }
390
+ end
391
+
392
+ def add_package( pkg_name, pkg_items )
393
+ if @packages.has_key?( pkg_name )
394
+ warn "Package #{pkg_name} already exists, ignoring."
395
+ else
396
+ @packages[ pkg_name ] = pkg_items
397
+ @package_names = @packages.keys
398
+ end
399
+ end
400
+ def add_packages( packages )
401
+ packages.each do | pkg_name, pkg_items |
402
+ add_package( pkg_name, pkg_items )
403
+ end
404
+ end
405
+ def del_package( pkg_name )
406
+ if @packages.has_key?( pkg_name )
407
+ @packages.delete( pkg_name )
408
+ @package_names = @packages.keys
409
+ end
410
+ end
411
+ def del_packages( packages )
412
+ packages.each { |pkg_name| del_package( pkg_name ) }
413
+ end
414
+
415
+ def add_reserved_name( reserved_name )
416
+ @reserved_names.push( reserved_name ) unless @reserved_names.include? reserved_name
417
+ end
418
+ def add_reserved_names( reserved_names )
419
+ reserved_names.each { |n| add_reserved_name( n ) }
420
+ end
421
+ def del_reserved_name( reserved_name )
422
+ @reserved_names.delete( reserved_name ) if @resered_names.include? reserved_name
423
+ end
424
+ def del_reserved_names( reserved_names )
425
+ reserved_names.each { |n| del_reserved_name( n ) }
426
+ end
427
+
428
+ def add_gfx_format( gfx_format )
429
+ @gfx_formats.push( gfx_format ) unless @gfx_formats.include? gfx_format
430
+ end
431
+ def add_gfx_formats( gfx_formats )
432
+ gfx_formats.each { |gfx_format| add_gfx_format( gfx_format ) }
433
+ end
434
+ def del_gfx_format( gfx_format )
435
+ @gfx_formats.delete( gfx_format ) if @gfx_formats.include? gfx_format
436
+ end
437
+ def del_gfx_formats( gfx_formats )
438
+ gfx_formats.each { |gfx_format| del_gfx_format( gfx_format ) }
439
+ end
440
+
441
+ #delete: @js_dst_dir, @themes_dst_dir,
442
+
443
+ attr_reader :js, :gz, :themes, :jsmin, :jscompress
444
+
445
+ def initialize( config, logger )
446
+
447
+ @logger = logger
448
+
449
+ # src_dirs is supposed to be an array of js source directories
450
+ @src_dirs = config[:src_dirs]
451
+
452
+ @js = {}
453
+ @gz = {}
454
+ @themes = {}
455
+
456
+ # theme_names is supposed to be an array of theme names to include in the build
457
+ @theme_names = config[:theme_names]
458
+
459
+ # pkg_info is supposed to be a hash of js package name definitions by pkg_name
460
+ @packages = config[:packages]
461
+
462
+ # packages is supposed to be a list of js package name definitions to include
463
+ @package_names = @packages.keys
464
+
465
+ # reserved_names is supposed to be a list of reserved words (words that shouldn't be compressed)
466
+ @reserved_names = config[:reserved_names]
467
+
468
+ # JSCompress compresses js by "obfuscating"
469
+ # all variables beginning with an underscore "_",
470
+ # eg. "_this" -> "_0", except
471
+ # those specified in the @reserved_names array
472
+ @jscompress = JSCompress.new( config[:reserved_names] )
473
+
474
+ # HTMLMin compresses css and html by removing whitespace
475
+ @html_min = HTMLMin.new
476
+
477
+ # JSMin removes js white-space (makes the source shorter)
478
+ @jsmin = JSMin.new
479
+
480
+ # makes sure the specified dirs are ok
481
+ return if not setup_dirs
482
+
483
+ begin
484
+ require 'rubygems'
485
+ require 'cssmin'
486
+ @css_min = true
487
+ rescue LoadError => e
488
+ warn "cssmin not installed. install cssmin (gem install cssmin) to improve the css minifiying."
489
+ @css_min = false
490
+ end
491
+
492
+ # contains a list of theme gfx extensions allowed
493
+ @gfx_formats = config[:gfx_formats]
494
+
495
+ # compression strategy ( fastest vs smallest )
496
+ @gz_strategy = config[:gz_strategy]
497
+ @no_gzip = config[:no_gzip]
498
+ @no_obfuscation = config[:no_obfuscation]
499
+ @no_whitespace_removal = config[:no_whitespace_removal]
500
+ @js_inc = config[:js_inc]
501
+ @debug = (not $DEBUG_MODE)
502
+ @quiet = (not $DEBUG_MODE)
503
+ end
504
+
505
+ def find_newer( src_dir, newer_than )
506
+ if File.exist?( src_dir ) and File.directory?( src_dir )
507
+ Dir.entries( src_dir ).each do | dir_entry |
508
+ next if dir_entry[0].chr == '.'
509
+ sub_dir = File.join( src_dir, dir_entry )
510
+ if File.directory?( sub_dir )
511
+ return true if find_newer( sub_dir, newer_than )
512
+ else
513
+ if newer_than < File.stat( sub_dir ).mtime.to_i
514
+ @logger.log( "File changed: #{sub_dir}" )
515
+ return true
516
+ end
517
+ end
518
+ end
519
+ end
520
+ return false
521
+ end
522
+
523
+ def bundle_changes( newer_than )
524
+ @bundles_found.each do | bundle_name, bundle_info |
525
+ bundle_path = bundle_info[:path]
526
+ is_newer = find_newer( bundle_path, newer_than )
527
+ return true if is_newer
528
+ end
529
+ return false
530
+ end
531
+
532
+ ##def autorun
533
+ ## while true
534
+ ## newest = read_file( File.join( @js_dst_dir, 'built' ) ).to_i
535
+ ## @logger.log( "waiting for changes..." )
536
+ ## until bundle_changes( newest )
537
+ ## sleep 3
538
+ ## end
539
+ ## flush
540
+ ## run
541
+ ## `say "Autobuild complete!"` if ARGV.include?('-say')
542
+ ## end
543
+ ##end
544
+
545
+ def print_stat( package_name, dst_size, jsc_size, gz_size )
546
+ percent = 'n/a'
547
+ if dst_size > 0
548
+ percent1 = (100*(jsc_size/dst_size.to_f)).to_i.to_s + '%'
549
+ percent2 = (100*(gz_size/dst_size.to_f)).to_i.to_s + '%'
550
+ else
551
+ percent1 = '-'
552
+ percent2 = '-'
553
+ end
554
+ if jsc_size == -1
555
+ jsc_size = ''
556
+ percent1 = ''
557
+ end
558
+ if gz_size == -1
559
+ gz_size = ''
560
+ percent2 = ''
561
+ end
562
+ @logger.log( "#{package_name.ljust(30).gsub(' ','.')}: #{dst_size.to_s.rjust(9)} | #{jsc_size.to_s.rjust(6)} #{percent1.rjust(4)} | #{gz_size.to_s.rjust(6)} #{percent2.rjust(4)}" )
563
+ end
564
+
565
+ def flush
566
+ @jscompress.free_indexes
567
+ end
568
+ end
569
+