flok 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/drivers/chrome/src/event.js +1 -0
  3. data/app/kern/controller.js +1 -0
  4. data/app/kern/mod/debug.js +18 -7
  5. data/app/kern/mod/event.js +8 -0
  6. data/docs/branches.md +4 -0
  7. data/docs/controllers.md +2 -2
  8. data/docs/mod/debug.md +5 -2
  9. data/docs/mod/debug/dump_ui.md +1 -0
  10. data/lib/flok/user_compiler.rb +10 -12
  11. data/lib/flok/user_compiler_templates/ctable.js.erb +1 -1
  12. data/lib/flok/version.rb +1 -1
  13. data/spec/etc/cli_spec.rb +0 -2
  14. data/spec/etc/user_compiler/controller0.rb +0 -1
  15. data/spec/etc/user_compiler_spec.rb +3 -2
  16. data/spec/kern/assets/controller0.rb +0 -1
  17. data/spec/kern/assets/controller1.rb +0 -2
  18. data/spec/kern/assets/controller_bare.rb +3 -2
  19. data/spec/kern/assets/controller_def.rb +0 -1
  20. data/spec/kern/assets/{controller_context.rb → controller_describe.rb} +3 -2
  21. data/spec/kern/assets/controller_spots.rb +6 -1
  22. data/spec/kern/assets/controller_spots_embed.rb +6 -3
  23. data/spec/kern/assets/controller_spots_embed_removed.rb +9 -3
  24. data/spec/kern/assets/embed_info.rb +0 -2
  25. data/spec/kern/assets/event_gw.rb +0 -2
  26. data/spec/kern/assets/forward_and_back.rb +37 -0
  27. data/spec/kern/assets/goto.rb +0 -3
  28. data/spec/kern/assets/goto2.rb +0 -2
  29. data/spec/kern/assets/lower_event.rb +0 -2
  30. data/spec/kern/assets/raise_event.rb +0 -2
  31. data/spec/kern/assets/rest_service.rb +0 -1
  32. data/spec/kern/assets/send_event.rb +0 -1
  33. data/spec/kern/assets/test_event.rb +0 -1
  34. data/spec/kern/assets/test_event2.rb +0 -2
  35. data/spec/kern/assets/test_event3.rb +0 -2
  36. data/spec/kern/assets/timer_service.rb +0 -1
  37. data/spec/kern/controller_spec.rb +12 -12
  38. data/spec/kern/debug_spec.rb +12 -6
  39. data/spec/kern/debug_ui_spec.rb +266 -186
  40. data/spec/kern/rest_service_spec.rb +1 -1
  41. data/spec/kern/timer_service_spec.rb +1 -1
  42. metadata +7 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d2381d87fc2df1592fba24b3c253c1306483a27
4
- data.tar.gz: d8b34fdcf810a4751a6586219933d2fd8b43bd54
3
+ metadata.gz: 00cd49da5335192729606171ad9984480b369ebe
4
+ data.tar.gz: 9a7bc120ce65ee6203b56cbd0c05eaf3437ff9a2
5
5
  SHA512:
6
- metadata.gz: db14dc64d1c11300b4f60f45a4f5c87e84f1ad3483dc31d3e98f351eedf7d707cfb80fd1843df555c9c02265a6d38a610f18dfd1d1039cdca020f195335cfe2d
7
- data.tar.gz: 58b581c57eb5b27cec7cbcc2f82c2535ffb54d9916ead0bdd50fc0872d72640910680f6c80f122bb2e7a06b874b1d0074e0c4289173dcfe1078c78509ccbf826
6
+ metadata.gz: 1fdfc40123d710b11c1ec8d5d57d8de48d1855b70d1a479198e9fe49a6e24ae0759daa1c813515f4a38d16025e5aee0cb26e522d71a6a902807de38401e0499d
7
+ data.tar.gz: 699c0f41acff97be48740a378bcaf89f6bac7c4eebf13f7de22999d23d54bd48d17e58e64e9c4e56f678020e3139b71db6368a7a8e84cd1e168aabef4ee95a3a
@@ -1,4 +1,5 @@
1
1
  function if_event(ep, name, info) {
2
+
2
3
  //Dispatch to controller if cinstances defines ep
3
4
  if (cinstances[ep] !== undefined) {
4
5
  if (name == "action") {
@@ -16,6 +16,7 @@
16
16
  //Embed a view-controller into a named spot. If spot is null, then it is assumed
17
17
  //you are referring to the root-spot.
18
18
  function _embed(vc_name, sp, context, event_gw) {
19
+ console.log("Eembed request for vc named: " + vc_name + " into spot: " + sp);
19
20
  //Lookup VC ctable entry
20
21
  var cte = ctable[vc_name];
21
22
 
@@ -38,7 +38,6 @@ function int_debug_dump_ui() {
38
38
  payload.children.push(rvc);
39
39
  }
40
40
 
41
- //Notify with the 'debug' pointer of -333
42
41
  SEND("main", "if_event", -333, "debug_dump_ui_res", payload);
43
42
  }
44
43
 
@@ -54,12 +53,17 @@ function dump_ui_recurse(ptr, node) {
54
53
 
55
54
  //Live controller instance
56
55
  var cinfo = tel_deref(ptr);
56
+ var cte = cinfo.cte;
57
57
 
58
58
  //Get action
59
- node['action'] = cinfo.action;
59
+ var action = cinfo.action;
60
+ node['action'] = action;
60
61
 
61
62
  //Get name from the ctable reference
62
- node['name'] = cinfo.cte.name;
63
+ node['name'] = cte.name;
64
+
65
+ //Get a list of events that this action responds to
66
+ node['events'] = Object.keys(cte.actions[action].handlers);
63
67
 
64
68
  //Recurse with the 'main' view (ptr+1) in this view controller's
65
69
  //first child slot. (there is only one view per view controller)
@@ -112,9 +116,16 @@ function dump_ui_recurse(ptr, node) {
112
116
  }
113
117
 
114
118
  ////////////////////////////////////////////////////////////
115
- //Controller context
119
+ //Controller describe
116
120
  ////////////////////////////////////////////////////////////
117
- function int_debug_controller_context(bp) {
118
- var payload = tel_deref(bp).context;
119
- SEND("main", "if_event", -333, "debug_controller_context_res", payload);
121
+ function int_debug_controller_describe(bp) {
122
+ //Grab the controller's instance and table entry
123
+ var cinfo = tel_deref(bp);
124
+ var cte = cinfo.cte;
125
+
126
+ var payload = {
127
+ context: cinfo.context,
128
+ events: Object.keys(cte.actions[cinfo.action].handlers)
129
+ };
130
+ SEND("main", "if_event", -333, "debug_controller_describe_res", payload);
120
131
  }
@@ -2,6 +2,14 @@
2
2
  evt = {};
3
3
 
4
4
  function int_event(ep, event_name, info) {
5
+ <% if @debug %>
6
+ if (typeof ep == 'string' || ep instanceof String) {
7
+ console.log("WARN: received ep of '" + ep + "' that was a string!!!");
8
+ console.log("name: " + name);
9
+ console.log("info: " + JSON.stringify(info));
10
+ }
11
+ <% end %>
12
+
5
13
  var f = evt[ep];
6
14
  if (f != undefined) {
7
15
  f(ep, event_name, info);
data/docs/branches.md ADDED
@@ -0,0 +1,4 @@
1
+ #Branches
2
+
3
+ * `test` - The development branch, this branch should *never* be broken.
4
+ * `master` - The production branch.
data/docs/controllers.md CHANGED
@@ -18,11 +18,11 @@ event, the event is passed to the `event_gw` (event gateway) of the `controller_
18
18
  on the structure. If `event_gw` is `null`, then the event is ignored.
19
19
 
20
20
  ###Writing a `flok user controller (fuc)`
21
- Let's write a `fuc` controller for a view that has 2 tabs and a content area.
21
+ Let's write a `fuc` controller that has 2 tabs and a content area. The view is implicitly the same name of the controller, in this case it would be
22
+ `tab_controller`
22
23
 
23
24
  ```ruby
24
25
  controller "tab_controller" do
25
- view "tab_container"
26
26
  spaces "content"
27
27
 
28
28
  #You can also define macros for shared action traits
data/docs/mod/debug.md CHANGED
@@ -14,8 +14,11 @@ the port -333 with the message name `eval_res` and the info as `{info: res}` whe
14
14
 
15
15
  `int_debug_dump_ui` - See [Debug Dump UI](./debug/dump_ui.md) for specifics.
16
16
 
17
- `int_debug_controller_context(bp)` - Retreive a controller's context. Sends a `if_event` to port `-333` named `debug_controller_context_res` with the payload of the controller's
18
- context at `bp`
17
+ `int_debug_controller_describe(bp)` - Retreive information about a controller. Sends a `if_event` to port `-333` named `debug_controller_describe_res` with the payload of the controller's
18
+ describe at `bp`.
19
+ * describe returns
20
+ * `context` - The context of the controller which is `cinfo.context`
21
+ * `events` - The list of events the current controller action will respond to, **current action not the same as displayed if it's changed**
19
22
 
20
23
  ### Driver Spec related
21
24
  * `if_debug_spec_assoc(base, key)` - When this message is received, the client shall return a message called `spec` containing the value
@@ -18,6 +18,7 @@ Ontop of the base node, the type defines a child class of the node:
18
18
  * `name` - The name of the view controller (human friendly)
19
19
  * `action` - Current action name (human friendly)
20
20
  * `ptr` - The base pointer of this view controller
21
+ * `events` - A list of events that the current action is capabable of handling
21
22
  * `view` - View
22
23
  * `name` - The name of the view
23
24
  * `ptr` - The pointer to the view
@@ -114,6 +114,7 @@ module Flok
114
114
  #Calculate spot index as an offset from the base address using the index of the spot in the spots
115
115
  #address offset
116
116
  res = %{
117
+
117
118
  var ptr = _embed("#{vc_name}", __base__+#{spot_index}+1, #{context}, __base__);
118
119
  __info__.embeds[#{spot_index-1}].push(ptr);
119
120
  }
@@ -210,20 +211,21 @@ module Flok
210
211
  }
211
212
  }
212
213
 
213
- //Send off event for action change
214
- main_q.push([3, "if_event", __base__, "action", {
215
- from: old_action,
216
- to: "#{action_name}"
217
- }]);
218
-
219
-
220
214
  //Prep embeds array, embeds[0] refers to the spot bp+2 (bp is vc, bp+1 is main)
221
215
  __info__.embeds = [];
222
216
  for (var i = 1; i < #{@controller.spots.count}; ++i) {
223
217
  __info__.embeds.push([]);
224
218
  }
225
219
 
220
+ //Call on_entry for the new action via the singleton on_entry
221
+ //located in ctable
226
222
  __info__.cte.actions[__info__.action].on_entry(__base__)
223
+
224
+ //Send off event for action change
225
+ main_q.push([3, "if_event", __base__, "action", {
226
+ from: old_action,
227
+ to: "#{action_name}"
228
+ }]);
227
229
  }
228
230
  out.puts res
229
231
  #Request(service_name, payload, event_name_cb)
@@ -263,7 +265,7 @@ module Flok
263
265
  end
264
266
 
265
267
  class UserCompilerController
266
- attr_accessor :root_view, :name, :spots, :macros
268
+ attr_accessor :name, :spots, :macros
267
269
  def initialize name, ctx, &block
268
270
  @name = name
269
271
  @ctx = ctx
@@ -273,10 +275,6 @@ module Flok
273
275
  self.instance_eval(&block)
274
276
  end
275
277
 
276
- def view name
277
- @root_view = name
278
- end
279
-
280
278
  #Create an action macro
281
279
  def macro name, &block
282
280
  @macros[name] = block
@@ -2,7 +2,7 @@ ctable = {
2
2
  <% @controllers.each do |c| %>
3
3
  <%= c.name %>: {
4
4
  name: '<%= c.name %>',
5
- root_view: '<%= c.root_view %>',
5
+ root_view: '<%= c.name %>',
6
6
  spots: <%= c.spots.to_json %>,
7
7
  actions: {
8
8
  <% actions_for_controller(c.name).each do |a| %>
data/lib/flok/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flok
2
- VERSION = "0.0.31"
2
+ VERSION = "0.0.32"
3
3
  end
data/spec/etc/cli_spec.rb CHANGED
@@ -168,7 +168,6 @@ it "Can create a new project with correct directories" do
168
168
  #Now add a file
169
169
  File.write "./app/controllers/test2.rb", %{
170
170
  controller "my_controller" do
171
- view "my_controller"
172
171
  action "my_action" do
173
172
  on_entry %{
174
173
  }
@@ -216,7 +215,6 @@ it "Can create a new project with correct directories" do
216
215
  #Now add a file
217
216
  File.write "./app/controllers/test2.rb", %{
218
217
  controller "my_controller" do
219
- view "my_controller"
220
218
  action "my_action" do
221
219
  on_entry %{
222
220
  }
@@ -1,5 +1,4 @@
1
1
  controller :my_controller do
2
- view :test_view
3
2
  spots "hello", "world"
4
3
 
5
4
  action :my_action do
@@ -27,10 +27,11 @@ RSpec.describe "User compiler" do
27
27
  compiler = Flok::UserCompiler
28
28
  end
29
29
 
30
- it "Can compile a controller and give up the root view" do
30
+ it "Can compile a controller and give up the root
31
+ iew" do
31
32
  ctx = compile "controller0"
32
33
  root_view = ctx.eval "ctable.my_controller.root_view"
33
- expect(root_view).to eq("test_view")
34
+ expect(root_view).to eq("my_controller")
34
35
  end
35
36
 
36
37
  it "Can compile a controller and contain a list of actions" do
@@ -1,5 +1,4 @@
1
1
  controller :my_controller do
2
- view :test_view
3
2
  spots "hello", "world"
4
3
 
5
4
  action :my_action do
@@ -1,5 +1,4 @@
1
1
  controller :my_controller do
2
- view :test_view
3
2
  spots "hello", "world"
4
3
 
5
4
  action :my_action do
@@ -14,7 +13,6 @@ controller :my_controller do
14
13
  end
15
14
 
16
15
  controller :my_sub_controller do
17
- view :test_view2
18
16
  spots "hello", "world"
19
17
 
20
18
  action :my_action do
@@ -1,8 +1,9 @@
1
1
  controller :my_controller do
2
- view "my_view"
3
-
4
2
  action :index do
5
3
  on_entry %{
6
4
  }
5
+
6
+ on "test", %{
7
+ }
7
8
  end
8
9
  end
@@ -1,5 +1,4 @@
1
1
  controller :my_controller do
2
- view :test_view
3
2
  spots "content"
4
3
 
5
4
  macro :my_macro do
@@ -1,9 +1,10 @@
1
1
  controller :my_controller do
2
- view "my_view"
3
-
4
2
  action :index do
5
3
  on_entry %{
6
4
  context.hello = 'world';
7
5
  }
6
+
7
+ on "test", %{
8
+ }
8
9
  end
9
10
  end
@@ -1,9 +1,14 @@
1
1
  controller :my_controller do
2
- view "my_view"
3
2
  spots "one", "two"
4
3
 
5
4
  action :index do
6
5
  on_entry %{
7
6
  }
7
+
8
+ on "test", %{
9
+ }
10
+
11
+ on "test2", %{
12
+ }
8
13
  end
9
14
  end
@@ -1,19 +1,22 @@
1
1
  controller :my_controller do
2
- view "my_view"
3
2
  spots "one", "two"
4
3
 
5
4
  action :index do
6
5
  on_entry %{
7
6
  Embed("my_other_controller", "one", {});
8
7
  }
8
+
9
+ on "test1", %{
10
+ }
9
11
  end
10
12
  end
11
13
 
12
14
  controller :my_other_controller do
13
- view "my_other_view"
14
-
15
15
  action :index do
16
16
  on_entry %{
17
17
  }
18
+
19
+ on "test2", %{
20
+ }
18
21
  end
19
22
  end
@@ -1,5 +1,4 @@
1
1
  controller :my_controller do
2
- view "my_view"
3
2
  spots "one", "two"
4
3
 
5
4
  action :index do
@@ -10,19 +9,26 @@ controller :my_controller do
10
9
  on "next", %{
11
10
  Goto("other");
12
11
  }
12
+
13
+ on "test1", %{
14
+ }
13
15
  end
14
16
 
15
17
  action :other do
16
18
  on_entry %{
17
19
  }
20
+
21
+ on "test2", %{
22
+ }
18
23
  end
19
24
  end
20
25
 
21
26
  controller :my_other_controller do
22
- view "my_other_view"
23
-
24
27
  action :index do
25
28
  on_entry %{
26
29
  }
30
+
31
+ on "test3", %{
32
+ }
27
33
  end
28
34
  end
@@ -1,5 +1,4 @@
1
1
  controller :my_controller do
2
- view :test_view
3
2
  spots "hello", "world"
4
3
 
5
4
  action :my_action do
@@ -14,7 +13,6 @@ controller :my_controller do
14
13
  end
15
14
 
16
15
  controller :my_sub_controller do
17
- view :test_view2
18
16
  spots "hello", "world"
19
17
 
20
18
  action :my_action do
@@ -1,5 +1,4 @@
1
1
  controller :my_controller do
2
- view :test_view
3
2
  spots "hello", "world"
4
3
 
5
4
  action :my_action do
@@ -10,7 +9,6 @@ controller :my_controller do
10
9
  end
11
10
 
12
11
  controller :my_sub_controller do
13
- view :test_view2
14
12
  spots "hello", "world"
15
13
 
16
14
  action :my_action do
@@ -0,0 +1,37 @@
1
+ controller :fabric do
2
+ spots "content"
3
+
4
+ action "one" do
5
+ on_entry %{
6
+ Embed("one", "content", {});
7
+ }
8
+
9
+ on "next_clicked", %{
10
+ Goto("two");
11
+ }
12
+ end
13
+
14
+ action "two" do
15
+ on_entry %{
16
+ Embed("two", "content", {});
17
+ }
18
+
19
+ on "back_clicked", %{
20
+ Goto("one");
21
+ }
22
+ end
23
+ end
24
+
25
+ controller :one do
26
+ action "index" do
27
+ on_entry %{
28
+ }
29
+ end
30
+ end
31
+
32
+ controller :two do
33
+ action "index" do
34
+ on_entry %{
35
+ }
36
+ end
37
+ end