rsence-pre 2.1.0.3.pre → 2.1.0.4.pre

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0.3.pre
1
+ 2.1.0.4.pre
@@ -144,11 +144,15 @@ COMM.Values = HClass.extend({
144
144
  * - 'b': Boolean (true/false)
145
145
  * - 'n': Number (integers and floats)
146
146
  * - 's': String
147
+ * - '~': Null
148
+ * - '-': Undefined
147
149
  *
148
150
  **/
149
151
  type: function(_obj){
150
- if(_obj === null || _obj === undefined){
151
- console.log('null or undefined obj:',_obj);
152
+ if(_obj === null){
153
+ return '~';
154
+ }
155
+ else if (_obj === undefined){
152
156
  return '-';
153
157
  }
154
158
  var _type = (typeof _obj).slice(0,1);
@@ -366,9 +370,12 @@ COMM.Values = HClass.extend({
366
370
  *
367
371
  **/
368
372
  clone: function( _obj, _shallow ){
369
- if(_obj === null || _obj === undefined){
370
- console.log('null or undefined obj:',_obj);
371
- return _obj;
373
+ if(_obj === null){
374
+ return null;
375
+ }
376
+ else if (_obj === undefined){
377
+ console.log('Undefined object, supplementing with null.');
378
+ return null;
372
379
  }
373
380
  var _item,
374
381
  _cloned;
@@ -12,10 +12,17 @@
12
12
  // ..into this namespace.
13
13
  // Additional logic for handling the namespaces will however be required.
14
14
  var RSence = {
15
+
16
+ // Configuration method for the html document of the server
15
17
  serverConf: function(_clientPrefix,_helloUrl){
16
18
  COMM.ClientPrefix=_clientPrefix;
17
19
  COMM.Transporter.HelloUrl=_helloUrl;
18
20
  HThemeManager.themePath=_clientPrefix+'/themes';
21
+ },
22
+
23
+ // Structure reserved for JSONRenderer instances remotely populated by the server
24
+ guiTrees: {
25
+
19
26
  }
20
27
  };
21
28
 
@@ -24,7 +24,7 @@
24
24
  //var//RSence.Foundation
25
25
  COMM.JSONRenderer = HClass.extend({
26
26
 
27
- version: 0.6,
27
+ version: 0.7,
28
28
 
29
29
  /** = Description
30
30
  * Renders JSON structured data, see some of the demos for usage examples.
@@ -48,6 +48,9 @@ COMM.JSONRenderer = HClass.extend({
48
48
  this.scopeDepth = 0;
49
49
  this.view = this.renderNode( this.data, this.parent );
50
50
  },
51
+ die: function(){
52
+ this.view.die();
53
+ },
51
54
  defineInScope: function( _definition ){
52
55
  var _isArr = (_definition instanceof Array),
53
56
  _isObj = (_definition instanceof Object);
@@ -192,7 +192,9 @@ HPropertyList = HControl.extend({
192
192
  a: 'Array',
193
193
  s: 'String',
194
194
  n: 'Number',
195
- b: 'Boolean'
195
+ b: 'Boolean',
196
+ '~': 'Null',
197
+ '-': 'Undefined'
196
198
  },
197
199
  keyRowStyle: "position:absolute;z-index:1;right:0px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;",
198
200
  addKeyColumnControl: function( token, i ){
@@ -35,9 +35,11 @@ module RSence
35
35
  def init
36
36
  super
37
37
  yaml_src = file_read( "gui/#{@name}.yaml" )
38
- yaml_src = file_read( "gui/main.yaml" ) unless yaml_src
38
+ unless yaml_src
39
+ yaml_src = file_read( "gui/main.yaml" )
40
+ end
39
41
  if yaml_src
40
- @gui = GUIParser.new( self, yaml_src )
42
+ @gui = GUIParser.new( self, yaml_src, @name )
41
43
  else
42
44
  @gui = nil
43
45
  end
@@ -128,9 +130,10 @@ module RSence
128
130
  uninstall_client_pkgs if @client_pkgs
129
131
  end
130
132
 
131
- # @private Sends gui specification to the main plugin
132
- def spec_ui( msg )
133
- # TODO
133
+ # @private Returns structured, processed gui tree to the caller.
134
+ def struct_ui( msg )
135
+ return {} unless @gui
136
+ @gui.struct( msg, gui_params( msg ) )
134
137
  end
135
138
 
136
139
  # Automatically inits the UI using {GUIParser#init}
@@ -28,12 +28,10 @@ module RSence
28
28
 
29
29
  # include ::RSence
30
30
 
31
- # Use this method to send the client all commands required to construct the GUI Tree using JSONRenderer.
32
- # @param [Message] msg The +Message+ instance +msg+ used all over the place.
33
- # @param [Hash] params Containing all parameters referred from the YAML file, see: {GUIPlugin__#gui_params GUIPlugin#gui_params}
34
- def init( msg, params )
31
+ def struct( msg, params )
35
32
  gui_data = YAML.load( @yaml_src )
36
33
  parse_gui( gui_data, params )
34
+ return gui_data if gui_data.class == Array
37
35
  if gui_data.has_key?('dependencies')
38
36
  @parent.include_js( msg, gui_data['dependencies'] )
39
37
  gui_data.delete('dependencies')
@@ -44,9 +42,36 @@ module RSence
44
42
  msg.reply( js_src )
45
43
  end
46
44
  end
47
- gui_name = @parent.name
45
+ return gui_data
46
+ end
47
+
48
+ # Use this method to send the client all commands required to construct the GUI Tree using JSONRenderer.
49
+ # @param [Message] msg The +Message+ instance +msg+ used all over the place.
50
+ # @param [Hash] params Containing all parameters referred from the YAML file, see: {GUIPlugin__#gui_params GUIPlugin#gui_params}
51
+ def init( msg, params )
52
+ gui_data = struct( msg, params )
53
+ if gui_data.class == Array
54
+ gui_data = {
55
+ 'type' => 'GUITree',
56
+ 'version' => 0.7,
57
+ 'class' => 'RSence.GUIApp',
58
+ 'options' => {
59
+ 'priority' => 0,
60
+ 'label' => "#{@gui_name.capitalize} (autogenerated)"
61
+ },
62
+ 'subviews' => gui_data
63
+ }
64
+ end
48
65
  json_data = JSON.dump( gui_data )
49
- msg.reply( "JSONRenderer.nu(#{json_data});", true )
66
+ msg.reply( "RSence.guiTrees[#{@gui_name.to_json}]=JSONRenderer.nu(#{json_data});", true )
67
+ end
68
+
69
+ def kill( msg )
70
+ gui_name = @parent.name
71
+ gui_ns = "RSence.guiTrees[#{@gui_name.to_json}]"
72
+ msg.reply( "#{gui_ns}.die();", true )
73
+ msg.reply( "#{gui_ns}=null;", true )
74
+ msg.reply( "delete #{gui_ns};", true )
50
75
  end
51
76
 
52
77
  # Use this method to extract all the value id's of the +ses+ hash.
@@ -113,8 +138,13 @@ module RSence
113
138
  # = Parameters
114
139
  # +parent+:: The Plugin instance called from, use +self+ when constructing in a Plugin method.
115
140
  # +yaml_src+:: The YAML source template for the GUI
116
- def initialize( parent, yaml_src )
141
+ def initialize( parent, yaml_src, gui_name=false )
117
142
  @parent = parent
143
+ if gui_name
144
+ @gui_name = gui_name.to_s
145
+ else
146
+ @gui_name = parent.name.to_s
147
+ end
118
148
  @yaml_src = yaml_src
119
149
  end
120
150
 
@@ -87,20 +87,18 @@ module RSence
87
87
  # Calls the method +method_name+ with args +args+ of the plugin +plugin_name+.
88
88
  # Returns false, if no such plugin or method exists.
89
89
  def call( plugin_name, method_name, *args )
90
- unless @name_prefix
91
- plugin_name_s = plugin_name.to_s
92
- if plugin_name_s.include?(':')
93
- colon_index = plugin_name_s.index(':')
94
- sub_manager_name = plugin_name_s[0..(colon_index-1)].to_sym
95
- plugin_name = plugin_name_s[(colon_index+1)..-1].to_sym
96
- if @registry.has_key?( sub_manager_name )
97
- sub_manager = @registry[sub_manager_name]
98
- if sub_manager.respond_to?( :plugin_plugins )
99
- return sub_manager.plugin_plugins.call( plugin_name, method_name, *args )
100
- end
90
+ plugin_name_s = plugin_name.to_s
91
+ if plugin_name_s.include?(':')
92
+ colon_index = plugin_name_s.index(':')
93
+ sub_manager_name = plugin_name_s[0..(colon_index-1)].to_sym
94
+ plugin_name = plugin_name_s[(colon_index+1)..-1].to_sym
95
+ if @registry.has_key?( sub_manager_name )
96
+ sub_manager = @registry[sub_manager_name]
97
+ if sub_manager.respond_to?( :plugin_plugins )
98
+ return sub_manager.plugin_plugins.call( plugin_name, method_name, *args )
101
99
  end
102
- return false
103
100
  end
101
+ return false
104
102
  end
105
103
  plugin_name = plugin_name.to_sym
106
104
  if callable?( plugin_name, method_name )
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsence-pre
3
3
  version: !ruby/object:Gem::Version
4
- hash: 961916136
4
+ hash: 961916148
5
5
  prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
9
  - 0
10
- - 3
10
+ - 4
11
11
  - pre
12
- version: 2.1.0.3.pre
12
+ version: 2.1.0.4.pre
13
13
  platform: ruby
14
14
  authors:
15
15
  - Riassence Inc.