rsence 2.1.11 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. data/INSTALL.rdoc +5 -3
  2. data/README.rdoc +23 -22
  3. data/VERSION +1 -1
  4. data/conf/default_conf.yaml +65 -29
  5. data/conf/rsence_command_strings.yaml +101 -71
  6. data/js/comm/autosync/autosync.js +3 -3
  7. data/js/comm/jsloader/jsloader.js +16 -3
  8. data/js/comm/queue/queue.js +1 -1
  9. data/js/comm/transporter/transporter.js +106 -83
  10. data/js/comm/values/values.js +8 -2
  11. data/js/controls/button/button.js +9 -4
  12. data/js/controls/button/themes/default/button.css +1 -1
  13. data/js/controls/checkbox/themes/default/checkbox.css +1 -1
  14. data/js/controls/dialogs/sheet/sheet.js +27 -18
  15. data/js/controls/radiobutton/themes/default/radiobutton.css +1 -1
  16. data/js/controls/searchfield/searchfield.coffee +2 -0
  17. data/js/controls/searchfield/themes/default/searchfield.css +96 -0
  18. data/js/controls/searchfield/themes/default/searchfield.html +12 -0
  19. data/js/controls/searchfield/themes/default/searchfield_parts1-ie6.gif +0 -0
  20. data/js/controls/searchfield/themes/default/searchfield_parts1.png +0 -0
  21. data/js/controls/sliders/slider/slider.js +7 -1
  22. data/js/controls/stepper/stepper.js +6 -1
  23. data/js/controls/stringview/stringview.js +50 -39
  24. data/js/controls/tab/tab.js +103 -7
  25. data/js/controls/tab/themes/default/tab.css +2 -0
  26. data/js/controls/textarea/themes/default/textarea.css +4 -0
  27. data/js/controls/textcontrol/textcontrol.js +32 -2
  28. data/js/controls/textcontrol/themes/default/textcontrol.css +17 -2
  29. data/js/controls/uploader/themes/default/uploader.css +3 -3
  30. data/js/controls/uploader/themes/default/uploader.html +1 -1
  31. data/js/controls/uploader/uploader.coffee +110 -0
  32. data/js/controls/window/themes/default/window.css +28 -5
  33. data/js/controls/window/themes/default/window.html +2 -0
  34. data/js/controls/window/window.js +5 -1
  35. data/js/core/class/class.js +22 -4
  36. data/js/core/elem/elem.coffee +816 -0
  37. data/js/core/event/event.js +2 -2
  38. data/js/core/rsence_ns/rsence_ns.coffee +31 -0
  39. data/js/core/rsence_ns/rsence_ns.js +6 -6
  40. data/js/datetime/calendar/calendar.coffee +307 -0
  41. data/js/datetime/calendar/themes/default/calendar.css +90 -9
  42. data/js/datetime/calendar/themes/default/calendar.html +11 -0
  43. data/js/datetime/calendar/themes/default/calendar_bg-ie6.gif +0 -0
  44. data/js/datetime/calendar/themes/default/calendar_bg.png +0 -0
  45. data/js/datetime/calendar/themes/default/calendar_parts1-ie6.gif +0 -0
  46. data/js/datetime/calendar/themes/default/calendar_parts1.png +0 -0
  47. data/js/datetime/calendar/themes/default/calendar_parts2-ie6.gif +0 -0
  48. data/js/datetime/calendar/themes/default/calendar_parts2.png +0 -0
  49. data/js/datetime/datetimepicker/datetimepicker.js +217 -0
  50. data/js/datetime/datetimevalue/datetimevalue.js +22 -5
  51. data/js/datetime/timesheet/themes/default/timesheet.css +51 -22
  52. data/js/datetime/timesheet/themes/default/timesheet.html +4 -2
  53. data/js/datetime/timesheet/timesheet.js +782 -192
  54. data/js/datetime/timesheet_item/themes/default/timesheet_item.css +42 -11
  55. data/js/datetime/timesheet_item/themes/default/timesheet_item.html +4 -2
  56. data/js/datetime/timesheet_item/themes/default/timesheet_item_icons.png +0 -0
  57. data/js/datetime/timesheet_item/timesheet_item.js +158 -254
  58. data/js/datetime/timesheet_item_edit/timesheet_item_edit.js +0 -274
  59. data/js/foundation/application/application.js +52 -9
  60. data/js/foundation/control/eventresponder/eventresponder.js +7 -4
  61. data/js/foundation/control/valueaction/valueaction.js +71 -0
  62. data/js/foundation/eventmanager/eventmanager.js +71 -33
  63. data/js/foundation/geom/rect/rect.js +39 -7
  64. data/js/foundation/json_renderer/json_renderer.js +278 -62
  65. data/js/foundation/locale_settings/locale_settings.js +131 -0
  66. data/js/foundation/system/system.js +40 -13
  67. data/js/foundation/thememanager/thememanager.js +21 -0
  68. data/js/foundation/view/markupview/markupview.js +12 -12
  69. data/js/foundation/view/view.js +221 -27
  70. data/js/graphics/svgcontrol/svgcontrol.js +400 -0
  71. data/js/lists/checkboxlist/checkboxlist.js +18 -7
  72. data/js/lists/listitems/listitems.js +52 -38
  73. data/js/lists/radiobuttonlist/radiobuttonlist.js +23 -7
  74. data/js/menus/menuitem/menuitem.js +5 -0
  75. data/js/menus/menuitem/themes/default/menuitem.css +45 -0
  76. data/js/menus/menuitem/themes/default/menuitem.html +4 -0
  77. data/js/menus/minimenu/minimenu.js +47 -16
  78. data/js/menus/minimenuitem/minimenuitem.js +62 -0
  79. data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.css +2 -2
  80. data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem.html +0 -0
  81. data/js/menus/{minimenu/minimenuitem → minimenuitem}/themes/default/minimenuitem_checkmark.png +0 -0
  82. data/js/menus/popupmenu/popupmenu.js +14 -0
  83. data/js/menus/popupmenu/themes/default/popupmenu.css +65 -0
  84. data/js/menus/popupmenu/themes/default/popupmenu.html +7 -0
  85. data/js/menus/popupmenu/themes/default/popupmenu.png +0 -0
  86. data/js/no_pkg/no_pkg.js +2 -0
  87. data/js/util/reloadapp/reloadapp.js +1 -1
  88. data/js/views/scrollview/scrollview.js +6 -0
  89. data/lib/rsence.rb +136 -3
  90. data/lib/rsence/argv.rb +218 -0
  91. data/lib/rsence/argv/argv_util.rb +58 -0
  92. data/lib/rsence/argv/env_check.rb +58 -0
  93. data/lib/rsence/argv/help_argv.rb +15 -0
  94. data/lib/rsence/argv/initenv_argv.rb +218 -0
  95. data/lib/rsence/argv/save_argv.rb +92 -0
  96. data/lib/rsence/argv/startup_argv.rb +118 -0
  97. data/lib/rsence/argv/status_argv.rb +132 -0
  98. data/lib/rsence/argv/test_port.rb +32 -0
  99. data/lib/{daemon → rsence}/daemon.rb +67 -23
  100. data/lib/{conf/default.rb → rsence/default_config.rb} +18 -10
  101. data/lib/{plugins → rsence}/dependencies.rb +0 -0
  102. data/lib/{util → rsence}/gzstring.rb +0 -0
  103. data/lib/rsence/http.rb +3 -0
  104. data/lib/{http → rsence/http}/broker.rb +106 -19
  105. data/lib/{http → rsence/http}/rackup.rb +0 -0
  106. data/lib/{http → rsence/http}/request.rb +0 -4
  107. data/lib/{http → rsence/http}/response.rb +0 -1
  108. data/lib/{session → rsence}/msg.rb +17 -1
  109. data/lib/{plugins → rsence}/pluginmanager.rb +29 -12
  110. data/lib/{plugins → rsence}/plugins.rb +7 -7
  111. data/lib/{plugins → rsence/plugins}/gui_plugin.rb +8 -3
  112. data/lib/{plugins → rsence/plugins}/guiparser.rb +9 -6
  113. data/lib/{plugins → rsence/plugins}/plugin.rb +23 -4
  114. data/lib/{plugins → rsence/plugins}/plugin_base.rb +11 -1
  115. data/lib/{plugins → rsence/plugins}/plugin_plugins.rb +2 -2
  116. data/lib/{plugins → rsence/plugins}/plugin_sqlite_db.rb +0 -0
  117. data/lib/{plugins → rsence/plugins}/servlet.rb +0 -0
  118. data/lib/{session → rsence}/sessionmanager.rb +101 -39
  119. data/lib/{session → rsence}/sessionstorage.rb +30 -16
  120. data/lib/{daemon → rsence}/sigcomm.rb +0 -0
  121. data/lib/{transporter → rsence}/transporter.rb +13 -11
  122. data/lib/{values/hvalue.rb → rsence/value.rb} +6 -1
  123. data/lib/{values → rsence}/valuemanager.rb +1 -1
  124. data/plugins/client_pkg/client_pkg.rb +14 -4
  125. data/plugins/client_pkg/info.yaml +2 -2
  126. data/plugins/client_pkg/lib/client_pkg_build.rb +145 -45
  127. data/plugins/client_pkg/lib/client_pkg_cache.rb +1 -1
  128. data/plugins/client_pkg/lib/client_pkg_serve.rb +1 -1
  129. data/plugins/main/main.rb +43 -3
  130. data/plugins/main/tmpl/index.html +2 -10
  131. data/plugins/main/values.yaml +3 -1
  132. data/plugins/ticket/lib/common.rb +6 -3
  133. data/plugins/ticket/ticket.rb +11 -3
  134. metadata +144 -174
  135. data/js/comm/autosync/js.inc +0 -0
  136. data/js/comm/js.inc +0 -0
  137. data/js/comm/jsloader/js.inc +0 -0
  138. data/js/comm/queue/js.inc +0 -0
  139. data/js/comm/session/js.inc +0 -0
  140. data/js/comm/sessionwatcher/js.inc +0 -0
  141. data/js/comm/transporter/js.inc +0 -0
  142. data/js/comm/urlresponder/js.inc +0 -0
  143. data/js/comm/values/js.inc +0 -0
  144. data/js/controls/button/js.inc +0 -0
  145. data/js/controls/checkbox/js.inc +0 -0
  146. data/js/controls/dialogs/alert_sheet/js.inc +0 -0
  147. data/js/controls/dialogs/confirm_sheet/js.inc +0 -0
  148. data/js/controls/dialogs/sheet/js.inc +0 -0
  149. data/js/controls/imageview/js.inc +0 -0
  150. data/js/controls/passwordcontrol/js.inc +0 -0
  151. data/js/controls/progress/progressbar/js.inc +0 -0
  152. data/js/controls/progress/progressindicator/js.inc +0 -0
  153. data/js/controls/radiobutton/js.inc +0 -0
  154. data/js/controls/sliders/slider/js.inc +0 -0
  155. data/js/controls/sliders/vslider/js.inc +0 -0
  156. data/js/controls/stepper/js.inc +0 -0
  157. data/js/controls/stringview/js.inc +0 -0
  158. data/js/controls/tab/js.inc +0 -0
  159. data/js/controls/textarea/js.inc +0 -0
  160. data/js/controls/textcontrol/js.inc +0 -0
  161. data/js/controls/uploader/js.inc +0 -0
  162. data/js/controls/uploader/uploader.js +0 -154
  163. data/js/controls/validatorview/js.inc +0 -0
  164. data/js/controls/window/js.inc +0 -0
  165. data/js/core/class/js.inc +0 -0
  166. data/js/core/elem/elem.js +0 -1325
  167. data/js/core/elem/js.inc +0 -0
  168. data/js/core/event/js.inc +0 -0
  169. data/js/core/iefix/js.inc +0 -0
  170. data/js/core/rsence_ns/js.inc +0 -0
  171. data/js/datetime/calendar/calendar.js +0 -198
  172. data/js/datetime/calendar/js.inc +0 -0
  173. data/js/datetime/datetimevalue/js.inc +0 -0
  174. data/js/datetime/timesheet/js.inc +0 -0
  175. data/js/datetime/timesheet/old_timesheet.js +0 -292
  176. data/js/datetime/timesheet/themes/default/old_timesheet.css +0 -30
  177. data/js/datetime/timesheet/themes/default/old_timesheet.html +0 -2
  178. data/js/datetime/timesheet_item/js.inc +0 -0
  179. data/js/datetime/timesheet_item/old_timesheet_item.js +0 -308
  180. data/js/datetime/timesheet_item/themes/default/old_timesheet_item.css +0 -42
  181. data/js/datetime/timesheet_item/themes/default/old_timesheet_item.html +0 -8
  182. data/js/datetime/timesheet_item_edit/js.inc +0 -0
  183. data/js/datetime/timesheet_item_edit/old_timesheet_item_edit.js +0 -274
  184. data/js/foundation/application/js.inc +0 -0
  185. data/js/foundation/control/controldefaults/js.inc +0 -0
  186. data/js/foundation/control/dummyvalue/js.inc +0 -0
  187. data/js/foundation/control/dyncontrol/js.inc +0 -0
  188. data/js/foundation/control/eventresponder/js.inc +0 -0
  189. data/js/foundation/control/js.inc +0 -0
  190. data/js/foundation/control/valuematrix/js.inc +0 -0
  191. data/js/foundation/control/valueresponder/js.inc +0 -0
  192. data/js/foundation/eventmanager/js.inc +0 -0
  193. data/js/foundation/geom/point/js.inc +0 -0
  194. data/js/foundation/geom/rect/js.inc +0 -0
  195. data/js/foundation/json_renderer/js.inc +0 -0
  196. data/js/foundation/system/js.inc +0 -0
  197. data/js/foundation/thememanager/js.inc +0 -0
  198. data/js/foundation/value/js.inc +0 -0
  199. data/js/foundation/view/js.inc +0 -0
  200. data/js/foundation/view/markupview/js.inc +0 -0
  201. data/js/foundation/view/morphanimation/js.inc +0 -0
  202. data/js/foundation/view/viewdefaults/js.inc +0 -0
  203. data/js/lists/checkboxlist/js.inc +0 -0
  204. data/js/lists/listitems/js.inc +0 -0
  205. data/js/lists/propertylist/js.inc +0 -0
  206. data/js/lists/propertylist/propertylisteditor/js.inc +0 -0
  207. data/js/lists/radiobuttonlist/js.inc +0 -0
  208. data/js/menus/minimenu/js.inc +0 -0
  209. data/js/menus/minimenu/minimenuitem/js.inc +0 -0
  210. data/js/menus/minimenu/minimenuitem/minimenuitem.js +0 -33
  211. data/js/util/reloadapp/js.inc +0 -0
  212. data/js/util/sha/js.inc +0 -0
  213. data/js/views/centerview/js.inc +0 -0
  214. data/js/views/inlineview/js.inc +0 -0
  215. data/js/views/scrollview/js.inc +0 -0
  216. data/lib/conf/argv.rb +0 -880
@@ -3,7 +3,7 @@
3
3
  .minimenuitem_label,
4
4
  .minimenuitem_state {
5
5
  position: absolute;
6
- top: 0px; height: 15px;
6
+ top: 0px; height: 16px;
7
7
  }
8
8
 
9
9
  .minimenuitem_control {
@@ -27,7 +27,7 @@
27
27
 
28
28
  .minimenuitem_label {
29
29
  left: 14px; right: 11px; top: 0px;
30
- height: 15px; line-height: 15px;
30
+ height: 15px; line-height: 14px;
31
31
  text-align: left;
32
32
  text-overflow: ellipsis;
33
33
  overflow: hidden;
@@ -0,0 +1,14 @@
1
+ var
2
+ HPopupMenu = HMiniMenu.extend({
3
+ componentName: 'popupmenu',
4
+ subComponentHeight: 24,
5
+ createComponent: function( i, _label ){
6
+ return HMenuItem.nu(
7
+ [ 0, (i*24), null, 24, 0, null ],
8
+ this.menuItemView, {
9
+ label: _label
10
+ }
11
+ );
12
+ }
13
+ });
14
+ var HPopUpMenu = HPopupMenu;
@@ -0,0 +1,65 @@
1
+
2
+ .popupmenu_control,
3
+ .popupmenu_edge_left,
4
+ .popupmenu_center,
5
+ .popupmenu_edge_right,
6
+ .popupmenu_label,
7
+ .popupmenu_antiselect {
8
+ position: absolute;
9
+ top: 0px; height: 23px;
10
+ }
11
+
12
+ .popupmenu_control {
13
+ left: 0px; right: 0px;
14
+ cursor: pointer;
15
+ }
16
+ .disabled .popupmenu_control {
17
+ cursor: default;
18
+ }
19
+
20
+ .popupmenu_edge_left,
21
+ .popupmenu_center,
22
+ .popupmenu_edge_right {
23
+ background-image: #{this.getCssFilePath('popupmenu.png')};
24
+ }
25
+
26
+ .popupmenu_edge_left {
27
+ left: 0px; width: 9px;
28
+ background-position: 0px 0px;
29
+ background-repeat: no-repeat;
30
+ }
31
+
32
+ .popupmenu_edge_right {
33
+ right: 0px; width: 17px;
34
+ background-position: -9px 0px;
35
+ background-repeat: no-repeat;
36
+ }
37
+
38
+ .popupmenu_center {
39
+ left: 9px; right: 17px;
40
+ background-position: 0px -23px;
41
+ background-repeat: repeat-x;
42
+ }
43
+
44
+ .popupmenu_label {
45
+ left: 13px; right: 11px; top: 0px;
46
+ height: 22px; line-height: #{(BROWSER_TYPE.ie7||BROWSER_TYPE.ie6)?'20':'22'}px;
47
+ text-align: left;
48
+ text-overflow: ellipsis;
49
+ overflow: hidden;
50
+ white-space:nowrap;
51
+ vertical-align: middle;
52
+ font-family: Arial, sans-serif;
53
+ font-size: 12px;
54
+ color: #333;
55
+ }
56
+ .popupmenu_control:hover > .popupmenu_label {
57
+ color: #000;
58
+ }
59
+ .disabled .popupmenu_control {
60
+ opacity: 0.6;
61
+ }
62
+
63
+ .popupmenu_antiselect {
64
+ left: 0px; right: 0px;
65
+ }
@@ -0,0 +1,7 @@
1
+ <div class="popupmenu_control" id="control#{_ID}">
2
+ <div class="popupmenu_edge_left"></div>
3
+ <div class="popupmenu_center"></div>
4
+ <div class="popupmenu_edge_right"></div>
5
+ <div class="popupmenu_label" id="label#{_ID}">#{this.label}</div>
6
+ <div class="popupmenu_antiselect"></div>
7
+ </div>
@@ -0,0 +1,2 @@
1
+
2
+ // Empty file for empty packages
@@ -101,7 +101,7 @@ ReloadApp = HApplication.extend({
101
101
  ELEM.setCSS(_alertIcon,'position:absolute;left:8px;top:8px;width:48px;height:48px;background-image:url('+_iconUrl+');');
102
102
  ELEM.setCSS(_alertTitle,'position:absolute;left:64px;top:8px;width:300px;height:24px;line-height:24px;vertical-align:middle;text-align:center;font-weight:bold;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;');
103
103
  ELEM.setHTML(_alertTitle,_this.app._title);
104
- ELEM.setCSS(_alertMessage,'position:absolute;left:64px;top:42px;width:332px;height:186px;border-bottom:1px dotted #999;line-height:17px;vertical-align:middle;overflow:auto;');
104
+ ELEM.setCSS(_alertMessage,'position:absolute;left:64px;top:42px;width:332px;height:186px;border-bottom:1px dotted #999;line-height:18px;vertical-align:middle;overflow:auto;');
105
105
  ELEM.setHTML(_alertMessage,_this.app._message);
106
106
  HButton.extend({
107
107
  click: this.app.reload
@@ -17,6 +17,12 @@ HScrollView = HControl.extend({
17
17
  scrollY: true
18
18
  }),
19
19
  drawSubviews: function(){
20
+ if(this.options.scrollX === 'auto' || this.options.scrollY === 'auto'){
21
+ this.setStyle('overflow','auto');
22
+ }
23
+ else if(this.options.scrollX || this.options.scrollY){
24
+ this.setStyle('overflow','scroll');
25
+ }
20
26
  if(!this.options.scrollX){
21
27
  this.setStyle('overflow-x','hidden');
22
28
  }
data/lib/rsence.rb CHANGED
@@ -25,8 +25,141 @@
25
25
  #
26
26
  # Most other classes are inner workings of RSence itself and are subject to change without further notice.
27
27
  module RSence
28
- end
28
+
29
+ # @private Returns true, if platform fully supports POSIX standard signals.
30
+ def self.pid_support?
31
+ # true for non-windows
32
+ return (not ['i386-mingw32','x86-mingw32'].include?(RUBY_PLATFORM))
33
+ end
34
+
35
+ # @private Returns true, if platform is linux
36
+ def self.linux?
37
+ return RUBY_PLATFORM.end_with?('-linux')
38
+ end
39
+
40
+ # @private Returns true, if platform is Mac OS X
41
+ def self.darwin?
42
+ return RUBY_PLATFORM.include?('-darwin')
43
+ end
44
+
45
+ # @private Returns signal name that resembles INFO or PWR (extra signal to poll for server status)
46
+ def self.info_signal_name
47
+ if self.linux?
48
+ return 'PWR'
49
+ else
50
+ return 'INFO'
51
+ end
52
+ end
53
+
54
+ # @private This accessor enables RSence.argv method, which returns the ARGVParser instance
55
+ def self.argv; @@argv_parser; end
56
+
57
+ # @private This accessor enables RSence.cmd method, which returns the command the process was started with.
58
+ def self.cmd; @@argv_parser.cmd; end
59
+
60
+ # Command line options parsed
61
+ # @return [Hash] Parsed command-line options:
62
+ # *Key* (Symbol):: *Value*
63
+ # +:env_path+:: (String) The directory of the environment.
64
+ # +:conf_files+:: (Array of Strings) Additional configuration files given with the +--conf+ command-line option. Default is +[]+.
65
+ # +:debug+:: (true or false) True, if the +-d+ or +--debug+ command-line option was given. Default is false.
66
+ # +:verbose+:: (true or false) True, if the +-v+ or +--verbose+ command-line option was given. Default is false.
67
+ # +:log_fg+:: (true or false) True, if the +-f+ or +--log-fg+ command-line option was given. Default is false.
68
+ # +:trace_js+:: (true or false) True, if the +--trace-js+ command-line option was given. Default is false.
69
+ # +:trace_delegate+:: (true or false) True, if the +--trace-delegate+ command-line option was given. Default is false.
70
+ # +:port+:: (String or nil) The TCP port number given with the +--port+ command-line option. Default is nil.
71
+ # +:addr+:: (String or nil) The TCP bind address given with the +--addr+ command-line option. Default is nil.
72
+ # +:server+:: (String or nil) The Rack http server handler given with the +--server+ command-line option. Default is nil.
73
+ # +:reset_ses+:: (true or false) True, if the +-r+ or +--reset-sessions+ command-line option was given. Default is false.
74
+ # +:autoupdate+:: (true or false) True, if the +-a+ or +--auto-update+ command-line option was given. Default is false.
75
+ # +:latency+:: (Number) Amount of milliseconds to sleep in each request given with the +--latency+ command-line option. Default is 0.
76
+ # +:say+:: (true or false) True, if the +-S+ or +--say+ command-line option was given. Default is false.
77
+ def self.args; @@argv_parser.args; end
78
+
79
+ def self.env_path; @@argv_parser.args[:env_path]; end
80
+
81
+ # @private This accessor enables RSence.startable? method, which returns true if a start-type command was given.
82
+ def self.startable?; @@argv_parser.startable?; end
83
+
84
+ # @return [String] The version of RSence
85
+ def self.version; @@argv_parser.version; end
86
+
87
+ # @private This accessor enables RSence.startup method, which starts RSence.
88
+ def self.startup
89
+ puts "Loading configuration..." if self.args[:verbose]
90
+ # Use the default configuration:
91
+ require 'rsence/default_config'
92
+ @@config = Configuration.new(self.args).config
93
+
94
+ # RSence runtime configuration data
95
+ # @return [Hash] the active configuration structure as defined by the {file:default_conf default configuration} and overridden by local configuration files.
96
+ def self.config
97
+ @@config
98
+ end
99
+
100
+ def self.transporter
101
+ @@transporter
102
+ end
103
+ def self.transporter=(transporter)
104
+ if class_variable_defined?(:'@@transporter')
105
+ warn "WARN: Transporter already set."
106
+ return
107
+ else
108
+ @@transporter = transporter
109
+ end
110
+ end
111
+
112
+ def self.plugin_manager
113
+ @@plugin_manager
114
+ end
115
+ def self.plugin_manager=(plugin_manager)
116
+ if class_variable_defined?(:'@@plugin_manager')
117
+ warn "WARN: @@plugin_manager already set."
118
+ return
119
+ else
120
+ @@plugin_manager = plugin_manager
121
+ end
122
+ end
123
+
124
+ def self.value_manager
125
+ @@value_manager
126
+ end
127
+ def self.value_manager=(value_manager)
128
+ if class_variable_defined?(:'@@value_manager')
129
+ warn "WARN: @@value_manager already set."
130
+ return
131
+ else
132
+ @@value_manager = value_manager
133
+ end
134
+ end
135
+
136
+ def self.session_manager
137
+ @@session_manager
138
+ end
139
+ def self.session_manager=(session_manager)
140
+ if class_variable_defined?(:'@@session_manager')
141
+ warn "WARN: @@session_manager already set."
142
+ return
143
+ else
144
+ @@session_manager = session_manager
145
+ end
146
+ end
147
+
148
+ ## Riassence Daemon controls
149
+ require 'rsence/daemon'
150
+ puts "Starting RSence..." if self.args[:verbose]
151
+ daemon = HTTPDaemon.new
152
+ daemon.daemonize!
153
+ end
154
+
155
+
156
+ # Includes the Signal Communication utility.
157
+ # Used to respond via special PID files in the run directory of the environment
158
+ require 'rsence/sigcomm'
29
159
 
30
- # Requires the ARGVParser that functions as the command-line user interface.
31
- require 'conf/argv'
160
+
161
+ # Requires the ARGVParser that functions as the command-line user interface.
162
+ require 'rsence/argv'
163
+
164
+ end
32
165
 
@@ -0,0 +1,218 @@
1
+ ## RSence
2
+ # Copyright 2010 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
+ module RSence
11
+
12
+ require 'erb'
13
+ require 'yaml'
14
+
15
+ # @private ARGVParser is the "user interface" as a command-line argument parser.
16
+ # It parses the command-line arguments and sets up things accordingly.
17
+ class ARGVParser
18
+
19
+ # Returns true if one of the 'start' -type commands were supplied
20
+ # and the environment seems valid.
21
+ def startable?; @startable; end
22
+
23
+ # Parses an argument of the 'help' command
24
+ def parse_help_argv
25
+ if @argv.length >= 2
26
+ help_cmd = @argv[1].to_sym
27
+ else
28
+ help_cmd = :help_main
29
+ end
30
+ help( help_cmd )
31
+ exit
32
+ end
33
+
34
+ # Creates the default and initial @args hash.
35
+ def init_args
36
+ @args = {
37
+ :env_path => Dir.pwd,
38
+ :conf_files => [ ], # --conf
39
+ :debug => false, # -d --debug
40
+ :verbose => false, # -v --verbose
41
+ :log_fg => false, # -f --log-fg
42
+ :trace_js => false, # --trace-js
43
+ :trace_delegate => false, # --trace-delegate
44
+ :port => nil, # --port
45
+ :addr => nil, # --addr --bind
46
+ :server => nil, # --server
47
+ :reset_ses => false, # -r --reset-sessions
48
+ :autoupdate => false, # -a --auto-update
49
+ :latency => 0, # --latency
50
+ :say => false, # -S --say
51
+ :http_delayed_start => nil, # --http-delayed-start
52
+
53
+ # client_pkg (not supported yet)
54
+ :client_pkg_no_gzip => false, # --disable-gzip
55
+ :client_pkg_no_obfuscation => false, # --disable-obfuscation
56
+ :client_pkg_no_whitespace_removal => false, # --disable-jsmin
57
+ :suppress_build_messages => true, # --build-report
58
+
59
+ }
60
+ end
61
+
62
+ # Sets various debug-related options on.
63
+ def set_debug
64
+ @args[:debug] = true
65
+ @args[:verbose] = true
66
+ @args[:autoupdate] = true
67
+ @args[:client_pkg_no_obfuscation] = true
68
+ @args[:client_pkg_no_whitespace_removal] = true
69
+ @args[:suppress_build_messages] = false
70
+ end
71
+
72
+ # Set the verbose argument on
73
+ def set_verbose
74
+ @args[:verbose] = true
75
+ end
76
+
77
+ # Set the foreground logging argument on
78
+ def set_log_fg
79
+ @args[:log_fg] = true
80
+ end
81
+
82
+ # Sets the session reset argument on
83
+ def set_reset_ses
84
+ @args[:reset_ses] = true
85
+ end
86
+
87
+ # Sets the auto-update argument on
88
+ def set_autoupdate
89
+ @args[:autoupdate] = true
90
+ end
91
+
92
+ # Sets the speech synthesis argument on
93
+ def set_say
94
+ @args[:say] = true
95
+ end
96
+
97
+ # Error message when an invalid environment is encountered, exits.
98
+ def invalid_env( env_path=false )
99
+ env_path = @args[:env_path] unless env_path
100
+ puts ERB.new( @strs[:messages][:invalid_environment] ).result( binding )
101
+ exit
102
+ end
103
+
104
+ # Error message when an invalid option is encountered, exits.
105
+ def invalid_option(arg,chr=false)
106
+ if chr
107
+ puts ERB.new( @strs[:messages][:invalid_option_chr] ).result( binding )
108
+ else
109
+ puts ERB.new( @strs[:messages][:invalid_option] ).result( binding )
110
+ end
111
+ exit
112
+ end
113
+
114
+ require 'rsence/argv/startup_argv'
115
+ require 'rsence/argv/status_argv'
116
+ require 'rsence/argv/save_argv'
117
+ require 'rsence/argv/initenv_argv'
118
+ require 'rsence/argv/help_argv'
119
+ require 'rsence/argv/env_check'
120
+ require 'rsence/argv/test_port'
121
+ include ArgvUtil
122
+
123
+ # Returns the version of RSence
124
+ def version; @version; end
125
+
126
+ # Returns the command the process was started with.
127
+ def cmd; @cmd; end
128
+
129
+ # Returns the parsed optional arguments
130
+ def args; @args; end
131
+
132
+ # Top-level argument parser, checks for command and calls sub-parser, if valid command.
133
+ def parse_argv
134
+ if @argv.empty?
135
+ puts @strs[:help][:help_help]
136
+ exit
137
+ else
138
+ cmd = @argv[0].to_sym
139
+ cmd = :help if [:h, :'-h', :'--help', :'-help'].include? cmd
140
+ end
141
+ if @cmds.include?(cmd)
142
+ @cmd = cmd
143
+ unless [:help, :version].include?( cmd )
144
+ puts "RSence #{@version} -- Ruby #{RUBY_VERSION}"
145
+ end
146
+ if cmd == :help
147
+ parse_help_argv
148
+ elsif cmd == :version
149
+ puts version
150
+ exit
151
+ elsif [:run,:start,:stop,:restart].include? cmd
152
+ parse_startup_argv
153
+ elsif cmd == :status
154
+ parse_status_argv
155
+ elsif cmd == :save
156
+ parse_save_argv
157
+ elsif cmd == :initenv or cmd == :init
158
+ parse_initenv_argv
159
+ end
160
+ else
161
+ puts @strs[:help][:unknown] + cmd.to_s.inspect
162
+ puts @strs[:help][:help_help]
163
+ exit
164
+ end
165
+ end
166
+
167
+ # The constructor sets the @startable flag as false. Use the #parse method with ARGV as the argument to start parsing the ARGV.
168
+ def initialize
169
+ @startable = false
170
+
171
+ # The RSence version string, read from the VERSION file in
172
+ # the root directory of RSence.
173
+ @version = File.read( File.join( SERVER_PATH, 'VERSION' ) ).strip
174
+
175
+ # Makes various commands available depending on the platform.
176
+ # The status/start/stop/restart/save -commands depend on an operating
177
+ # system that fully implements POSIX standard signals.
178
+ # These are necessary to send signals to the background process.
179
+ if not RSence.pid_support?
180
+ @cmds = [ :run, :init, :initenv, :version, :help ]
181
+ else
182
+ @cmds = [ :run, :status, :start, :stop, :restart, :save,
183
+ :init, :initenv, :version, :help ]
184
+ end
185
+
186
+ help_avail_cmds = @cmds.map{|cmd|cmd.to_s}.join("\n ")
187
+
188
+ # Load the strings from the strings file.
189
+ strs_path = File.join( SERVER_PATH, 'conf',
190
+ 'rsence_command_strings.yaml' )
191
+ strs_data = File.read( strs_path )
192
+
193
+ strs_data = ERB.new( strs_data ).result( binding )
194
+
195
+ @strs = YAML.load( strs_data )
196
+
197
+ @strs[:help][:run] += @strs[:help][:path]+@strs[:help][:options]
198
+ @strs[:help][:start] += @strs[:help][:path]+@strs[:help][:options]
199
+ @strs[:help][:stop] += @strs[:help][:path]+@strs[:help][:options]
200
+ @strs[:help][:restart] += @strs[:help][:path]+@strs[:help][:options]
201
+ @strs[:help][:status] += @strs[:help][:path]
202
+ @strs[:help][:save] += @strs[:help][:path]
203
+ end
204
+
205
+ # Entry point for ARGV parsing
206
+ def parse( argv )
207
+ @argv = argv
208
+ parse_argv
209
+ end
210
+
211
+ end
212
+
213
+ # @private The ARGVParser instance and its startup
214
+ @@argv_parser = ARGVParser.new
215
+ @@argv_parser.parse( ARGV )
216
+
217
+ end
218
+