rsence 2.0.0.10.pre → 2.0.0.11

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,162 @@
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
+
13
+ module Plugins
14
+
15
+ # This module contains common functionality included in the {Plugin__ Plugin}, {GUIPlugin__ GUIPlugin} and the {Servlet__ Servlet} base classes.
16
+ #
17
+ # = Extension hooks for server events
18
+ # These methods are provided as the basic server event hooks:
19
+ # * {#init +#init+} -- Use instead of +initialize+
20
+ # * {#open +#open+} -- Extend to open objects
21
+ # * {#flush +#flush+} -- Extend to write the state and to flush buffers
22
+ # * {#close +#close+} -- Extend to close objects
23
+ #
24
+ # = Utility methods
25
+ # These are general utility methods not intended to be extended.
26
+ # * {#file_read +#file_read+} Use to read files
27
+ # * {#yaml_read +#yaml_read+} Use to read yaml data
28
+ # * {#file_write +#file_write+} Use to write files
29
+ # * {#bundle_path +#bundle_path+} Use for plugin bundle -specific paths
30
+ # * {#httime +#httime+} Use for HTTP date/time
31
+ #
32
+ # = See also
33
+ # * {file:PluginBundles Plugin Bundles} -- General information about the plugin bundle system
34
+ # * {Plugin__ Plugin} -- The Plugin base class
35
+ # * {Servlet__ Servlet} -- The Servlet base class
36
+ # * {GUIPlugin__ GUIPlugin} -- The GUIPlugin base class
37
+ module PluginBase
38
+
39
+ # @private External accessor for @plugins
40
+ # @return [PluginManager] The PluginManager the instance belongs to.
41
+ attr_reader :plugins
42
+
43
+ # Extend this method do any initial configuration instead of extending the +initialize+ constructor, which should *never* be done in plugins.
44
+ #
45
+ # It is called by the {PluginManager#register_bundle PluginManager} when the plugin has been constructed and registered.
46
+ #
47
+ # @return [nil]
48
+ def init
49
+ end
50
+
51
+ # Extend to open objects like streams and database connections.
52
+ #
53
+ # It is called by the {PluginManager#update_bundles! PluginManager} after the {#init} method, when everything is constructed after all plugins are loaded.
54
+ #
55
+ # @return [nil]
56
+ def open
57
+ end
58
+
59
+ # Extend to save your plugin state, write or flush any data that needs to be stored.
60
+ #
61
+ # It is called by the {PluginManager#unload_bundle PluginManager} before {#close}, but doesn't always mean a +close+ event is imminent.
62
+ #
63
+ # @return [nil]
64
+ def flush
65
+ end
66
+
67
+ # Extend to close objects like streams and database connections.
68
+ #
69
+ # It is called by the {PluginManager#unload_bundle PluginManager} when the plugin is about to be destructed, so don't expect any events after it has been called.
70
+ #
71
+ # @return [nil]
72
+ def close
73
+ end
74
+
75
+ # File reader utility
76
+ #
77
+ # Reads the contents of the file given in the +path+.
78
+ #
79
+ # @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before reading the file.
80
+ #
81
+ # @return [false] If there is no file, returns +false+
82
+ # @return [String] The contents of the file.
83
+ def file_read( path )
84
+ path = bundle_path( path )
85
+ return false unless File.exist?( path )
86
+ return File.read( path )
87
+ end
88
+
89
+ # YAML reader utility
90
+ #
91
+ # Reads the contents of the YAML file given in the +path+ and returns as a parsed structure of the contents of the file.
92
+ #
93
+ # @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before reading the file.
94
+ #
95
+ # @return [false] If the is no file, returns +false+
96
+ # @return [Object] Any valid structure defined by the YAML file, parsed to a Ruby object.
97
+ def yaml_read( path )
98
+ file_data = file_read( path )
99
+ if not file_data
100
+ return false
101
+ else
102
+ return YAML.load( file_data )
103
+ end
104
+ end
105
+
106
+ # Flie writer utility.
107
+ #
108
+ # Writes the contents of the +data+ into the file given in the +path+.
109
+ # @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before writing the file.
110
+ # @param [#to_s] data The data to write.
111
+ #
112
+ # @return [true,false] A success code of the operation (+false+ for failure and +true+ for success).
113
+ def file_write( path, data )
114
+ path = bundle_path( path )
115
+ begin
116
+ datafile = File.open( path, 'wb' )
117
+ datafile.write( data.to_s )
118
+ datafile.close
119
+ return true
120
+ rescue => e
121
+ warn "file_write error for path #{path} #{e}"
122
+ return false
123
+ end
124
+ end
125
+ alias file_save file_write
126
+
127
+ # Path utility
128
+ #
129
+ # Makes a full, absolute path using the plugin bundle as the default path when a relative path is given. Returns just the bundle's local path, if no parameters given.
130
+ #
131
+ # @param [String, false] path The path is relative to the bundle path by default, unless it starts with '/' or '..'.
132
+ # @param [String, false] prefix Alternative root path if +path+ is specified as a relative path.
133
+ # @param [String, false] suffix The file suffix, like the the extension.
134
+ #
135
+ # @return [String] Full absolute path.
136
+ def bundle_path( path=false, prefix=false, suffix=false )
137
+ return @path if not path
138
+ if suffix
139
+ path = "#{path}#{suffix}" unless path.end_with?(suffix)
140
+ end
141
+ if prefix
142
+ path = File.join( prefix, path )
143
+ end
144
+ path = File.expand_path( path, @path )
145
+ return path
146
+ end
147
+
148
+ # Utility for returning the time in the HTTP RFC specification format, like:
149
+ # !!!text
150
+ # Sun, 04 Jul 2010 06:20:53 EEST
151
+ #
152
+ # @param [Time, false] time An Time object to format. Uses the current date/time by default.
153
+ #
154
+ # @return [String] The date/time formatted according to the HTTP RFC specification.
155
+ def httime(time=false)
156
+ time = Time.new unless time
157
+ return time.gmtime.strftime('%a, %d %b %Y %H:%M:%S %Z')
158
+ end
159
+
160
+ end
161
+ end
162
+ end
@@ -6,65 +6,71 @@
6
6
  # with this software package. If not, contact licensing@riassence.com
7
7
  ##
8
8
 
9
- module ::RSence
9
+
10
+ module RSence
11
+
12
+
10
13
  module Plugins
11
14
 
12
- # Interface to enable plugins under a plugin.
13
- # Just include this in your subclass of Plugin.
14
- # The plugins loaded using this system are isolated from other plugins.
15
- # To address them from this plugin, use @plugin_plugins instead of
16
- # @plugins to address them.
15
+
16
+ # Include this module in your subclass of {Plugin__ Plugin} to enable sub-plugin bundles in another plugin bundle.
17
+ #
18
+ # The plugins loaded using this system are isolated from system-wide plugins.
19
+ #
20
+ # To address them from this plugin, use +@plugin_plugins+ instead of +@plugins+ to access them.
21
+ #
22
+ # Install your sub-plugins into a directory named +plugins+ inside your plugin bundle.
17
23
  module PluginPlugins
18
24
 
19
- # Extended init, delegates calls to the sub-plugins.
25
+ # Extended {#init}, delegates calls to the sub-plugins.
20
26
  def init
21
27
  super
22
28
  @plugin_plugins = RSence::PluginManager.new( [ bundle_path('plugins') ] )
23
29
  end
24
30
 
25
- # Extended open, delegates calls to the sub-plugins.
31
+ # Extended {#open}, delegates calls to the sub-plugins.
26
32
  def open
27
33
  super
28
34
  @plugin_plugins.delegate(:open)
29
35
  end
30
36
 
31
- # Extended close, delegates calls to the sub-plugins.
37
+ # Extended {#close}, delegates calls to the sub-plugins.
32
38
  def close
33
39
  super
34
40
  @plugin_plugins.delegate(:close)
35
41
  end
36
42
 
37
- # Extended flush, delegates calls to the sub-plugins.
43
+ # Extended {#flush}, delegates calls to the sub-plugins.
38
44
  def flush
39
45
  super
40
46
  @plugin_plugins.delegate(:flush)
41
47
  end
42
48
 
43
- # Extended idle, delegates calls to the sub-plugins.
49
+ # Extended {#idle}, delegates calls to the sub-plugins.
44
50
  def idle( msg )
45
51
  super
46
52
  @plugin_plugins.delegate(:idle,msg)
47
53
  end
48
54
 
49
- # Extended init_ses, delegates calls to the sub-plugins.
55
+ # Extended {#init_ses}, delegates calls to the sub-plugins.
50
56
  def init_ses( msg )
51
57
  super
52
58
  @plugin_plugins.delegate(:init_ses,msg)
53
59
  end
54
60
 
55
- # Extended restore_ses, delegates calls to the sub-plugins.
61
+ # Extended {#restore_ses}, delegates calls to the sub-plugins.
56
62
  def restore_ses( msg )
57
63
  super
58
64
  @plugin_plugins.delegate(:restore_ses,msg)
59
65
  end
60
66
 
61
- # Extended cloned_target, delegates calls to the sub-plugins.
67
+ # Extended {#cloned_target}, delegates calls to the sub-plugins.
62
68
  def cloned_target( msg, source_session )
63
69
  super
64
70
  @plugin_plugins.delegate(:cloned_target,msg,source_session)
65
71
  end
66
72
 
67
- # Extended cloned_source, delegates calls to the sub-plugins.
73
+ # Extended {#cloned_source}, delegates calls to the sub-plugins.
68
74
  def cloned_source( msg, target_session )
69
75
  super
70
76
  @plugin_plugins.delegate(:cloned_source,msg,target_session)
@@ -6,16 +6,26 @@
6
6
  # with this software package. If not, contact licensing@riassence.com
7
7
  ##
8
8
 
9
- module ::RSence
9
+
10
+ module RSence
11
+
12
+
10
13
  module Plugins
11
- # Include this module in your plugin class to automatically
12
- # create and connect/disconnect an sqlite database.
13
- # The plugin instance will have a @db Sequel object referring
14
- # to the sqlite database automatically created
14
+
15
+
16
+ # Include this module in your plugin class to automatically create, update and connect/disconnect a sqlite database file.
17
+ #
18
+ # The Plugin instances including this module will have a +@db+ Sequel[http://sequel.rubyforge.org/] object referring to the sqlite database automatically created.
19
+ #
15
20
  module PluginSqliteDB
16
21
 
17
- # First calls superclass, then creates database if it doesn't exist.
18
- # Then calls init_db_tables.
22
+ # Extends {Plugin__#init Plugin#init} to specify +@db_path+ as the name of the bundle with a +.db+ suffix in the project environment +db+ path.
23
+ #
24
+ # Calls {#create_db_tables} (extend with your own method), if no database is found (typically on the first run in an environment)
25
+ #
26
+ # @example If your plugin bundle is named +my_app+, a +db/my_app.db+ database is created under your project environment.
27
+ #
28
+ # @return [nil]
19
29
  def init
20
30
  super
21
31
  db_dir = File.join( RSence.args[:env_path], 'db' )
@@ -27,43 +37,58 @@ module ::RSence
27
37
  end
28
38
  end
29
39
 
30
- # Automatically opens the database connection, then calls update_db.
40
+ # Extends {PluginBase#open PluginBase#open} to open the sqlite database from +@db_path+ as a +@db+ instance variable.
41
+ #
42
+ # Calls {#update_db} (extend with your own method) after the database object is created.
43
+ #
44
+ # @return [nil]
31
45
  def open
32
46
  @db = Sequel.sqlite( @db_path )
33
47
  update_db
34
48
  super
35
49
  end
36
50
 
37
- # Automatically closes (disconnects) the database. Calls flush_db before closing.
51
+ # Extends {PluginBase#close PluginBase#close} to close (disconnect) the database object.
52
+ #
53
+ # Calls {#flush_db} (extend with your own method) before closing the database object.
54
+ #
55
+ # @return [nil]
38
56
  def close
39
57
  flush_db
40
58
  @db.disconnect
41
59
  super
42
60
  end
43
61
 
44
- # Extend this method to do something immediately after the @db object is assigned.
62
+ # Extend this method to do something immediately after the +@db+ object is created.
63
+ #
45
64
  # An usage scenario would be updating some tables or deleting some junk rows.
65
+ #
66
+ # @return [nil]
46
67
  def update_db
47
68
  end
48
69
 
49
- # Extend this method to do something immediately before the @db object is disconnected.
70
+ # Extend this method to do something immediately before the +@db+ object is disconnected.
71
+ #
50
72
  # An usage scenario would be deleting some junk rows or writing some pending data in memory into the database.
73
+ #
74
+ # @return [nil]
51
75
  def flush_db
52
76
  end
53
77
 
54
78
  # Extend this method to define tables or initial data for the tables.
55
79
  # It's called once, when the database is created.
56
80
  #
57
- # NOTE: In a future reversion, tables might be defined from a configuration file.
58
- #
59
- # = Usage:
60
- # @db.create_table :my_table do
61
- # primary_key :id
62
- # String :my_text_column
81
+ # @example Creates a table named +:my_table+ and inserts one row.
82
+ # def create_db_tables
83
+ # @db.create_table :my_table do
84
+ # primary_key :id
85
+ # String :my_text_column
86
+ # end
87
+ # my_table = @db[:my_table]
88
+ # my_table.insert(:my_text_column => 'Some text')
63
89
  # end
64
- # my_table = @db[:my_table]
65
- # my_table.insert(:my_text_column => 'Some text')
66
- #
90
+ #
91
+ # @return [nil]
67
92
  def create_db_tables
68
93
  end
69
94
 
@@ -5,18 +5,19 @@
5
5
  # You should have received a copy of the GNU General Public License along
6
6
  # with this software package. If not, contact licensing@riassence.com
7
7
  ##
8
+
9
+
8
10
  require 'plugins/plugins'
9
11
  require 'plugins/dependencies'
10
12
 
11
13
  module RSence
12
14
 
13
- ## = Abstract
14
15
  ## PluginManager is the service that loads and provides method delegation
15
16
  ## amongst its plugin bundles.
16
17
  ##
17
18
  ## = Usage
18
- ## plugin_paths = [ 'plugins', '/home/me/rsence/plugins' ]
19
- ## myPluginManager = RSence::PluginManager.new( plugin_paths )
19
+ ## plugin_paths = [ 'plugins', '/home/me/rsence/plugins' ]
20
+ ## myPluginManager = RSence::PluginManager.new( plugin_paths )
20
21
  ##
21
22
  class PluginManager
22
23
 
@@ -258,7 +259,7 @@ module RSence
258
259
 
259
260
  # Dependency, by default the system category (built-in plugins).
260
261
  # A nil ( "~" in yaml ) value means no dependencies.
261
- :depends_on => :system,
262
+ :depends_on => [ :system ],
262
263
 
263
264
  # Optional, name of category. The built-in plugins are :system
264
265
  :category => nil,
@@ -304,7 +305,7 @@ module RSence
304
305
  end
305
306
  end
306
307
 
307
- # Extra information, not overrideable in info.yaml
308
+ # Extra information, not override-able in info.yaml
308
309
 
309
310
  # Path of bundle
310
311
  info[:path] = bundle_path
@@ -502,16 +503,19 @@ module RSence
502
503
  to_unload.push( name ) if not found_map.has_key?( name )
503
504
  end
504
505
  to_unload.each do |name|
506
+ next if @deps.category?( name )
505
507
  puts "Unloading #{name.inspect}"
506
508
  unload_bundle( name )
507
509
  end
508
510
  to_reload.each do |name|
511
+ next if @deps.category?( name )
509
512
  puts "Unloading #{name.inspect}"
510
513
  unload_order = unload_bundle( name )
511
514
  to_load += unload_order
512
515
  end
513
516
  info_map = {}
514
517
  to_load.each do |name|
518
+ next unless found_map.has_key? name
515
519
  info_map[name] = bundle_info( *found_map[name] )
516
520
  end
517
521
  no_deps = {}
@@ -524,6 +528,7 @@ module RSence
524
528
  end
525
529
  to_open = []
526
530
  @deps.list.each do |name|
531
+ next if @deps.category?( name )
527
532
  next unless to_load.include?( name )
528
533
  info = info_map[name]
529
534
  if to_reload.include?( name )
@@ -6,8 +6,16 @@
6
6
  # with this software package. If not, contact licensing@riassence.com
7
7
  ##
8
8
 
9
- # Contains the PluginUtil module which has common methods for the bundle classes
10
- require 'plugins/plugin_util'
9
+
10
+ module RSence
11
+
12
+ # Namespace for plugin classes and modules
13
+ module Plugins
14
+ end
15
+ end
16
+
17
+ # Contains the PluginBase module which has common methods for the bundle classes
18
+ require 'plugins/plugin_base'
11
19
 
12
20
  # guiparser.rb contains the Yaml serializer for gui trees.
13
21
  # It uses JSONRenderer on the client to build user interfaces.
@@ -20,15 +28,22 @@ require 'plugins/plugin_sqlite_db'
20
28
  # Interface for plugins in a plugin bundle
21
29
  require 'plugins/plugin_plugins'
22
30
 
23
- module ::RSence
31
+
32
+ # Templates for the main plugin classes.
33
+ require 'plugins/plugin'
34
+ require 'plugins/gui_plugin'
35
+ require 'plugins/servlet'
36
+
37
+
38
+ module RSence
39
+
24
40
  module Plugins
25
41
 
26
- require 'plugins/plugin'
27
-
28
- # The PluginMaker mimic class creates the Plugin class from PluginTemplate
29
- def self.PluginMaker
42
+ # Creates the runtime Plugin class from Plugin__
43
+ # @return [Plugin__]
44
+ def self.Plugin
30
45
  lambda do |ns|
31
- klass = Class.new( PluginTemplate ) do
46
+ klass = Class.new( Plugin__ ) do
32
47
  def self.ns=(ns)
33
48
  define_method( :bundle_info ) do
34
49
  ns.bundle_info
@@ -40,12 +55,12 @@ module ::RSence
40
55
  end
41
56
  end
42
57
 
43
- require 'plugins/gui_plugin'
44
58
 
45
- # The GUIPluginMaker mimic class creates the GUIPlugin class from GUIPluginTemplate
46
- def self.GUIPluginMaker
59
+ # Creates the runtime GUIPlugin class from GUIPlugin__
60
+ # @return [GUIPlugin__]
61
+ def self.GUIPlugin
47
62
  lambda do |ns|
48
- klass = Class.new( GUIPluginTemplate ) do
63
+ klass = Class.new( GUIPlugin__ ) do
49
64
  def self.ns=(ns)
50
65
  define_method( :bundle_info ) do
51
66
  ns.bundle_info
@@ -57,12 +72,12 @@ module ::RSence
57
72
  end
58
73
  end
59
74
 
60
- require 'plugins/servlet'
61
75
 
62
- # The ServletMaker mimic class creates the Servlet class from ServletTemplate
63
- def self.ServletMaker
76
+ # Creates the runtime Servlet class from Servlet__
77
+ # @return [Servlet__]
78
+ def self.Servlet
64
79
  lambda do |ns|
65
- klass = Class.new( ServletTemplate ) do
80
+ klass = Class.new( Servlet__ ) do
66
81
  def self.ns=(ns)
67
82
  define_method( :bundle_info ) do
68
83
  ns.bundle_info
@@ -74,31 +89,48 @@ module ::RSence
74
89
  end
75
90
  end
76
91
 
77
- # Loads bundle according to the +params+ hash.
78
- # Some essential params:
79
- # :src_path => '/path/of/the_plugin/the_plugin.rb'
80
- # :bundle_path => '/path/of/the_plugin'
81
- # :bundle_name => :the_plugin
92
+ # Loads bundle in an anonymous module with special environment options.
93
+ # @param [Hash] params
94
+ # @option params [String] :src_path ('/path/of/the_plugin/the_plugin.rb') The ruby source file to read.
95
+ # @option params [String] :bundle_path ('/path/of/the_plugin') The plugin bundle directory path.
96
+ # @option params [String] :bundle_name (:the_plugin) The name of the plugin as it will be registered.
97
+ # @return [Module] Isolated, anonymous module containing the evaluated source code of +src_path+
82
98
  def self.bundle_loader( params )
83
- src_path = params[:src_path]
84
99
  begin
85
100
  mod = Module.new do |m|
86
101
  if RUBY_VERSION.to_f >= 1.9
87
- m.define_singleton_method( :bundle_path ) do
88
- params[:bundle_path]
102
+ m.define_singleton_method( :_bundle_path ) do
103
+ params[ :bundle_path ]
104
+ end
105
+ else
106
+ m.module_eval( <<-END
107
+ def self._bundle_path; #{params[:bundle_path].inspect}; end
108
+ END
109
+ )
110
+ end
111
+
112
+ # Makes a full path using the plugin bundle as the 'local path'.
113
+ # The (optional) +prefix+ is a subdirectory in the bundle,
114
+ # the +suffix+ is the file extension.
115
+ def self.bundle_path( path=false, prefix=false, suffix=false )
116
+ return _bundle_path if not path
117
+ if suffix
118
+ path = "#{path}#{suffix}" unless path.end_with?(suffix)
119
+ end
120
+ if prefix
121
+ path = File.join( prefix, path )
89
122
  end
123
+ path = File.expand_path( path, _bundle_path )
124
+ return path
90
125
  end
91
126
  def self.inspect; "#<module BundleWrapper of #{@@bundle_name}}>"; end
92
127
  def self.const_missing( name )
93
128
  if name == :Servlet
94
- return Plugins.ServletMaker.call( self )
95
- elsif name == :ServletPlugin
96
- warn "'ServletPlugin' is deprecated, use 'Servlet' instead."
97
- return Plugins.ServletMaker.call( self )
129
+ return Plugins.Servlet.call( self )
98
130
  elsif name == :Plugin
99
- return Plugins.PluginMaker.call( self )
131
+ return Plugins.Plugin.call( self )
100
132
  elsif name == :GUIPlugin
101
- return Plugins.GUIPluginMaker.call( self )
133
+ return Plugins.GUIPlugin.call( self )
102
134
  else
103
135
  warn "Known const missing: #{name.inspect}"
104
136
  super
@@ -106,12 +138,14 @@ module ::RSence
106
138
  end
107
139
  plugin_src = params[:src]
108
140
  unless RUBY_VERSION.to_f >= 1.9
109
- plugin_src = "bundle_path = #{params[:bundle_path].inspect}\n\n" + plugin_src
141
+ plugin_src = "_bundle_path = #{params[:bundle_path].inspect};" + plugin_src
110
142
  end
111
143
  m.module_eval( plugin_src )
112
144
  end
113
145
  return mod
114
146
  rescue => e
147
+ src_path = params[:src_path]
148
+ src_path = "<undefined src_path>" if src_path == nil
115
149
  params[:plugin_manager].plugin_error(
116
150
  e,
117
151
  'BundleLoaderError',