flok 0.0.36 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/app/drivers/chrome/build_context.rb +1 -1
- data/app/drivers/chrome/config.yml +10 -0
- data/app/drivers/chrome/pipe.rb +24 -1
- data/app/drivers/chrome/src/persist.js +29 -0
- data/app/drivers/chrome/src/sockio.js +3 -1
- data/app/drivers/chrome/src/vendor/store2.js +3 -0
- data/app/kern/callout.js +55 -0
- data/app/kern/controller.js +3 -0
- data/app/kern/crc32.js +22 -0
- data/app/kern/dispatch.js +16 -0
- data/app/kern/mod/event.js +3 -0
- data/app/kern/mod/persist.js +1 -0
- data/app/kern/mod/timer.js +5 -0
- data/app/kern/pagers/mem_pager.js +2 -0
- data/app/kern/pagers/sockio_pager.js +66 -0
- data/app/kern/pagers/spec0.js +35 -0
- data/app/kern/pagers/spec1.js +24 -0
- data/app/kern/pagers/spec2.js +31 -0
- data/app/kern/services/test.rb +7 -0
- data/app/kern/services/vm.rb +141 -0
- data/app/kern/spec_helper.js +5 -0
- data/bin/flok +27 -5
- data/docs/callout.md +8 -0
- data/docs/client_api.md +1 -1
- data/docs/compilation.md +14 -8
- data/docs/controllers.md +2 -1
- data/docs/datatypes.md +3 -1
- data/docs/environmentals.md +6 -0
- data/docs/interactive.md +6 -1
- data/docs/kernel_api.md +3 -0
- data/docs/mod/event.md +5 -1
- data/docs/mod/persist.md +14 -31
- data/docs/mod/timer.md +4 -2
- data/docs/project.md +16 -5
- data/docs/scheduling.md +1 -0
- data/docs/services.md +141 -56
- data/docs/services/vm.md +128 -0
- data/docs/services/vm/pagers.md +46 -0
- data/lib/flok/build.rb +11 -16
- data/lib/flok/platform.rb +29 -6
- data/lib/flok/project_template/app/scripts/script.js +3 -0
- data/lib/flok/project_template/app/services/service.rb +1 -0
- data/lib/flok/project_template/config/config.yml +1 -0
- data/lib/flok/project_template/config/platforms/chrome/config.yml +1 -0
- data/lib/flok/project_template/config/services.rb +1 -0
- data/lib/flok/service_compiler_templates/services.js.erb +78 -9
- data/lib/flok/services_compiler.rb +117 -20
- data/lib/flok/user_compiler.rb +14 -6
- data/lib/flok/user_compiler_templates/ctable.js.erb +10 -0
- data/lib/flok/version.rb +1 -1
- data/spec/env/etc.rb +1 -1
- data/spec/env/global.rb +2 -0
- data/spec/env/iface.rb +20 -4
- data/spec/env/kern.rb +8 -3
- data/spec/etc/cli_spec.rb +319 -165
- data/spec/etc/lib/assets/config.yml +3 -0
- data/spec/etc/lib/platform_spec.rb +14 -10
- data/spec/etc/lib/project_spec.rb +22 -0
- data/spec/etc/service_compiler/config0.rb +1 -0
- data/spec/etc/service_compiler/config1.rb +1 -0
- data/spec/etc/service_compiler/config2.rb +3 -0
- data/spec/etc/service_compiler/service0.rb +22 -6
- data/spec/etc/service_compiler/service1.rb +26 -0
- data/spec/etc/service_compiler/service_bad_type.rb +20 -0
- data/spec/etc/services_compiler_spec.rb +35 -16
- data/spec/etc/user_compiler/data.js +2 -0
- data/spec/etc/user_compiler_spec.rb +7 -1
- data/spec/iface/driver/persist_spec.rb +106 -0
- data/spec/iface/driver/pipe_spec.rb +5 -0
- data/spec/iface/kern/ping_spec.rb +4 -3
- data/spec/kern/assets/blank.rb +0 -0
- data/spec/kern/assets/service0.rb +24 -0
- data/spec/kern/assets/service1.rb +22 -0
- data/spec/kern/assets/service2.rb +27 -0
- data/spec/kern/assets/service_config0.rb +2 -0
- data/spec/kern/assets/service_config1.rb +2 -0
- data/spec/kern/assets/service_controller0.rb +13 -0
- data/spec/kern/assets/service_controller1.rb +32 -0
- data/spec/kern/assets/service_controller2.rb +38 -0
- data/spec/kern/assets/service_controller3.rb +38 -0
- data/spec/kern/assets/vm/config0.rb +2 -0
- data/spec/kern/assets/vm/config1.rb +12 -0
- data/spec/kern/assets/vm/config2.rb +12 -0
- data/spec/kern/assets/vm/config3.rb +12 -0
- data/spec/kern/assets/vm/controller0.rb +8 -0
- data/spec/kern/assets/vm/controller1.rb +18 -0
- data/spec/kern/assets/vm/controller2.rb +18 -0
- data/spec/kern/assets/vm/controller3.rb +20 -0
- data/spec/kern/assets/vm/controller4.rb +22 -0
- data/spec/kern/assets/vm/controller5.rb +22 -0
- data/spec/kern/assets/vm/controller6.rb +21 -0
- data/spec/kern/assets/vm/service0.rb +24 -0
- data/spec/kern/assets/vm/service_controller0.rb +7 -0
- data/spec/kern/callout_spec.rb +153 -0
- data/spec/kern/functions_spec.rb +29 -0
- data/spec/kern/service_controller_spec.rb +213 -0
- data/spec/kern/vm_service_spec.rb +195 -0
- metadata +98 -12
- data/app/kern/services/rest.rb +0 -310
- data/app/kern/services/timer.rb +0 -30
- data/docs/services/timer.md +0 -21
- data/spec/kern/assets/rest_service.rb +0 -20
- data/spec/kern/assets/timer_service.rb +0 -19
- data/spec/kern/timer_service_spec.rb +0 -40
data/spec/env/etc.rb
CHANGED
data/spec/env/global.rb
ADDED
data/spec/env/iface.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require './spec/env/global.rb'
|
1
2
|
require 'json'
|
2
3
|
require './spec/lib/rspec_extensions'
|
3
4
|
require 'open3'
|
@@ -11,7 +12,7 @@ shared_context "iface:kern" do
|
|
11
12
|
before(:each) do
|
12
13
|
@pipe = IO.popen("rake pipe:kern", "r+")
|
13
14
|
@pid = @pipe.pid
|
14
|
-
@mods = Flok::Platform.mods ENV['
|
15
|
+
@mods = Flok::Platform.mods ENV['FLOK_ENV']
|
15
16
|
end
|
16
17
|
|
17
18
|
after(:each) do
|
@@ -27,7 +28,7 @@ shared_context "iface:driver" do
|
|
27
28
|
before(:each) do
|
28
29
|
@pipe = IO.popen("rake pipe:driver", "r+")
|
29
30
|
@pid = @pipe.pid
|
30
|
-
@mods = Flok::Platform.mods ENV['
|
31
|
+
@mods = Flok::Platform.mods ENV['FLOK_ENV']
|
31
32
|
end
|
32
33
|
|
33
34
|
after(:each) do
|
@@ -43,11 +44,11 @@ end
|
|
43
44
|
|
44
45
|
#Get a list of modules based on the platform and environment
|
45
46
|
def mods
|
46
|
-
Flok::Platform.mods ENV['
|
47
|
+
Flok::Platform.mods ENV['FLOK_ENV']
|
47
48
|
end
|
48
49
|
|
49
50
|
def config_yml
|
50
|
-
Flok::Platform.config_yml ENV['
|
51
|
+
Flok::Platform.config_yml ENV['FLOK_ENV']
|
51
52
|
end
|
52
53
|
|
53
54
|
#Ensure this platform supports a module, or skip the test (used inside before(:each) describe block, or `it` block)
|
@@ -62,3 +63,18 @@ def settings_dep key, value
|
|
62
63
|
raise "#{ENV["PLATFORM"].inspect} does not support #{key.inspect} configuration in config.yml" unless config_yml.include? key
|
63
64
|
skip "#{ENV["PLATFORM"].inspect} #{key.inspect} is not #{value.inspect} in config.yml; it is #{config_yml[key].inspect}" unless value == config_yml[key]
|
64
65
|
end
|
66
|
+
|
67
|
+
#Restart the driver but persist any data that was saved
|
68
|
+
def restart_driver_but_persist
|
69
|
+
#Ensure the pipe is fully drained before sending RESTART
|
70
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
71
|
+
|
72
|
+
@pipe.puts "RESTART"
|
73
|
+
begin
|
74
|
+
Timeout::timeout(10) do
|
75
|
+
expect(@pipe.readline).to eq("RESTART OK\n")
|
76
|
+
end
|
77
|
+
rescue Timeout::Error
|
78
|
+
raise "Tried to restart driver but timed out waiting for 'RESTART OK'"
|
79
|
+
end
|
80
|
+
end
|
data/spec/env/kern.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require './spec/env/global.rb'
|
1
2
|
require 'therubyracer'
|
2
3
|
require './spec/lib/temp_dir'
|
3
4
|
|
@@ -20,21 +21,25 @@ shared_context "kern" do
|
|
20
21
|
bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
|
21
22
|
|
22
23
|
#Now execute the command with a set of arguments
|
23
|
-
system("#{bin_path} #{args}")
|
24
|
+
return system("#{bin_path} #{args}")
|
24
25
|
end
|
25
26
|
|
26
27
|
#Create a new flok project, add the given user_file (an .rb file containing controllers, etc.)
|
27
28
|
#and then retrieve a V8 instance from this project's application_user.js
|
28
|
-
def flok_new_user user_controllers_src
|
29
|
+
def flok_new_user user_controllers_src, service_config=nil, service_src=nil
|
29
30
|
temp_dir = new_temp_dir
|
30
31
|
Dir.chdir temp_dir do
|
31
32
|
flok "new test"
|
32
33
|
Dir.chdir "test" do
|
33
34
|
#Put controllers in
|
34
35
|
File.write './app/controllers/user_controller.rb', user_controllers_src
|
36
|
+
File.write './config/services.rb', service_config if service_config
|
37
|
+
File.write './app/services/service0.rb', service_src if service_src
|
35
38
|
|
36
39
|
#Build
|
37
|
-
flok "build" #Will generate drivers/ but we will ignore that
|
40
|
+
unless flok "build" #Will generate drivers/ but we will ignore that
|
41
|
+
raise "Build failed"
|
42
|
+
end
|
38
43
|
|
39
44
|
#Execute
|
40
45
|
@driver = FakeDriverContext.new
|
data/spec/etc/cli_spec.rb
CHANGED
@@ -35,69 +35,124 @@ def flok_new
|
|
35
35
|
end
|
36
36
|
|
37
37
|
RSpec.describe "CLI" do
|
38
|
-
|
38
|
+
before(:all) do
|
39
39
|
#Uninstall old gems and install the current development gem
|
40
40
|
system("rake gem:install")
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
43
|
+
#it "Can be executed via bundle exec" do flok_new do
|
44
|
+
#flok "build"
|
45
|
+
#end
|
46
|
+
#end
|
47
|
+
|
48
|
+
##When this sets FLOK_CONFIG, the defines is added to the project config.yml
|
49
|
+
##to show spec_helper_defines_spec_test. This text should show up in the final
|
50
|
+
##source code
|
51
|
+
#it "Does set the FLOK_CONFIG to the correct file based on PLATFORM" do
|
52
|
+
#flok_new do
|
53
|
+
##Set spec_test in project configuration
|
54
|
+
#config_yml = YAML.load_file("./config/platforms/#{ENV['PLATFORM']}/config.yml")
|
55
|
+
#config_yml["DEBUG"]["defines"] = ["spec_test"]
|
56
|
+
#File.write("./config/platforms/#{ENV['PLATFORM']}/config.yml", config_yml.to_yaml)
|
57
|
+
|
58
|
+
##Now commit a build
|
59
|
+
#flok "build"
|
60
|
+
|
61
|
+
##Now read the application_user file, it should contain the string located in `./app/kern/spec_helper.js`
|
62
|
+
##that will only show if the correct defines is set
|
63
|
+
#application_user = File.read("./products/#{ENV['PLATFORM']}/application_user.js")
|
64
|
+
#expect(application_user).to include("spec_helper_defines_spec_test")
|
65
|
+
#end
|
66
|
+
#end
|
67
|
+
|
68
|
+
#it "Can create a new project with correct directories" do
|
69
|
+
#flok_new do
|
70
|
+
##Should include all entities in the project template with the exception
|
71
|
+
##of erb extenseded entities (which will still be included, but they each
|
72
|
+
##will not have the erb ending
|
73
|
+
#template_nodes = nil
|
74
|
+
#Dir.chdir File.join(File.dirname(__FILE__), "../../lib/flok/project_template") do
|
75
|
+
#template_nodes = Dir["**/*"].map{|e| e.gsub(/\.erb$/i, "")}
|
76
|
+
#end
|
77
|
+
#new_proj_nodes = Dir["**/*"]
|
78
|
+
#expect(new_proj_nodes.sort).to eq(template_nodes.sort)
|
79
|
+
|
80
|
+
#expect(files).to include("Gemfile")
|
81
|
+
#end
|
82
|
+
#end
|
83
|
+
|
84
|
+
#it "Can build a project with every type of platform" do
|
85
|
+
#platform = ENV['PLATFORM']
|
86
|
+
#flok_new do
|
87
|
+
##Build a new project
|
88
|
+
#flok "build"
|
89
|
+
|
90
|
+
##Check it's products directory
|
91
|
+
#expect(dirs).to include "products"
|
92
|
+
#Dir.chdir "products" do
|
93
|
+
##Has a platform folder
|
94
|
+
#expect(dirs).to include platform
|
95
|
+
#Dir.chdir platform do
|
96
|
+
##Has an application_user.js file
|
97
|
+
#expect(files).to include "application_user.js"
|
98
|
+
|
99
|
+
##The application_user.js contains both the glob/application.js and the glob/user_compiler.js
|
100
|
+
#glob_application_js = File.read('glob/application.js')
|
101
|
+
#glob_user_compiler_js = File.read('glob/user_compiler.js')
|
102
|
+
#application_user_js = File.read('application_user.js')
|
103
|
+
#expect(application_user_js).to include(glob_application_js)
|
104
|
+
#expect(application_user_js).to include(glob_user_compiler_js)
|
105
|
+
|
106
|
+
##Contains the same files as the kernel in the drivers directory
|
107
|
+
#expect(dirs).to include "drivers"
|
108
|
+
#end
|
109
|
+
#end
|
110
|
+
#end
|
111
|
+
#end
|
112
|
+
|
113
|
+
#it "Can build a project with a controller file for each platform" do
|
114
|
+
##Compile and then return the length of the application_user.js file
|
115
|
+
#def compile_with_file path=nil
|
116
|
+
##Custom controller to test source with
|
117
|
+
#controller_src = File.read(path) if path
|
118
|
+
#flok_new do
|
119
|
+
#File.write "./app/controllers/controller0.rb", controller_src if path
|
120
|
+
|
121
|
+
##Build a new project
|
122
|
+
#flok "build"
|
123
|
+
|
124
|
+
##Check it's products directory
|
125
|
+
#Dir.chdir "products" do
|
126
|
+
##Has a platform folder
|
127
|
+
#Dir.chdir @platform do
|
128
|
+
#glob_application_js = File.read('glob/application.js')
|
129
|
+
#glob_user_compiler_js = File.read('glob/user_compiler.js')
|
130
|
+
#application_user_js = File.read('application_user.js')
|
131
|
+
|
132
|
+
#return application_user_js.split("\n").count
|
133
|
+
#end
|
134
|
+
#end
|
135
|
+
#end
|
136
|
+
#end
|
137
|
+
|
138
|
+
#platform = ENV['PLATFORM']
|
139
|
+
#@platform = platform
|
140
|
+
#controller_rb = File.read('./spec/etc/user_compiler/controller0.rb')
|
141
|
+
|
142
|
+
##The file with content should be longer when compiled into the flat application_user.js
|
143
|
+
#len_with_content = compile_with_file "./spec/etc/user_compiler/controller0.rb"
|
144
|
+
#len_no_content = compile_with_file
|
145
|
+
|
146
|
+
#expect(len_no_content).to be < len_with_content
|
147
|
+
#end
|
148
|
+
|
149
|
+
it "Can build a project with a javascript file for each platform" do
|
95
150
|
#Compile and then return the length of the application_user.js file
|
96
151
|
def compile_with_file path=nil
|
97
152
|
#Custom controller to test source with
|
98
153
|
controller_src = File.read(path) if path
|
99
154
|
flok_new do
|
100
|
-
File.write "./app/
|
155
|
+
File.write "./app/scripts/data.js", controller_src if path
|
101
156
|
|
102
157
|
#Build a new project
|
103
158
|
flok "build"
|
@@ -106,8 +161,6 @@ it "Can create a new project with correct directories" do
|
|
106
161
|
Dir.chdir "products" do
|
107
162
|
#Has a platform folder
|
108
163
|
Dir.chdir @platform do
|
109
|
-
glob_application_js = File.read('glob/application.js')
|
110
|
-
glob_user_compiler_js = File.read('glob/user_compiler.js')
|
111
164
|
application_user_js = File.read('application_user.js')
|
112
165
|
|
113
166
|
return application_user_js.split("\n").count
|
@@ -118,119 +171,220 @@ it "Can create a new project with correct directories" do
|
|
118
171
|
|
119
172
|
platform = ENV['PLATFORM']
|
120
173
|
@platform = platform
|
121
|
-
controller_rb = File.read('./spec/etc/user_compiler/controller0.rb')
|
122
|
-
|
123
174
|
#The file with content should be longer when compiled into the flat application_user.js
|
124
|
-
len_with_content = compile_with_file "./spec/etc/user_compiler/
|
175
|
+
len_with_content = compile_with_file "./spec/etc/user_compiler/data.js"
|
125
176
|
len_no_content = compile_with_file
|
126
177
|
|
127
178
|
expect(len_no_content).to be < len_with_content
|
128
179
|
end
|
129
180
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
#
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
File.write "./
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
#
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
181
|
+
#it "Can build a project with an instantized service from the kernel ./app/kern/services folder" do
|
182
|
+
##Compiled to config/services.rb
|
183
|
+
#def compile_with_file path=nil
|
184
|
+
#config_src = File.read(path) if path
|
185
|
+
#flok_new do
|
186
|
+
#File.write "./config/services.rb", config_src if path
|
187
|
+
|
188
|
+
##Build a new project
|
189
|
+
#flok "build"
|
190
|
+
|
191
|
+
##Check it's products directory
|
192
|
+
#Dir.chdir "products" do
|
193
|
+
##Has a platform folder
|
194
|
+
#Dir.chdir @platform do
|
195
|
+
#application_user_js = File.read('application_user.js')
|
196
|
+
|
197
|
+
#return application_user_js.split("\n").count
|
198
|
+
#end
|
199
|
+
#end
|
200
|
+
#end
|
201
|
+
#end
|
202
|
+
|
203
|
+
#platform = ENV['PLATFORM']
|
204
|
+
#@platform = platform
|
205
|
+
#config_rb = File.read('./spec/etc/service_compiler/config0.rb')
|
206
|
+
|
207
|
+
##The file with content should be longer when compiled into the flat application_user.js
|
208
|
+
#len_with_content = compile_with_file "./spec/etc/service_compiler/config0.rb"
|
209
|
+
#len_no_content = compile_with_file
|
210
|
+
|
211
|
+
#expect(len_no_content).to be < len_with_content
|
212
|
+
#end
|
213
|
+
|
214
|
+
#it "Can build a project with an instantized service from the user ./app/services folder" do
|
215
|
+
##Compiled to config/services.rb
|
216
|
+
#def compile_with_file config_path=nil, src_path=nil
|
217
|
+
#config_src = File.read(config_path) if config_path
|
218
|
+
#src = File.read(src_path) if src_path
|
219
|
+
#flok_new do
|
220
|
+
#File.write "./config/services.rb", config_src if config_path
|
221
|
+
#File.write "./app/services/service0.rb", src if src_path
|
222
|
+
|
223
|
+
##Build a new project
|
224
|
+
#flok "build"
|
225
|
+
|
226
|
+
##Check it's products directory
|
227
|
+
#Dir.chdir "products" do
|
228
|
+
##Has a platform folder
|
229
|
+
#Dir.chdir @platform do
|
230
|
+
#application_user_js = File.read('application_user.js')
|
231
|
+
|
232
|
+
#return application_user_js.split("\n").count
|
233
|
+
#end
|
234
|
+
#end
|
235
|
+
#end
|
236
|
+
#end
|
237
|
+
|
238
|
+
#platform = ENV['PLATFORM']
|
239
|
+
#@platform = platform
|
240
|
+
#config_rb = File.read('./spec/etc/service_compiler/config1.rb')
|
241
|
+
#service_rb = File.read('./spec/etc/service_compiler/service0.rb')
|
242
|
+
|
243
|
+
##The file with content should be longer when compiled into the flat application_user.js
|
244
|
+
#len_with_content = compile_with_file "./spec/etc/service_compiler/config1.rb", "./spec/etc/service_compiler/service0.rb"
|
245
|
+
#len_no_content = compile_with_file
|
246
|
+
|
247
|
+
#expect(len_no_content).to be < len_with_content
|
248
|
+
#end
|
249
|
+
|
250
|
+
#it "Can build a project with an instantized service from the user ./app/services folder and this has a function of the service" do
|
251
|
+
##Compiled to config/services.rb
|
252
|
+
#def compile_with_file config_path=nil, src_path=nil
|
253
|
+
#config_src = File.read(config_path) if config_path
|
254
|
+
#src = File.read(src_path) if src_path
|
255
|
+
#flok_new do
|
256
|
+
#File.write "./config/services.rb", config_src if config_path
|
257
|
+
#File.write "./app/services/service0.rb", src if src_path
|
258
|
+
|
259
|
+
##Build a new project
|
260
|
+
#flok "build"
|
261
|
+
|
262
|
+
##Check it's products directory
|
263
|
+
#Dir.chdir "products" do
|
264
|
+
##Has a platform folder
|
265
|
+
#Dir.chdir @platform do
|
266
|
+
#application_user_js = File.read('application_user.js')
|
267
|
+
|
268
|
+
#return application_user_js
|
269
|
+
#end
|
270
|
+
#end
|
271
|
+
#end
|
272
|
+
#end
|
273
|
+
|
274
|
+
#platform = ENV['PLATFORM']
|
275
|
+
#@platform = platform
|
276
|
+
#config_rb = File.read('./spec/etc/service_compiler/config1.rb')
|
277
|
+
#service_rb = File.read('./spec/etc/service_compiler/service0.rb')
|
278
|
+
|
279
|
+
##The file with content should be longer when compiled into the flat application_user.js
|
280
|
+
#res = compile_with_file "./spec/etc/service_compiler/config1.rb", "./spec/etc/service_compiler/service0.rb"
|
281
|
+
#expect(res).to include("function blah_on_wakeup()")
|
282
|
+
#end
|
283
|
+
|
284
|
+
#include SpecHelpers
|
285
|
+
#it "server does build project when first run" do
|
286
|
+
#platform = ENV['PLATFORM']
|
287
|
+
#flok_new do
|
288
|
+
##Now execute the command with a set of arguments
|
289
|
+
#sh2("bundle exec flok server", /BUILD RAN/) do |inp, out|
|
290
|
+
##The server should always trigger a build on it's first run
|
291
|
+
#expect(dirs).to include "products"
|
292
|
+
#Dir.chdir "products" do
|
293
|
+
##Has a platform folder
|
294
|
+
#expect(dirs).to include platform
|
295
|
+
#Dir.chdir platform do
|
296
|
+
##Has an application_user.js file
|
297
|
+
#expect(files).to include "application_user.js"
|
298
|
+
|
299
|
+
##The application_user.js contains both the glob/application.js and the glob/user_compiler.js
|
300
|
+
#glob_application_js = File.read('glob/application.js')
|
301
|
+
#glob_user_compiler_js = File.read('glob/user_compiler.js')
|
302
|
+
#application_user_js = File.read('application_user.js')
|
303
|
+
#expect(application_user_js).to include(glob_application_js)
|
304
|
+
#expect(application_user_js).to include(glob_user_compiler_js)
|
305
|
+
|
306
|
+
##Contains the same files as the kernel in the drivers directory
|
307
|
+
#expect(dirs).to include "drivers"
|
308
|
+
#end
|
309
|
+
#end
|
310
|
+
#end
|
311
|
+
#end
|
312
|
+
#end
|
313
|
+
|
314
|
+
#it "server does rebuild project when a file is added" do
|
315
|
+
#platform = ENV['PLATFORM']
|
316
|
+
#flok_new do
|
317
|
+
##Now execute the command with a set of arguments
|
318
|
+
#sh2("bundle exec flok server", /BUILD RAN/) do |inp, out|
|
319
|
+
##Get the original build
|
320
|
+
#application_user_js = File.read("products/#{platform}/application_user.js")
|
321
|
+
|
322
|
+
##Now add a file
|
323
|
+
#File.write "./app/controllers/test2.rb", %{
|
324
|
+
#controller "my_controller" do
|
325
|
+
#action "my_action" do
|
326
|
+
#on_entry %{
|
327
|
+
#}
|
328
|
+
#end
|
329
|
+
#end
|
330
|
+
#}
|
331
|
+
|
332
|
+
##Wait for a rebuild
|
333
|
+
#expect(out).to readline_and_equal_x_within_y_seconds("BUILD RAN", 5.seconds)
|
334
|
+
|
335
|
+
##Get updated version
|
336
|
+
#application_user_js2 = File.read("products/#{platform}/application_user.js")
|
337
|
+
|
338
|
+
##Make sure the compiled file is different and it's somewhat valid (length > 30)
|
339
|
+
#expect(application_user_js2).not_to eq(application_user_js)
|
340
|
+
#expect(application_user_js2.length).to be > 30 #Magic 30 to avoid any problems
|
341
|
+
#end
|
342
|
+
#end
|
343
|
+
#end
|
344
|
+
|
345
|
+
#it "server does host products on localhost:9992" do
|
346
|
+
#platform = ENV['PLATFORM']
|
347
|
+
#flok_new do
|
348
|
+
##Now execute the command with a set of arguments
|
349
|
+
#sh2("bundle exec flok server", /BUILD RAN/) do |inp, out|
|
350
|
+
#real_application_user_js = File.read("products/#{platform}/application_user.js")
|
351
|
+
|
352
|
+
##Grab the application_user.js file
|
353
|
+
#res = wget "http://localhost:9992/application_user.js"
|
354
|
+
#expect(res).not_to eq(nil)
|
355
|
+
#expect(res.length).not_to eq(0)
|
356
|
+
#expect(res).to eq(real_application_user_js)
|
357
|
+
#end
|
358
|
+
#end
|
359
|
+
#end
|
360
|
+
|
361
|
+
#it "server does host products on localhost:9992 and changes the products when the files change" do
|
362
|
+
#platform = ENV['PLATFORM']
|
363
|
+
#flok_new do
|
364
|
+
##Now execute the command with a set of arguments
|
365
|
+
#sh2("bundle exec flok server", /BUILD RAN/) do |inp, out|
|
366
|
+
##Get the original
|
367
|
+
#application_user_js = wget "http://localhost:9992/application_user.js"
|
368
|
+
|
369
|
+
##Now add a file
|
370
|
+
#File.write "./app/controllers/test2.rb", %{
|
371
|
+
#controller "my_controller" do
|
372
|
+
#action "my_action" do
|
373
|
+
#on_entry %{
|
374
|
+
#}
|
375
|
+
#end
|
376
|
+
#end
|
377
|
+
#}
|
378
|
+
##Wait for a rebuild
|
379
|
+
#expect(out).to readline_and_equal_x_within_y_seconds("BUILD RAN", 5.seconds)
|
380
|
+
|
381
|
+
##Grab new version
|
382
|
+
#application_user_js2 = wget "http://localhost:9992/application_user.js"
|
383
|
+
|
384
|
+
##Make sure the compiled file is different and it's longer
|
385
|
+
#expect(application_user_js2.length).to be > application_user_js.length
|
386
|
+
#expect(application_user_js2.length).to be > 30 #Make sure it's at least something
|
387
|
+
#end
|
388
|
+
#end
|
389
|
+
#end
|
236
390
|
end
|