flok 0.0.75 → 0.0.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/drivers/{CHROME → chrome}/README.md +0 -0
- data/app/drivers/{CHROME → chrome}/Rakefile +0 -0
- data/app/drivers/{CHROME → chrome}/build_context.rb +0 -0
- data/app/drivers/{CHROME → chrome}/cakery/spec.js.erb +0 -0
- data/app/drivers/{CHROME → chrome}/config.yml +0 -0
- data/app/drivers/{CHROME → chrome}/pipe.rb +0 -0
- data/app/drivers/{CHROME → chrome}/spec/config/config.js +0 -0
- data/app/drivers/{CHROME → chrome}/spec/init/qunit.js +0 -0
- data/app/drivers/{CHROME → chrome}/spec/spec/controller_debug_spec.js +0 -0
- data/app/drivers/{CHROME → chrome}/spec/spec/debug_spec.js +0 -0
- data/app/drivers/{CHROME → chrome}/spec/spec/dom_helpers_spec.js +0 -0
- data/app/drivers/{CHROME → chrome}/spec/spec/sel_scope_spec.js +0 -0
- data/app/drivers/{CHROME → chrome}/spec/spec/vars_spec.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/bench.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/config0.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/controller.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/debug.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/dispatch.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/event.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/helpers.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/net.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/persist.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/segue.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/sockio.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/timer.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/ui.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/vendor/jquery.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/vendor/socket.io.js +0 -0
- data/app/drivers/{CHROME → chrome}/src/vendor/store2.js +0 -0
- data/app/kern/pagers/pg_net_sim.js +3 -1
- data/lib/flok/version.rb +1 -1
- data/spec/env/kern.rb +4 -0
- data/spec/kern/assets/vm/pg_mem/write.rb +2 -8
- data/spec/kern/assets/vm/pg_mem/write2.rb +2 -6
- data/spec/kern/rest_service_spec.rb +0 -4
- data/spec/kern/vm_service_mem_pagers_spec.rb +25 -47
- data/spec/kern/vm_sockio_pager_spec.rb +6 -10
- metadata +31 -35
- data/spec/etc/services_compiler_spec.rb +0 -68
- data/spec/etc/user_compiler_spec.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95e9915e21c598cac1138e92ac3e5f53463ec5fa
|
4
|
+
data.tar.gz: a299acf1cf525084c7e71dd937005827e969dc8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19f42aa5778d4d4bdba0f13f8578b9c81e19d1c7c6dc0bb69be0d6312bc951bb87513c56c58a62f21a4caa1ef194c043b1efcd2d2f51ff2bcbc0eb6cf4456ad5
|
7
|
+
data.tar.gz: b2e796c961f4f9edb3cf698be3223b362867a6ba23e3ce7c1f7abf75374f81dde612a07d18eccd865c00eaf416fb8b076ab196c4fb0152563cd93c7faacc4815
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -13,7 +13,9 @@ function pg_net_sim_init(ns, options) {
|
|
13
13
|
function pg_net_sim_tick_handler(ep, ename, info) {
|
14
14
|
while (pg_net_sim_waiting_for_response.length > 0) {
|
15
15
|
var e = pg_net_sim_waiting_for_response.shift();
|
16
|
-
|
16
|
+
vm_transaction_begin();
|
17
|
+
vm_cache_write(pg_net_sim_ns, pg_net_sim_stored_pages[e.id]);
|
18
|
+
vm_transaction_end();
|
17
19
|
}
|
18
20
|
}
|
19
21
|
|
data/lib/flok/version.rb
CHANGED
data/spec/env/kern.rb
CHANGED
@@ -97,6 +97,10 @@ shared_context "kern" do
|
|
97
97
|
if_dispatch_json(JSON.stringify(q));
|
98
98
|
}
|
99
99
|
}
|
100
|
+
$stderr.puts "env/kern File.read... dumping directory"
|
101
|
+
$stderr.puts "pwd = #{Dir.pwd}"
|
102
|
+
$stderr.puts Dir["**/*"].select{|e| e.split("/").length < 4}.inspect
|
103
|
+
|
100
104
|
v8.eval File.read('./products/chrome/application_user.js')
|
101
105
|
return v8
|
102
106
|
end
|
@@ -3,14 +3,7 @@ controller :my_controller do
|
|
3
3
|
|
4
4
|
action :my_action do
|
5
5
|
on_entry %{
|
6
|
-
|
7
|
-
hello: "world"
|
8
|
-
}
|
9
|
-
|
10
|
-
page = NewPage("array", "test");
|
11
|
-
SetPageHead(page, "head");
|
12
|
-
SetPageNext(page, "next");
|
13
|
-
EntryInsert(page, 0, entry);
|
6
|
+
page = vm_create_page("test");
|
14
7
|
|
15
8
|
var write_info = {
|
16
9
|
ns: "local",
|
@@ -18,6 +11,7 @@ controller :my_controller do
|
|
18
11
|
};
|
19
12
|
|
20
13
|
Request("vm", "write", write_info);
|
14
|
+
kern_log("hey");
|
21
15
|
}
|
22
16
|
end
|
23
17
|
end
|
@@ -12,18 +12,14 @@ controller :my_controller do
|
|
12
12
|
}
|
13
13
|
|
14
14
|
|
15
|
-
page =
|
16
|
-
SetPageHead(page, "head");
|
17
|
-
SetPageNext(page, "next");
|
18
|
-
EntryInsert(page, 0, entry);
|
15
|
+
page = vm_create_page("test");
|
19
16
|
|
20
17
|
var write_info = {
|
21
18
|
ns: "local0",
|
22
19
|
page: page
|
23
20
|
};
|
24
21
|
|
25
|
-
page2 =
|
26
|
-
EntryInsert(page2, 0, entry);
|
22
|
+
page2 = vm_copy_page(page);
|
27
23
|
|
28
24
|
var write_info2 = {
|
29
25
|
ns: "local1",
|
@@ -18,11 +18,7 @@ RSpec.describe "kern:rest_service" do
|
|
18
18
|
|
19
19
|
//Drain queue
|
20
20
|
int_dispatch([]);
|
21
|
-
|
22
|
-
dump["rest_base_url"] = rest_base_url;
|
23
21
|
}
|
24
|
-
|
25
|
-
expect(dump["rest_base_url"]).to eq("http://localhost:8080/")
|
26
22
|
end
|
27
23
|
|
28
24
|
it "Can make a request on the rest service" do
|
@@ -35,9 +35,15 @@ RSpec.describe "kern:vm_service_mem_pagers" do
|
|
35
35
|
int_dispatch([]);
|
36
36
|
}
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
#Disk must return cache copy
|
39
|
+
@driver.int "int_per_get_res", [
|
40
|
+
Integer,
|
41
|
+
"local",
|
42
|
+
"test",
|
43
|
+
nil
|
44
|
+
]
|
45
|
+
|
46
|
+
expect(ctx.dump("vm_cache")["local"]["test"]).not_to eq(nil)
|
41
47
|
end
|
42
48
|
|
43
49
|
it "Can initialize the pg_mem1 pager" do
|
@@ -54,50 +60,6 @@ RSpec.describe "kern:vm_service_mem_pagers" do
|
|
54
60
|
expect(res).to eq(true)
|
55
61
|
end
|
56
62
|
|
57
|
-
it "Can make a write request to pg_mem1 and have that written in cache" do
|
58
|
-
ctx = flok_new_user File.read('./spec/kern/assets/vm/pg_mem/write.rb'), File.read("./spec/kern/assets/vm/pg_mem/config1.rb")
|
59
|
-
ctx.eval %{
|
60
|
-
//Call embed on main root view
|
61
|
-
base = _embed("my_controller", 0, {}, null);
|
62
|
-
|
63
|
-
//Drain queue
|
64
|
-
int_dispatch([]);
|
65
|
-
}
|
66
|
-
|
67
|
-
page = ctx.dump "page"
|
68
|
-
vm_cache = ctx.dump("vm_cache")
|
69
|
-
expect(page).to eq(vm_cache["local"]["test"])
|
70
|
-
end
|
71
|
-
|
72
|
-
it "Can initialize the pg_mem2 pager" do
|
73
|
-
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/pg_mem/config2.rb")
|
74
|
-
ctx.eval %{
|
75
|
-
//Call embed on main root view
|
76
|
-
base = _embed("my_controller", 0, {}, null);
|
77
|
-
|
78
|
-
//Drain queue
|
79
|
-
int_dispatch([]);
|
80
|
-
}
|
81
|
-
|
82
|
-
res = ctx.eval("pg_mem2_spec_did_init")
|
83
|
-
expect(res).to eq(true)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "Can make a write request to pg_mem2 and have that written in cache" do
|
87
|
-
ctx = flok_new_user File.read('./spec/kern/assets/vm/pg_mem/write.rb'), File.read("./spec/kern/assets/vm/pg_mem/config2.rb")
|
88
|
-
ctx.eval %{
|
89
|
-
//Call embed on main root view
|
90
|
-
base = _embed("my_controller", 0, {}, null);
|
91
|
-
|
92
|
-
//Drain queue
|
93
|
-
int_dispatch([]);
|
94
|
-
}
|
95
|
-
|
96
|
-
page = ctx.dump "page"
|
97
|
-
vm_cache = ctx.dump("vm_cache")
|
98
|
-
expect(page).to eq(vm_cache["local"]["test"])
|
99
|
-
end
|
100
|
-
|
101
63
|
it "Can use pg_mem0 and pg_mem1 at the same time" do
|
102
64
|
ctx = flok_new_user File.read('./spec/kern/assets/vm/pg_mem/write2.rb'), File.read("./spec/kern/assets/vm/pg_mem/config3.rb")
|
103
65
|
ctx.eval %{
|
@@ -108,6 +70,22 @@ RSpec.describe "kern:vm_service_mem_pagers" do
|
|
108
70
|
int_dispatch([]);
|
109
71
|
}
|
110
72
|
|
73
|
+
#Disk must return cache copy
|
74
|
+
@driver.int "int_per_get_res", [
|
75
|
+
Integer,
|
76
|
+
"local0",
|
77
|
+
"test",
|
78
|
+
nil
|
79
|
+
]
|
80
|
+
|
81
|
+
#Disk must return cache copy
|
82
|
+
@driver.int "int_per_get_res", [
|
83
|
+
Integer,
|
84
|
+
"local1",
|
85
|
+
"test",
|
86
|
+
nil
|
87
|
+
]
|
88
|
+
|
111
89
|
page = ctx.dump "page"
|
112
90
|
page2 = ctx.dump "page2"
|
113
91
|
vm_cache = ctx.dump("vm_cache")
|
@@ -460,26 +460,22 @@ RSpec.describe "kern:sockio_pager" do
|
|
460
460
|
|
461
461
|
//Drain queue
|
462
462
|
int_dispatch([]);
|
463
|
-
|
464
|
-
dump.vm_cache = vm_cache;
|
465
463
|
}
|
466
464
|
|
467
465
|
#Driver response
|
468
466
|
@driver.int "int_per_get_res", [
|
469
467
|
"vm",
|
470
468
|
"sockio",
|
471
|
-
"test"
|
472
|
-
|
469
|
+
"test",
|
470
|
+
nil
|
471
|
+
]
|
473
472
|
|
474
473
|
#The vm_cache should now contain an entry for the page
|
475
|
-
expect(dump
|
474
|
+
expect(ctx.dump("vm_cache")["sockio"]["test"]).not_to eq(nil)
|
476
475
|
|
477
476
|
@driver.ignore_up_to "if_sockio_send", 1
|
478
|
-
@driver.
|
479
|
-
|
480
|
-
"page_write",
|
481
|
-
dump["vm_cache"]["sockio"]["test"]
|
482
|
-
], 1
|
477
|
+
res = @driver.get "if_sockio_send", 1
|
478
|
+
expect(res[1]).to eq("write")
|
483
479
|
end
|
484
480
|
|
485
481
|
it "Does accept writes of pages that **do** currently exist in cache; they go into vm_cache commited" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.76
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -263,35 +263,35 @@ files:
|
|
263
263
|
- LICENSE
|
264
264
|
- README.md
|
265
265
|
- Rakefile
|
266
|
-
- app/drivers/
|
267
|
-
- app/drivers/
|
268
|
-
- app/drivers/
|
269
|
-
- app/drivers/
|
270
|
-
- app/drivers/
|
271
|
-
- app/drivers/
|
272
|
-
- app/drivers/
|
273
|
-
- app/drivers/
|
274
|
-
- app/drivers/
|
275
|
-
- app/drivers/
|
276
|
-
- app/drivers/
|
277
|
-
- app/drivers/
|
278
|
-
- app/drivers/
|
279
|
-
- app/drivers/
|
280
|
-
- app/drivers/
|
281
|
-
- app/drivers/
|
282
|
-
- app/drivers/
|
283
|
-
- app/drivers/
|
284
|
-
- app/drivers/
|
285
|
-
- app/drivers/
|
286
|
-
- app/drivers/
|
287
|
-
- app/drivers/
|
288
|
-
- app/drivers/
|
289
|
-
- app/drivers/
|
290
|
-
- app/drivers/
|
291
|
-
- app/drivers/
|
292
|
-
- app/drivers/
|
293
|
-
- app/drivers/
|
294
|
-
- app/drivers/
|
266
|
+
- app/drivers/chrome/README.md
|
267
|
+
- app/drivers/chrome/Rakefile
|
268
|
+
- app/drivers/chrome/build_context.rb
|
269
|
+
- app/drivers/chrome/cakery/spec.js.erb
|
270
|
+
- app/drivers/chrome/config.yml
|
271
|
+
- app/drivers/chrome/pipe.rb
|
272
|
+
- app/drivers/chrome/spec/config/config.js
|
273
|
+
- app/drivers/chrome/spec/init/qunit.js
|
274
|
+
- app/drivers/chrome/spec/spec/controller_debug_spec.js
|
275
|
+
- app/drivers/chrome/spec/spec/debug_spec.js
|
276
|
+
- app/drivers/chrome/spec/spec/dom_helpers_spec.js
|
277
|
+
- app/drivers/chrome/spec/spec/sel_scope_spec.js
|
278
|
+
- app/drivers/chrome/spec/spec/vars_spec.js
|
279
|
+
- app/drivers/chrome/src/bench.js
|
280
|
+
- app/drivers/chrome/src/config0.js
|
281
|
+
- app/drivers/chrome/src/controller.js
|
282
|
+
- app/drivers/chrome/src/debug.js
|
283
|
+
- app/drivers/chrome/src/dispatch.js
|
284
|
+
- app/drivers/chrome/src/event.js
|
285
|
+
- app/drivers/chrome/src/helpers.js
|
286
|
+
- app/drivers/chrome/src/net.js
|
287
|
+
- app/drivers/chrome/src/persist.js
|
288
|
+
- app/drivers/chrome/src/segue.js
|
289
|
+
- app/drivers/chrome/src/sockio.js
|
290
|
+
- app/drivers/chrome/src/timer.js
|
291
|
+
- app/drivers/chrome/src/ui.js
|
292
|
+
- app/drivers/chrome/src/vendor/jquery.js
|
293
|
+
- app/drivers/chrome/src/vendor/socket.io.js
|
294
|
+
- app/drivers/chrome/src/vendor/store2.js
|
295
295
|
- app/kern/callout.js
|
296
296
|
- app/kern/controller.js
|
297
297
|
- app/kern/crc32.js
|
@@ -407,7 +407,6 @@ files:
|
|
407
407
|
- spec/etc/service_compiler/service1.rb
|
408
408
|
- spec/etc/service_compiler/service3.rb
|
409
409
|
- spec/etc/service_compiler/service_bad_type.rb
|
410
|
-
- spec/etc/services_compiler_spec.rb
|
411
410
|
- spec/etc/transition_compiler/trans0.rb
|
412
411
|
- spec/etc/transition_complier_spec.rb
|
413
412
|
- spec/etc/user_compiler/controller0.rb
|
@@ -415,7 +414,6 @@ files:
|
|
415
414
|
- spec/etc/user_compiler/controller0bg.rb
|
416
415
|
- spec/etc/user_compiler/controller0timer.rb
|
417
416
|
- spec/etc/user_compiler/data.js
|
418
|
-
- spec/etc/user_compiler_spec.rb
|
419
417
|
- spec/iface/driver/assets/debug_socket_server.js
|
420
418
|
- spec/iface/driver/assets/node_modules/socket.io/.npmignore
|
421
419
|
- spec/iface/driver/assets/node_modules/socket.io/.travis.yml
|
@@ -1356,7 +1354,6 @@ test_files:
|
|
1356
1354
|
- spec/etc/service_compiler/service1.rb
|
1357
1355
|
- spec/etc/service_compiler/service3.rb
|
1358
1356
|
- spec/etc/service_compiler/service_bad_type.rb
|
1359
|
-
- spec/etc/services_compiler_spec.rb
|
1360
1357
|
- spec/etc/transition_compiler/trans0.rb
|
1361
1358
|
- spec/etc/transition_complier_spec.rb
|
1362
1359
|
- spec/etc/user_compiler/controller0.rb
|
@@ -1364,7 +1361,6 @@ test_files:
|
|
1364
1361
|
- spec/etc/user_compiler/controller0bg.rb
|
1365
1362
|
- spec/etc/user_compiler/controller0timer.rb
|
1366
1363
|
- spec/etc/user_compiler/data.js
|
1367
|
-
- spec/etc/user_compiler_spec.rb
|
1368
1364
|
- spec/iface/driver/assets/debug_socket_server.js
|
1369
1365
|
- spec/iface/driver/assets/node_modules/socket.io/.npmignore
|
1370
1366
|
- spec/iface/driver/assets/node_modules/socket.io/.travis.yml
|
@@ -1,68 +0,0 @@
|
|
1
|
-
Dir.chdir File.join File.dirname(__FILE__), '../../'
|
2
|
-
require './lib/flok'
|
3
|
-
require './spec/env/etc'
|
4
|
-
|
5
|
-
RSpec.describe "lib/services_compiler" do
|
6
|
-
#Return a v8 instance of a compiled js file
|
7
|
-
def compile fn, config
|
8
|
-
compiler = Flok::ServicesCompiler
|
9
|
-
js_src(fn)
|
10
|
-
js_res = compiler.compile(js_src(fn), js_src(config))
|
11
|
-
ctx = V8::Context.new
|
12
|
-
ctx.eval js_res
|
13
|
-
|
14
|
-
return ctx, js_res
|
15
|
-
end
|
16
|
-
|
17
|
-
#Get the source for a file in ./service_compiler/*.rb
|
18
|
-
def js_src fn
|
19
|
-
Dir.chdir File.join(File.dirname(__FILE__), "service_compiler") do
|
20
|
-
return File.read(fn+'.rb')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "Does fail to compile a controller with a non-existant type" do
|
25
|
-
expect { compile "service_bad_type" }.to raise_exception
|
26
|
-
end
|
27
|
-
|
28
|
-
it "Can call compile method and get a copy of all the functions" do
|
29
|
-
ctx, _ = compile "service0", "config0b"
|
30
|
-
|
31
|
-
#on_wakeup
|
32
|
-
res = ctx.eval("test_on_wakeup")
|
33
|
-
expect(res).not_to eq(nil)
|
34
|
-
|
35
|
-
#on_sleep
|
36
|
-
res = ctx.eval("test_on_sleep")
|
37
|
-
expect(res).not_to eq(nil)
|
38
|
-
|
39
|
-
#on_connect
|
40
|
-
res = ctx.eval("test_on_connect");
|
41
|
-
expect(res).not_to eq(nil)
|
42
|
-
|
43
|
-
#on_disconnect
|
44
|
-
res = ctx.eval("test_on_disconnect")
|
45
|
-
expect(res).not_to eq(nil)
|
46
|
-
|
47
|
-
#on_event
|
48
|
-
res = ctx.eval("test_on_hello");
|
49
|
-
expect(res).not_to eq(nil)
|
50
|
-
|
51
|
-
#on_handle_timer_events
|
52
|
-
res = ctx.eval("test_handle_timer_events");
|
53
|
-
expect(res).not_to eq(nil)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "Can call compile method with options" do
|
57
|
-
ctx, js = compile "service1", "config2"
|
58
|
-
expect(js).to include("23rntoheuh3nthoeunthn23th");
|
59
|
-
end
|
60
|
-
|
61
|
-
#If SEND works, then all kernel macros should work
|
62
|
-
it "Can compile with a SEND macro" do
|
63
|
-
ctx, src = compile "service3", "config0b"
|
64
|
-
|
65
|
-
expect(src).not_to include("SEND")
|
66
|
-
expect(src).to include("_q.push")
|
67
|
-
end
|
68
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
#Load all the test files in ./user_compiler/*.js
|
2
|
-
|
3
|
-
Dir.chdir File.join File.dirname(__FILE__), '../../'
|
4
|
-
require './lib/flok'
|
5
|
-
|
6
|
-
|
7
|
-
#Testing the compilation of controller/action user files into javascript counterparts
|
8
|
-
RSpec.describe "User compiler" do
|
9
|
-
#Return a v8 instance of a compiled js file
|
10
|
-
def compile fn
|
11
|
-
compiler = Flok::UserCompiler
|
12
|
-
js_src(fn)
|
13
|
-
js_res = compiler.compile(js_src(fn))
|
14
|
-
File.write "/Users/Seo/Desktop/js_src.js", js_res
|
15
|
-
ctx = V8::Context.new
|
16
|
-
ctx.eval js_res
|
17
|
-
return ctx, js_res
|
18
|
-
end
|
19
|
-
|
20
|
-
#Get the source for a file in ./user_compiler/*.rb
|
21
|
-
def js_src fn
|
22
|
-
Dir.chdir File.join(File.dirname(__FILE__), "user_compiler") do
|
23
|
-
return File.read(fn+'.rb')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "Can load the ruby module" do
|
28
|
-
compiler = Flok::UserCompiler
|
29
|
-
end
|
30
|
-
|
31
|
-
it "Can compile a controller and give up the root
|
32
|
-
iew" do
|
33
|
-
ctx, js_src = compile "controller0"
|
34
|
-
root_view = ctx.eval "ctable.my_controller.root_view"
|
35
|
-
expect(root_view).to eq("my_controller")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "Can compile a controller and contain a list of actions" do
|
39
|
-
ctx, js_src = compile "controller0"
|
40
|
-
actions = ctx.eval "Object.keys(ctable.my_controller.actions).length"
|
41
|
-
expect(actions).to eq(1)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "Can compile a controller and contain an __init__ function" do
|
45
|
-
ctx, js_src = compile "controller0"
|
46
|
-
actions = ctx.eval "ctable.my_controller.__init__"
|
47
|
-
expect(actions).not_to eq(nil)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "Can compile a controller with an action that contains an on_entry" do
|
51
|
-
ctx, js_src = compile "controller0"
|
52
|
-
on_entry = ctx.eval "ctable.my_controller.actions.my_action.on_entry"
|
53
|
-
expect(on_entry).not_to eq(nil)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "Can compile a controller with an action that does not contains an on_entry" do
|
57
|
-
ctx, js_src = compile "controller0b"
|
58
|
-
on_entry = ctx.eval "ctable.my_controller.actions.my_action.on_entry"
|
59
|
-
expect(on_entry).not_to eq(nil)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "Can compile a controller with a global on_entry" do
|
63
|
-
ctx, js_src = compile "controller0bg"
|
64
|
-
on_entry = ctx.eval "ctable.my_controller.on_entry"
|
65
|
-
expect(js_src).to include("global_on_entry")
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
it "on_entry controller has more code than non on_entry controller" do
|
70
|
-
ctx, js_src = compile "controller0"
|
71
|
-
on_entry = ctx.eval "ctable.my_controller.actions.my_action.on_entry"
|
72
|
-
|
73
|
-
ctx2, js_src = compile "controller0b"
|
74
|
-
on_entry2 = ctx2.eval "ctable.my_controller.actions.my_action.on_entry"
|
75
|
-
expect(on_entry2.to_s.length).to be < on_entry.to_s.length
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
it "Can compile a controller with an action that contains the name" do
|
80
|
-
ctx, js_src = compile "controller0"
|
81
|
-
on_entry = ctx.eval "ctable.my_controller.name"
|
82
|
-
expect(on_entry).to eq("my_controller")
|
83
|
-
end
|
84
|
-
|
85
|
-
it "Can compile a controller with an action that contains an event that responds to hello" do
|
86
|
-
ctx, js_src = compile "controller0"
|
87
|
-
hello_event_function = ctx.eval "ctable.my_controller.actions.my_action.handlers.hello"
|
88
|
-
expect(hello_event_function).not_to eq(nil)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "Can compile a controller with spot names" do
|
92
|
-
ctx, js_src = compile "controller0"
|
93
|
-
spot_names = JSON.parse(ctx.eval "JSON.stringify(ctable.my_controller.spots)")
|
94
|
-
expect(spot_names).to include "hello"
|
95
|
-
expect(spot_names).to include "world"
|
96
|
-
expect(spot_names).to include "main" #Should be added by default
|
97
|
-
end
|
98
|
-
|
99
|
-
it "Can compile a controller with an action containing a timer and set the appropriate every_handlers key" do
|
100
|
-
ctx, js_src = compile "controller0timer"
|
101
|
-
|
102
|
-
function_names = JSON.parse(ctx.eval "JSON.stringify(Object.keys(ctable.my_controller.actions.my_action.handlers))")
|
103
|
-
expect(function_names).to include("hello")
|
104
|
-
expect(function_names.detect{|e| e =~ /_sec_/}).not_to eq(nil)
|
105
|
-
end
|
106
|
-
end
|