rsence 2.0.0.10.pre → 2.0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. data/.yardopts +10 -0
  2. data/INSTALL.rdoc +52 -86
  3. data/{LICENSE → LICENSE.txt} +0 -0
  4. data/README.rdoc +52 -49
  5. data/VERSION +1 -1
  6. data/bin/rsence +4 -6
  7. data/conf/default_conf.yaml +314 -305
  8. data/conf/default_strings.yaml +70 -71
  9. data/docs/ExampleGuiPlugin.rdoc +193 -0
  10. data/{js/comm/comm/autosync/js.inc → docs/JavascriptBundles.rdoc} +0 -0
  11. data/docs/PluginBundleInfo.rdoc +173 -0
  12. data/docs/PluginBundles.rdoc +96 -0
  13. data/docs/Values.rdoc +163 -0
  14. data/js/comm/{comm/autosync → autosync}/autosync.js +1 -2
  15. data/js/comm/{comm → autosync}/js.inc +0 -0
  16. data/js/comm/{comm/comm.js → comm.js} +1 -0
  17. data/js/comm/{comm/queue/js.inc → js.inc} +0 -0
  18. data/js/comm/jsloader/jsloader.js +2 -4
  19. data/js/comm/{comm/session → queue}/js.inc +0 -0
  20. data/js/comm/{comm/queue → queue}/queue.js +1 -0
  21. data/js/comm/{comm/sessionwatcher → session}/js.inc +0 -0
  22. data/js/comm/{comm/session → session}/session.js +4 -3
  23. data/js/comm/{comm/transporter → sessionwatcher}/js.inc +0 -0
  24. data/js/comm/{comm/sessionwatcher → sessionwatcher}/sessionwatcher.js +1 -0
  25. data/js/comm/{comm/urlresponder → transporter}/js.inc +0 -0
  26. data/js/comm/{comm/transporter → transporter}/transporter.js +1 -0
  27. data/js/comm/{comm/values → urlresponder}/js.inc +0 -0
  28. data/js/comm/{comm/urlresponder → urlresponder}/urlresponder.js +1 -0
  29. data/js/comm/{reloadapp → values}/js.inc +0 -0
  30. data/js/comm/{comm/values → values}/values.js +1 -0
  31. data/js/controls/button/button.js +10 -1
  32. data/js/controls/checkbox/checkbox.js +2 -0
  33. data/js/controls/dialogs/alert_sheet/alert_sheet.js +1 -0
  34. data/js/controls/dialogs/confirm_sheet/confirm_sheet.js +1 -0
  35. data/js/controls/dialogs/sheet/sheet.js +1 -0
  36. data/js/controls/imageview/imageview.js +1 -0
  37. data/js/controls/passwordcontrol/passwordcontrol.js +1 -0
  38. data/js/controls/progress/progressbar/progressbar.js +1 -0
  39. data/js/controls/progress/progressindicator/progressindicator.js +1 -0
  40. data/js/controls/radiobutton/radiobutton.js +3 -1
  41. data/js/controls/sliders/slider/slider.js +1 -0
  42. data/js/controls/sliders/vslider/vslider.js +1 -0
  43. data/js/controls/stepper/stepper.js +1 -0
  44. data/js/controls/stringview/stringview.js +2 -2
  45. data/js/controls/tab/tab.js +7 -5
  46. data/js/controls/textarea/textarea.js +1 -0
  47. data/js/controls/textcontrol/textcontrol.js +3 -1
  48. data/js/controls/uploader/uploader.js +1 -0
  49. data/js/controls/validatorview/validatorview.js +62 -59
  50. data/js/controls/window/window.js +1 -0
  51. data/js/core/class/class.js +2 -1
  52. data/js/core/elem/elem.js +27 -27
  53. data/js/core/event/event.js +3 -874
  54. data/js/{comm/sha → core/rsence_ns}/js.inc +0 -0
  55. data/js/core/rsence_ns/rsence_ns.js +15 -0
  56. data/js/{controls/datetime → datetime}/calendar/calendar.js +1 -0
  57. data/js/{comm/values/value → datetime/calendar}/js.inc +0 -0
  58. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.css +0 -0
  59. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar.html +0 -0
  60. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows-ie6.gif +0 -0
  61. data/js/{controls/datetime → datetime}/calendar/themes/default/calendar_arrows.png +0 -0
  62. data/js/{controls/datetime → datetime}/datetimevalue/datetimevalue.js +1 -0
  63. data/js/{comm/values/valuematrix → datetime/datetimevalue}/js.inc +0 -0
  64. data/js/{controls/datetime/calendar → datetime/timesheet}/js.inc +0 -0
  65. data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.css +0 -0
  66. data/js/{controls/datetime → datetime}/timesheet/themes/default/timesheet.html +0 -0
  67. data/js/{controls/datetime → datetime}/timesheet/timesheet.js +1 -0
  68. data/js/{controls/datetime/datetimevalue → datetime/timesheet_item}/js.inc +0 -0
  69. data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.css +0 -0
  70. data/js/{controls/datetime → datetime}/timesheet_item/themes/default/timesheet_item.html +0 -0
  71. data/js/{controls/datetime → datetime}/timesheet_item/timesheet_item.js +1 -0
  72. data/js/{controls/datetime/timesheet → datetime/timesheet_item_edit}/js.inc +0 -0
  73. data/js/{controls/datetime → datetime}/timesheet_item_edit/timesheet_item_edit.js +1 -1
  74. data/js/foundation/application/application.js +1 -2
  75. data/js/foundation/control/control.js +1 -4
  76. data/js/foundation/control/controldefaults/controldefaults.js +1 -4
  77. data/js/foundation/control/dummyvalue/dummyvalue.js +1 -0
  78. data/js/foundation/control/dyncontrol/dyncontrol.js +1 -2
  79. data/js/foundation/control/eventresponder/eventresponder.js +11 -3
  80. data/js/{controls/datetime/timesheet_item → foundation/control/valuematrix}/js.inc +0 -0
  81. data/js/{comm/values → foundation/control}/valuematrix/valuematrix.js +2 -5
  82. data/js/foundation/control/valueresponder/valueresponder.js +3 -1
  83. data/js/foundation/eventmanager/eventmanager.js +884 -0
  84. data/js/{controls/datetime/timesheet_item_edit → foundation/eventmanager}/js.inc +0 -0
  85. data/js/foundation/geom/point/point.js +2 -2
  86. data/js/foundation/geom/rect/rect.js +1 -0
  87. data/js/foundation/json_renderer/json_renderer.js +2 -0
  88. data/js/foundation/system/system.js +2 -1
  89. data/js/foundation/thememanager/thememanager.js +29 -23
  90. data/js/{controls/lists/checkboxlist → foundation/value}/js.inc +0 -0
  91. data/js/{comm/values → foundation}/value/value.js +1 -0
  92. data/js/foundation/view/markupview/markupview.js +2 -1
  93. data/js/foundation/view/morphanimation/morphanimation.js +1 -0
  94. data/js/foundation/view/view.js +6 -12
  95. data/js/foundation/view/viewdefaults/viewdefaults.js +1 -0
  96. data/js/{controls/lists → lists}/checkboxlist/checkboxlist.js +1 -0
  97. data/js/{controls/lists/listitems → lists/checkboxlist}/js.inc +0 -0
  98. data/js/{controls/lists/radiobuttonlist → lists/listitems}/js.inc +0 -0
  99. data/js/{controls/lists → lists}/listitems/listitems.js +22 -3
  100. data/js/lists/radiobuttonlist/js.inc +0 -0
  101. data/js/{controls/lists → lists}/radiobuttonlist/radiobuttonlist.js +2 -12
  102. data/js/util/reloadapp/js.inc +0 -0
  103. data/js/{comm → util}/reloadapp/reloadapp.js +10 -8
  104. data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning-ie6.gif +0 -0
  105. data/js/{comm → util}/reloadapp/themes/default/reloadapp_warning.png +0 -0
  106. data/js/util/sha/js.inc +0 -0
  107. data/js/{comm → util}/sha/sha.js +27 -33
  108. data/js/views/centerview/centerview.js +33 -3
  109. data/js/views/inlineview/inlineview.js +1 -0
  110. data/js/views/scrollview/scrollview.js +1 -0
  111. data/lib/conf/argv.rb +34 -22
  112. data/lib/conf/default.rb +165 -173
  113. data/lib/daemon/daemon.rb +9 -9
  114. data/lib/daemon/sigcomm.rb +4 -4
  115. data/lib/http/broker.rb +30 -27
  116. data/lib/http/rackup.rb +2 -3
  117. data/lib/http/request.rb +1 -2
  118. data/lib/http/response.rb +10 -10
  119. data/lib/plugins/dependencies.rb +2 -1
  120. data/lib/plugins/gui_plugin.rb +77 -50
  121. data/lib/plugins/guiparser.rb +26 -22
  122. data/lib/plugins/plugin.rb +207 -427
  123. data/lib/plugins/plugin_base.rb +162 -0
  124. data/lib/plugins/plugin_plugins.rb +21 -15
  125. data/lib/plugins/plugin_sqlite_db.rb +45 -20
  126. data/lib/plugins/pluginmanager.rb +10 -5
  127. data/lib/plugins/plugins.rb +65 -31
  128. data/lib/plugins/servlet.rb +74 -26
  129. data/lib/rsence.rb +32 -0
  130. data/lib/session/msg.rb +131 -96
  131. data/lib/session/sessionmanager.rb +5 -4
  132. data/lib/session/sessionstorage.rb +4 -3
  133. data/lib/transporter/transporter.rb +30 -21
  134. data/lib/util/gzstring.rb +4 -2
  135. data/lib/util/ruby19_fixes.rb +18 -0
  136. data/lib/values/hvalue.rb +139 -88
  137. data/lib/values/valuemanager.rb +60 -46
  138. data/plugins/client_pkg/client_pkg.rb +6 -5
  139. data/plugins/client_pkg/lib/client_pkg_build.rb +5 -5
  140. data/plugins/client_pkg/lib/client_pkg_serve.rb +8 -0
  141. data/plugins/index_html/index_html.rb +3 -1
  142. data/plugins/index_html/tmpl/index.html +2 -3
  143. data/plugins/main/js/main.js +84 -0
  144. data/plugins/main/main.rb +54 -27
  145. data/plugins/ticket/lib/common.rb +4 -2
  146. data/plugins/ticket/lib/favicon.rb +3 -2
  147. data/plugins/ticket/lib/file.rb +2 -2
  148. data/plugins/ticket/lib/img.rb +2 -2
  149. data/plugins/ticket/lib/objblob.rb +2 -2
  150. data/plugins/ticket/lib/rsrc.rb +2 -2
  151. data/plugins/ticket/lib/upload.rb +9 -8
  152. data/plugins/ticket/ticket.rb +141 -8
  153. data/setup/welcome/welcome.rb +1 -0
  154. metadata +76 -72
  155. data/lib/plugins/plugin_util.rb +0 -107
  156. data/plugins/index_html/tmpl/startup_index.html +0 -29
  157. data/plugins/main/js/riassence_ns.js +0 -87
  158. data/setup/legacy/info.yaml +0 -18
  159. data/setup/legacy/legacy.rb +0 -17
  160. data/setup/welcome/gui/welcome.yaml +0 -68
  161. data/setup/welcome/text/welcome.html +0 -8
@@ -12,10 +12,15 @@
12
12
  // centered inside its parent by adjusting its "left" style property.
13
13
  // Designed to be used as a root-level view, listens to the resize event and
14
14
  // re-calculates the center position accordingly. Likely to evolve a lot still.
15
+ var//RSence.Views
15
16
  HCenterView = HControl.extend({
16
17
  defaultEvents: {
17
18
  resize: true
18
19
  },
20
+ controlDefaults: HControlDefaults.extend({
21
+ centerX: true,
22
+ centerY: false
23
+ }),
19
24
  drawRect: function(_selfCalled){
20
25
  this.base();
21
26
  if(!_selfCalled){
@@ -23,10 +28,14 @@ HCenterView = HControl.extend({
23
28
  }
24
29
  },
25
30
  minLeft: false,
31
+ minTop: false,
26
32
  resize: function(){
27
33
  if(this.minLeft === false){
28
34
  this.minLeft = this.rect.left;
29
35
  }
36
+ if(this.minTop === false){
37
+ this.minTop = this.rect.top;
38
+ }
30
39
  var
31
40
  _rect = this.rect,
32
41
  _winSize = ELEM.windowSize(),
@@ -35,11 +44,32 @@ HCenterView = HControl.extend({
35
44
  _rectWidth = _rect.width,
36
45
  _rectWidthHalf = Math.floor(_rectWidth/2),
37
46
  _winWidthHalf = Math.floor(_winWidth/2),
38
- _left = _winWidthHalf - _rectWidthHalf;
39
- if( _left < this.minLeft ){
47
+ _left = _winWidthHalf - _rectWidthHalf,
48
+ _rectHeight = _rect.height,
49
+ _rectHeightHalf = Math.floor(_rectHeight/2),
50
+ _winHeightHalf = Math.floor(_winHeight/2),
51
+ _top = _winHeightHalf - _rectHeightHalf;
52
+ if (!this.options.centerX){
53
+ _left = _rect.left;
54
+ }
55
+ else if( _left < this.minLeft ){
40
56
  _left = this.minLeft;
41
57
  }
42
- _rect.offsetTo( _left, _rect.top );
58
+ if (!this.options.centerY){
59
+ _top = _rect.top;
60
+ }
61
+ else if( _top < this.minTop ){
62
+ _top = this.minTop;
63
+ }
64
+ _rect.offsetTo( _left, _top );
43
65
  this.drawRect(true);
44
66
  }
45
67
  });
68
+
69
+ var//RSence.Views
70
+ HMiddleView = HCenterView.extend({
71
+ controlDefaults: HControlDefaults.extend({
72
+ centerX: false,
73
+ centerY: true
74
+ })
75
+ });
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  // Simple view for inline content (relative positioning and inline view instead of block)
10
+ var//RSence.Views
10
11
  HInlineView = HView.extend({
11
12
  isAbsolute: false,
12
13
  isRelative: true,
@@ -10,6 +10,7 @@
10
10
  // Uses two special options for setting scroll bar behavior:
11
11
  // - scrollX: true | false | 'auto'
12
12
  // - scrollY: true | false | 'auto'
13
+ var//RSence.Views
13
14
  HScrollView = HControl.extend({
14
15
  controlDefaults: HControlDefaults.extend({
15
16
  scrollX: true,
@@ -1,4 +1,3 @@
1
- #--
2
1
  ## RSence
3
2
  # Copyright 2010 Riassence Inc.
4
3
  # http://riassence.com/
@@ -6,44 +5,37 @@
6
5
  # You should have received a copy of the GNU General Public License along
7
6
  # with this software package. If not, contact licensing@riassence.com
8
7
  ##
9
- #++
10
8
 
11
- # --
12
9
  # Includes the Signal Communication utility.
13
10
  # Used to respond via special PID files in the run directory of the environment
14
- # ++
15
11
  require 'daemon/sigcomm'
16
12
 
17
- # --
18
- # Creates the RSence module. RSence classes are defined within.
19
- # ++
13
+
20
14
  module RSence
21
15
 
22
- # Returns true, if platform fully supports POSIX standard signals.
16
+ # @private Returns true, if platform fully supports POSIX standard signals.
23
17
  def self.pid_support?
24
18
  # true for non-windows
25
19
  return (not ['i386-mingw32','x86-mingw32'].include?(RUBY_PLATFORM))
26
20
  end
27
21
 
28
- # ARGVParser is the "user interface" as a command-line argument parser.
29
- # Handles every action of the 'rsence' command-line tool.
22
+ # @private ARGVParser is the "user interface" as a command-line argument parser.
23
+ # It parses the command-line arguments and sets up things accordingly.
30
24
  class ARGVParser
31
25
 
32
26
  # The RSence version string, read from the VERSION file in
33
27
  # the root directory of RSence.
34
28
  @@version = File.read( File.join( SERVER_PATH, 'VERSION' ) ).strip
35
29
 
36
- # --
37
30
  # Makes various commands available depending on the platform.
38
31
  # The status/start/stop/restart/save -commands depend on an operating
39
32
  # system that fully implements POSIX standard signals.
40
33
  # These are necessary to send signals to the background process.
41
- # ++
42
- if RSence.pid_support?
34
+ if not RSence.pid_support?
35
+ @@cmds = [ :run, :initenv, :version, :help ]
36
+ else
43
37
  @@cmds = [ :run, :status, :start, :stop, :restart, :save,
44
38
  :initenv, :version, :help ]
45
- else
46
- @@cmds = [ :run, :initenv, :version, :help ]
47
39
  end
48
40
 
49
41
  help_avail_cmds = @@cmds.map{|cmd|cmd.to_s}.join("\n ")
@@ -531,7 +523,7 @@ module RSence
531
523
  end
532
524
  end
533
525
 
534
- # asks y/n and returns boleans,
526
+ # asks y/n and returns booleans,
535
527
  # the default tells if which one is for just enter
536
528
  def yesno(default=false)
537
529
  if default
@@ -798,27 +790,46 @@ module RSence
798
790
 
799
791
  end
800
792
 
801
- # This accessor enables RSence.argv method, which returns the ARGVParser instance
793
+ # @private This accessor enables RSence.argv method, which returns the ARGVParser instance
802
794
  def self.argv; @@argv_parser; end
803
795
 
804
- # This accessor enables RSence.cmd method, which returns the command the process was started with.
796
+ # @private This accessor enables RSence.cmd method, which returns the command the process was started with.
805
797
  def self.cmd; @@argv_parser.cmd; end
806
798
 
807
- # This accessor enables RSence.args method, which returns the parsed command-line arguments.
799
+ # Command line options parsed
800
+ # @return [Hash] Parsed command-line options:
801
+ # *Key* (Symbol):: *Value*
802
+ # +:env_path+:: (String) The directory of the environment.
803
+ # +:conf_files+:: (Array of Strings) Additional configuration files given with the +--conf+ command-line option. Default is +[]+.
804
+ # +:debug+:: (true or false) True, if the +-d+ or +--debug+ command-line option was given. Default is false.
805
+ # +:verbose+:: (true or false) True, if the +-v+ or +--verbose+ command-line option was given. Default is false.
806
+ # +:log_fg+:: (true or false) True, if the +-f+ or +--log-fg+ command-line option was given. Default is false.
807
+ # +:trace_js+:: (true or false) True, if the +--trace-js+ command-line option was given. Default is false.
808
+ # +:trace_delegate+:: (true or false) True, if the +--trace-delegate+ command-line option was given. Default is false.
809
+ # +:port+:: (String or nil) The TCP port number given with the +--port+ command-line option. Default is nil.
810
+ # +:addr+:: (String or nil) The TCP bind address given with the +--addr+ command-line option. Default is nil.
811
+ # +:server+:: (String or nil) The Rack http server handler given with the +--server+ command-line option. Default is nil.
812
+ # +:reset_ses+:: (true or false) True, if the +-r+ or +--reset-sessions+ command-line option was given. Default is false.
813
+ # +:autoupdate+:: (true or false) True, if the +-a+ or +--auto-update+ command-line option was given. Default is false.
814
+ # +:latency+:: (Number) Amount of milliseconds to sleep in each request given with the +--latency+ command-line option. Default is 0.
815
+ # +:say+:: (true or false) True, if the +-S+ or +--say+ command-line option was given. Default is false.
808
816
  def self.args; @@argv_parser.args; end
809
817
 
810
- # This accessor enables RSence.startable? method, which returns true if a start-type command was given.
818
+ # @private This accessor enables RSence.startable? method, which returns true if a start-type command was given.
811
819
  def self.startable?; @@argv_parser.startable?; end
812
820
 
813
- # This accessor enables RSence.version method, which returns the RSence version number.
821
+ # @return [String] The version of RSence
814
822
  def self.version; @@argv_parser.version; end
815
823
 
816
- # This accessor enables RSence.startup method, which starts RSence.
824
+ # @private This accessor enables RSence.startup method, which starts RSence.
817
825
  def self.startup
818
826
  puts "Loading configuration..." if self.args[:verbose]
819
827
  # Use the default configuration:
820
828
  require 'conf/default'
821
829
  @@config = Configuration.new(self.args).config
830
+
831
+ # RSence runtime configuration data
832
+ # @return [Hash] the active configuration structure as defined by the {file:default_conf default configuration} and overridden by local configuration files.
822
833
  def self.config
823
834
  @@config
824
835
  end
@@ -829,6 +840,7 @@ module RSence
829
840
  daemon.daemonize!
830
841
  end
831
842
 
843
+ # @private The ARGVParser instance and its startup
832
844
  @@argv_parser = ARGVParser.new
833
845
  @@argv_parser.parse( ARGV )
834
846
 
@@ -1,4 +1,3 @@
1
- #--
2
1
  ## RSence
3
2
  # Copyright 2008 Riassence Inc.
4
3
  # http://riassence.com/
@@ -6,222 +5,215 @@
6
5
  # You should have received a copy of the GNU General Public License along
7
6
  # with this software package. If not, contact licensing@riassence.com
8
7
  ##
9
- #++
8
+
10
9
 
11
10
  require 'rubygems'
12
11
  require 'rack'
13
12
  require 'yaml'
14
13
 
15
- if RUBY_VERSION.to_f >= 1.9
16
- # --
17
- # Ruby 1.9 encoding defaults.
18
- # This is clearly not enough but a good start for fixing the encoding madness.
19
- # ++
20
- Encoding.default_external = Encoding::BINARY
21
- Encoding.default_internal = Encoding::BINARY
22
- # --
23
- # Ruby 1.9 doesn't have String#each anymore.
24
- # This is a backwards-compatible work-around.
25
- # ++
26
- class String
27
- def each
28
- self.split($/).each { |e| yield e }
29
- end
30
- end
31
- end
32
14
 
33
- # Configuration handles config files and such.
34
- class Configuration
15
+
16
+ require 'util/ruby19_fixes' if RUBY_VERSION.to_f >= 1.9
17
+
18
+
19
+ module RSence
20
+
35
21
 
36
- # Method for combining two arrays
37
- def array_merge( target, source )
38
- source.each do |item|
39
- unless target.include?(item)
40
- if item.class == Array
41
- sub_arr = []
42
- array_merge( sub_arr, item )
43
- target.push( sub_arr )
44
- elsif item.class == Hash
45
- sub_hash = {}
46
- hash_merge( sub_hash, item )
47
- target.push( sub_hash )
48
- else
49
- target.push( item )
22
+ # Configuration handles config files and such.
23
+ class Configuration
24
+
25
+ # Combines the Arrays `target` and `source` recursively.
26
+ # @param [Array] target Gets merged with `source`
27
+ # @param [Array] source Has its items pushed to `target` unless an identical item already exists in `target`. If an item class is a Hash, then uses {#hash_merge} to combine them.
28
+ def array_merge( target, source )
29
+ source.each do |item|
30
+ unless target.include?(item)
31
+ if item.class == Array
32
+ sub_arr = []
33
+ array_merge( sub_arr, item )
34
+ target.push( sub_arr )
35
+ elsif item.class == Hash
36
+ sub_hash = {}
37
+ hash_merge( sub_hash, item )
38
+ target.push( sub_hash )
39
+ else
40
+ target.push( item )
41
+ end
50
42
  end
51
43
  end
52
44
  end
53
- end
54
45
 
55
- # Method for combining two hashes.
56
- def hash_merge( target, source )
57
- source.each do |key,item|
58
- if not target.has_key?key or target[key] != item
59
- if item.class == Array
60
- target[key] = [] unless target.has_key?(key)
61
- array_merge( target[key], item )
62
- elsif item.class == Hash
63
- target[key] = {} unless target.has_key?key
64
- hash_merge( target[key], item )
65
- else
66
- target[key] = item
46
+ # Combines the Hashes `target` and `source` recursively.
47
+ # @param [Hash] target Gets merged with `source`
48
+ # @param [Hash] source Has its items merged to `target` unless a key with an identical value already exists in `target`. If an item class is Array, then uses {#array_merge} to combine them.
49
+ def hash_merge( target, source )
50
+ source.each do |key,item|
51
+ if not target.has_key?key or target[key] != item
52
+ if item.class == Array
53
+ target[key] = [] unless target.has_key?(key)
54
+ array_merge( target[key], item )
55
+ elsif item.class == Hash
56
+ target[key] = {} unless target.has_key?key
57
+ hash_merge( target[key], item )
58
+ else
59
+ target[key] = item
60
+ end
67
61
  end
68
62
  end
69
63
  end
70
- end
71
64
 
72
- # The args structure comes from RSence::ARGVParser
73
- # The dont_expand_path is for special cases, when
74
- # Configuration is used without running RSence.
75
- def initialize( args, dont_expand_path=false )
65
+ # @param args A parsed structure of the command-line arguments.
66
+ # @param dont_expand_path Is reserved for special cases, when Configuration is used without running RSence.
67
+ def initialize( args, dont_expand_path=false )
76
68
 
77
- ## Paths for log and pid files
78
- pidpath = File.join( args[:env_path], 'run' )
79
- logpath = File.join( args[:env_path], 'log' )
69
+ ## Paths for log and pid files
70
+ pidpath = File.join( args[:env_path], 'run' )
71
+ logpath = File.join( args[:env_path], 'log' )
80
72
 
81
- # The default configuration path, this one is distributed with the system.
82
- yaml_conf_path = File.join( SERVER_PATH, 'conf', 'default_conf.yaml' )
73
+ # The default configuration path, this one is distributed with the system.
74
+ yaml_conf_path = File.join( SERVER_PATH, 'conf', 'default_conf.yaml' )
83
75
 
84
- # Parses the default configuration from yaml first.
85
- # This is used as the basis for overriding the defaults in various other config files.
86
- config = YAML.load( File.read( yaml_conf_path ) )
76
+ # Parses the default configuration from yaml first.
77
+ # This is used as the basis for overriding the defaults in various other config files.
78
+ config = YAML.load( File.read( yaml_conf_path ) )
87
79
 
88
- # The default strings for various messages, this one is distributed with the system.
89
- yaml_strings_path = File.join( SERVER_PATH, 'conf', 'default_strings.yaml' )
90
- strings = YAML.load( File.read( yaml_strings_path ) )
80
+ # The default strings for various messages, this one is distributed with the system.
81
+ yaml_strings_path = File.join( SERVER_PATH, 'conf', 'default_strings.yaml' )
82
+ strings = YAML.load( File.read( yaml_strings_path ) )
91
83
 
92
- # Transporter-specific strings are set.
93
- config[:transporter_conf][:messages] = strings[:messages][:transporter]
84
+ # Transporter-specific strings are set.
85
+ config[:transporter_conf][:messages] = strings[:messages][:transporter]
94
86
 
95
- # Makes the distribution 'js' directory containing the client core the
96
- # first client package source directory.
97
- config[:client_pkg][:src_dirs].unshift( File.join( SERVER_PATH, 'js' ) )
87
+ # Makes the distribution 'js' directory containing the client core the
88
+ # first client package source directory.
89
+ config[:client_pkg][:src_dirs].unshift( File.join( SERVER_PATH, 'js' ) )
98
90
 
99
- # The distributed standard plugins are in this directory.
100
- default_plugins_path = File.join( SERVER_PATH, 'plugins' )
101
- unless config[:plugin_paths].include? default_plugins_path
102
- config[:plugin_paths].push( default_plugins_path )
103
- end
91
+ # The distributed standard plugins are in this directory.
92
+ default_plugins_path = File.join( SERVER_PATH, 'plugins' )
93
+ unless config[:plugin_paths].include? default_plugins_path
94
+ config[:plugin_paths].push( default_plugins_path )
95
+ end
104
96
 
105
- # Paths to add to $LOAD_PATH after all configuration files are read.
106
- lib_paths = []
97
+ # Paths to add to $LOAD_PATH after all configuration files are read.
98
+ lib_paths = []
107
99
 
108
- # List of configuration files to look for.
109
- local_config_file_paths = [
110
- File.join(SERVER_PATH,'conf','local_conf.yaml'),
111
- '/etc/rsence/config.yaml',
112
- File.expand_path('~/.rsence/config.yaml'),
113
- File.join( File.split( SERVER_PATH )[0], 'conf', 'local_conf.yaml' )
114
- ]
100
+ # List of configuration files to look for.
101
+ local_config_file_paths = [
102
+ File.join(SERVER_PATH,'conf','local_conf.yaml'),
103
+ '/etc/rsence/config.yaml',
104
+ File.expand_path('~/.rsence/config.yaml'),
105
+ File.join( File.split( SERVER_PATH )[0], 'conf', 'local_conf.yaml' )
106
+ ]
115
107
 
116
- # Add the additional config files optionally specified in ARGVParser
117
- args[:conf_files].each do |conf_file|
118
- local_config_file_paths.push( conf_file )
119
- end
108
+ # Add the additional config files optionally specified in ARGVParser
109
+ args[:conf_files].each do |conf_file|
110
+ local_config_file_paths.push( conf_file )
111
+ end
120
112
 
121
- # Loads the configuration files
122
- local_config_file_paths.each do |local_config_file_path|
123
- if File.exists? local_config_file_path and File.file? local_config_file_path
124
- if local_config_file_path.end_with? '.yaml'
125
- puts "loading config file: #{local_config_file_path}" if args[:verbose]
126
- local_conf = YAML.load( File.read( local_config_file_path ) )
127
- unless local_conf.class == Hash
128
- warn "invalid configuration file: #{local_config_file_path.inspect}"
129
- next
113
+ # Loads the configuration files
114
+ local_config_file_paths.each do |local_config_file_path|
115
+ if File.exists? local_config_file_path and File.file? local_config_file_path
116
+ if local_config_file_path.end_with? '.yaml'
117
+ puts "loading config file: #{local_config_file_path}" if args[:verbose]
118
+ local_conf = YAML.load( File.read( local_config_file_path ) )
119
+ unless local_conf.class == Hash
120
+ warn "invalid configuration file: #{local_config_file_path.inspect}"
121
+ next
122
+ end
123
+ hash_merge( config, local_conf )
124
+ else
125
+ warn "Only Yaml configuration files are supported."
130
126
  end
131
- hash_merge( config, local_conf )
132
- else
133
- warn "Only Yaml configuration files are supported."
134
127
  end
135
128
  end
136
- end
137
129
 
138
- # Adds the plugins directory of the environment
139
- # to the configuration automatically
140
- env_plugins_path = File.expand_path( 'plugins', args[:env_path] )
141
- unless config[:plugin_paths].include? env_plugins_path
142
- config[:plugin_paths].push( env_plugins_path )
143
- end
130
+ # Adds the plugins directory of the environment
131
+ # to the configuration automatically
132
+ env_plugins_path = File.expand_path( 'plugins', args[:env_path] )
133
+ unless config[:plugin_paths].include? env_plugins_path
134
+ config[:plugin_paths].push( env_plugins_path )
135
+ end
144
136
 
145
- # At this point, configuration files are read and ready.
137
+ # At this point, configuration files are read and ready.
146
138
 
147
- puts "plugin paths: #{config[:plugin_paths].inspect}" if args[:debug]
139
+ puts "plugin paths: #{config[:plugin_paths].inspect}" if args[:debug]
148
140
 
149
- # Override configuration options with command-line-options.
150
- config[:trace] = true if args[:trace_js]
151
- config[:debug_mode] = true if args[:debug]
152
- config[:http_server][:latency] = args[:latency]
153
- config[:http_server][:port] = args[:port] if args[:port]
154
- config[:http_server][:bind_address] = args[:addr] if args[:addr]
155
- config[:http_server][:rack_require] = args[:server] if args[:server]
156
- config[:session_conf][:reset_sessions] = true if args[:reset_ses]
141
+ # Override configuration options with command-line-options.
142
+ config[:trace] = true if args[:trace_js]
143
+ config[:debug_mode] = true if args[:debug]
144
+ config[:http_server][:latency] = args[:latency]
145
+ config[:http_server][:port] = args[:port] if args[:port]
146
+ config[:http_server][:bind_address] = args[:addr] if args[:addr]
147
+ config[:http_server][:rack_require] = args[:server] if args[:server]
148
+ config[:session_conf][:reset_sessions] = true if args[:reset_ses]
157
149
 
158
- config[:client_pkg][:no_obfuscation] = true if args[:client_pkg_no_obfuscation]
159
- config[:client_pkg][:no_whitespace_removal] = true if args[:client_pkg_no_whitespace_removal]
150
+ config[:client_pkg][:no_obfuscation] = true if args[:client_pkg_no_obfuscation]
151
+ config[:client_pkg][:no_whitespace_removal] = true if args[:client_pkg_no_whitespace_removal]
160
152
 
161
- # Sets the default pid and log paths used by the HTTPDaemon
162
- config[:daemon][:pid_fn] = File.join(pidpath, "rsence.pid") unless config[:daemon].has_key?(:pid_fn)
163
- config[:daemon][:log_fn] = File.join(logpath, "rsence") unless config[:daemon].has_key?(:log_fn)
153
+ # Sets the default pid and log paths used by the HTTPDaemon
154
+ config[:daemon][:pid_fn] = File.join(pidpath, "rsence.pid") unless config[:daemon].has_key?(:pid_fn)
155
+ config[:daemon][:log_fn] = File.join(logpath, "rsence") unless config[:daemon].has_key?(:log_fn)
164
156
 
165
- # Check database path for sqlite databases.
166
- if config[:database][:ses_db].start_with?('sqlite://') and not dont_expand_path
167
- db_url = File.expand_path( config[:database][:ses_db].split('sqlite://')[1], args[:env_path] )
168
- config[:database][:ses_db] = "sqlite://#{db_url}"
169
- end
157
+ # Check database path for sqlite databases.
158
+ if config[:database][:ses_db].start_with?('sqlite://') and not dont_expand_path
159
+ db_url = File.expand_path( config[:database][:ses_db].split('sqlite://')[1], args[:env_path] )
160
+ config[:database][:ses_db] = "sqlite://#{db_url}"
161
+ end
170
162
 
171
- # Sets the various standard url prefixes:
172
- [ ## POST-requests
173
- # broker_key # default_uri
174
- # The default responder for transporter requests.
175
- [ :x, File.join(config[:base_url],'x') ],
176
- # The default responder for cookie-enabled "handshake" transporter requests
177
- [ :hello, File.join(config[:base_url],'hello') ],
178
- # The default responder for file uploads
179
- [ :u, File.join(config[:base_url],'U') ],
163
+ # Sets the various standard url prefixes:
164
+ [ ## POST-requests
165
+ # broker_key # default_uri
166
+ # The default responder for transporter requests.
167
+ [ :x, File.join(config[:base_url],'x') ],
168
+ # The default responder for cookie-enabled "handshake" transporter requests
169
+ [ :hello, File.join(config[:base_url],'hello') ],
170
+ # The default responder for file uploads
171
+ [ :u, File.join(config[:base_url],'U') ],
180
172
 
181
- ## GET-requests
182
- # broker_key # default_uri
183
- # The default address of built javascript and theme packages
184
- [ :h, File.join(config[:base_url],'H/') ],
185
- # The default address of the ticketserve :img -category
186
- [ :i, File.join(config[:base_url],'i/') ],
187
- # The default address of the ticketserve :rsrc -category
188
- [ :d, File.join(config[:base_url],'d/') ],
189
- # The default address of the ticketserve :file -category
190
- [ :f, File.join(config[:base_url],'f/') ],
191
- # The default address of the ticketserve :blobobj -category
192
- [ :b, File.join(config[:base_url],'b/') ],
193
- # The default address of the favicon
194
- [ :favicon, '/favicon.ico' ],
195
- # The default address of the "empty" iframe of uploader
196
- [ :uploader_iframe, File.join(config[:base_url],'U/iframe_html') ],
197
- ].each do |broker_key, default_uri|
198
- unless config[:broker_urls].has_key?( broker_key )
199
- config[:broker_urls][broker_key] = default_uri
173
+ ## GET-requests
174
+ # broker_key # default_uri
175
+ # The default address of built javascript and theme packages
176
+ [ :h, File.join(config[:base_url],'H/') ],
177
+ # The default address of the ticketserve :img -category
178
+ [ :i, File.join(config[:base_url],'i/') ],
179
+ # The default address of the ticketserve :rsrc -category
180
+ [ :d, File.join(config[:base_url],'d/') ],
181
+ # The default address of the ticketserve :file -category
182
+ [ :f, File.join(config[:base_url],'f/') ],
183
+ # The default address of the ticketserve :blobobj -category
184
+ [ :b, File.join(config[:base_url],'b/') ],
185
+ # The default address of the favicon
186
+ [ :favicon, '/favicon.ico' ],
187
+ # The default address of the "empty" iframe of uploader
188
+ [ :uploader_iframe, File.join(config[:base_url],'U/iframe_html') ],
189
+ ].each do |broker_key, default_uri|
190
+ unless config[:broker_urls].has_key?( broker_key )
191
+ config[:broker_urls][broker_key] = default_uri
192
+ end
200
193
  end
201
- end
202
194
 
203
- if RUBY_VERSION.to_f >= 1.9
204
- # The encodings mess up compression when using ruby1.9
205
- warn "Disabling gzip support for ruby 1.9" if args[:debug]
206
- config[:no_gzip] = true
207
- end
195
+ if RUBY_VERSION.to_f >= 1.9
196
+ # The encodings mess up compression when using ruby1.9
197
+ warn "Disabling gzip support for ruby 1.9" if args[:debug]
198
+ config[:no_gzip] = true
199
+ end
208
200
 
209
- # The default address of the index_html plugin
210
- unless config[:index_html].has_key?(:respond_address)
211
- config[:index_html][:respond_address] = File.join(config[:base_url])
212
- end
201
+ # The default address of the index_html plugin
202
+ unless config[:index_html].has_key?(:respond_address)
203
+ config[:index_html][:respond_address] = File.join(config[:base_url])
204
+ end
213
205
 
214
- ## Uses the lib paths as search paths
215
- lib_paths.merge( config[:lib_paths] ) if config.has_key?(:lib_paths)
216
- lib_paths.each do |lib_path|
217
- $LOAD_PATH << lib_path
218
- end
206
+ ## Uses the lib paths as search paths
207
+ lib_paths.merge( config[:lib_paths] ) if config.has_key?(:lib_paths)
208
+ lib_paths.each do |lib_path|
209
+ $LOAD_PATH << lib_path
210
+ end
219
211
 
220
- @config = config
221
- end
212
+ @config = config
213
+ end
222
214
 
223
- attr_reader :config
215
+ attr_reader :config
224
216
 
217
+ end
225
218
  end
226
219
 
227
-