flok 0.0.21 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +26 -1
- data/bin/flok +0 -10
- data/lib/flok/project_template/Gemfile.erb +1 -0
- data/lib/flok/project_template/Guardfile +7 -0
- data/lib/flok/version.rb +1 -1
- data/spec/etc/cli_spec.rb +204 -221
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36ee09730e9f19e332b7c1cee80be3b26bf5c11e
|
4
|
+
data.tar.gz: b1f842a2a19bea7cd6db737cd1a29e6813d35e08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb2aa688b989b5be991f43a8cdb7807c3d4878da48bf774f5b9bcbd66f99f3a65c817168f769ec52eaa09f2caeade4cdf368f801851c6226af9c48fce974938
|
7
|
+
data.tar.gz: ddf77bccde7a3972164670c058741dc68e552f185bf7f8db40c36e29f247c75191fa6b25471c1599aafce8f680bafd53aa0dd460d8e0057890e06db268a454c5
|
data/Rakefile
CHANGED
@@ -23,7 +23,7 @@ def upgrade_version
|
|
23
23
|
return new_version
|
24
24
|
end
|
25
25
|
|
26
|
-
task :push do
|
26
|
+
task 'gem:push' do
|
27
27
|
version = upgrade_version
|
28
28
|
`git add .`
|
29
29
|
`git commit -a -m 'gem #{version}'`
|
@@ -35,6 +35,31 @@ task :push do
|
|
35
35
|
`rm flok-#{version}.gem`
|
36
36
|
end
|
37
37
|
|
38
|
+
#Will build and install the development GEM
|
39
|
+
#but will not push it out or upgrade the version
|
40
|
+
#WARNING: It will also remove any copies of flok you currently
|
41
|
+
task 'gem:install' do
|
42
|
+
#Remove current version
|
43
|
+
$stderr.puts "Removing gem if necessary... This may give a warning but it's ok"
|
44
|
+
$stderr.puts "------------------------------------------------------"
|
45
|
+
system('gem uninstall -xa flok')
|
46
|
+
$stderr.puts "------------------------------------------------------\n\n"
|
47
|
+
|
48
|
+
#Build gem
|
49
|
+
$stderr.puts "Attempting to build gem..."
|
50
|
+
$stderr.puts "------------------------------------------------------"
|
51
|
+
res = system('gem build flok.gemspec')
|
52
|
+
raise "Could not build gem" unless res
|
53
|
+
$stderr.puts "------------------------------------------------------\n\n"
|
54
|
+
|
55
|
+
#Install gem
|
56
|
+
$stderr.puts "Attempting to install gem..."
|
57
|
+
$stderr.puts "------------------------------------------------------"
|
58
|
+
res = system("gem install flok-#{Flok::VERSION}.gem")
|
59
|
+
raise "Could not install gem" unless res
|
60
|
+
$stderr.puts "------------------------------------------------------"
|
61
|
+
end
|
62
|
+
|
38
63
|
#Compile
|
39
64
|
#############################################################################
|
40
65
|
namespace :build do
|
data/bin/flok
CHANGED
@@ -66,16 +66,6 @@ class FlokCLI < Thor
|
|
66
66
|
desc "server", "Monitors for changes within your flok application and triggers an automatic rebuild of ./products/* for a PLATFORM when something in ./app changes"
|
67
67
|
include SpecHelpers #Contains sh2
|
68
68
|
def server platform
|
69
|
-
File.write "Guardfile", %{
|
70
|
-
guard :shell, :all_on_start => true do
|
71
|
-
watch %r{^app/.*} do |m|
|
72
|
-
system("#{$0} build #{platform}")
|
73
|
-
res = system("#{$0} build #{platform}");
|
74
|
-
$stdout.puts "BUILD RAN"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
}
|
78
|
-
|
79
69
|
#Ensure puts does something because it's on another thread
|
80
70
|
$stdout.sync = true
|
81
71
|
|
data/lib/flok/version.rb
CHANGED
data/spec/etc/cli_spec.rb
CHANGED
@@ -11,19 +11,23 @@ require 'securerandom'
|
|
11
11
|
|
12
12
|
#Execute flok binary
|
13
13
|
def flok args
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
#Execute
|
15
|
+
ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, "Gemfile")
|
16
|
+
ENV['RUBYOPT'] = ""
|
17
|
+
system('bundle install')
|
18
|
+
res = system("bundle exec flok #{args}")
|
19
|
+
raise "Could not execute bundle exec flok #{args.inspect}" unless res
|
20
20
|
end
|
21
21
|
|
22
22
|
#Create a new flok project named test and go into that directory
|
23
23
|
def flok_new
|
24
24
|
temp_dir = new_temp_dir
|
25
25
|
Dir.chdir temp_dir do
|
26
|
-
flok
|
26
|
+
#This isn't done with flok() because we don't have a project yet, ergo, no Gemfile
|
27
|
+
#But it's ok because it's *this* development version because we installed a copy of
|
28
|
+
#it before this spec ran in before(:each)
|
29
|
+
system("flok new test")
|
30
|
+
|
27
31
|
Dir.chdir "test" do
|
28
32
|
yield
|
29
33
|
end
|
@@ -31,167 +35,140 @@ def flok_new
|
|
31
35
|
end
|
32
36
|
|
33
37
|
RSpec.describe "CLI" do
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
38
|
+
before(:all) do
|
39
|
+
#Uninstall old gems and install the current development gem
|
40
|
+
system("rake gem:install")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "Can be executed via bundle exec" do
|
44
|
+
flok_new do
|
45
|
+
flok "build CHROME"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "Can create a new project with correct directories" do
|
50
|
+
flok_new do
|
51
|
+
#Should include all entities in the project template with the exception
|
52
|
+
#of erb extenseded entities (which will still be included, but they each
|
53
|
+
#will not have the erb ending
|
54
|
+
template_nodes = nil
|
55
|
+
Dir.chdir File.join(File.dirname(__FILE__), "../../lib/flok/project_template") do
|
56
|
+
template_nodes = Dir["**/*"].map{|e| e.gsub(/\.erb$/i, "")}
|
57
|
+
end
|
58
|
+
new_proj_nodes = Dir["**/*"]
|
59
|
+
$stderr.puts "Flok version = #{Flok::VERSION}"
|
60
|
+
expect(new_proj_nodes).to eq(template_nodes)
|
61
|
+
|
62
|
+
expect(files).to include("Gemfile")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it "Can build a project with every type of platform" do
|
67
|
+
Flok.platforms.each do |platform|
|
68
|
+
flok_new do
|
69
|
+
#Build a new project
|
70
|
+
flok "build #{platform}"
|
71
|
+
|
72
|
+
#Check it's products directory
|
73
|
+
expect(dirs).to include "products"
|
74
|
+
Dir.chdir "products" do
|
75
|
+
#Has a platform folder
|
76
|
+
expect(dirs).to include platform
|
77
|
+
Dir.chdir platform do
|
78
|
+
#Has an application_user.js file
|
79
|
+
expect(files).to include "application_user.js"
|
80
|
+
|
81
|
+
#The application_user.js contains both the glob/application.js and the glob/user_compiler.js
|
82
|
+
glob_application_js = File.read('glob/application.js')
|
83
|
+
glob_user_compiler_js = File.read('glob/user_compiler.js')
|
84
|
+
application_user_js = File.read('application_user.js')
|
85
|
+
expect(application_user_js).to include(glob_application_js)
|
86
|
+
expect(application_user_js).to include(glob_user_compiler_js)
|
87
|
+
|
88
|
+
#Contains the same files as the kernel in the drivers directory
|
89
|
+
expect(dirs).to include "drivers"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "Can build a project with a controller file for each platform" do
|
97
|
+
#Compile and then return the length of the application_user.js file
|
98
|
+
def compile_with_file path=nil
|
99
|
+
#Custom controller to test source with
|
100
|
+
controller_src = File.read(path) if path
|
101
|
+
flok_new do
|
102
|
+
File.write "./app/controllers/controller0.rb", controller_src if path
|
103
|
+
|
104
|
+
#Build a new project
|
105
|
+
flok "build #{@platform}"
|
106
|
+
|
107
|
+
#Check it's products directory
|
108
|
+
Dir.chdir "products" do
|
109
|
+
#Has a platform folder
|
110
|
+
Dir.chdir @platform do
|
111
|
+
glob_application_js = File.read('glob/application.js')
|
112
|
+
glob_user_compiler_js = File.read('glob/user_compiler.js')
|
113
|
+
application_user_js = File.read('application_user.js')
|
114
|
+
|
115
|
+
return application_user_js.split("\n").count
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
Flok.platforms.each do |platform|
|
122
|
+
@platform = platform
|
123
|
+
controller_rb = File.read('./spec/etc/user_compiler/controller0.rb')
|
109
124
|
|
110
125
|
|
111
126
|
|
112
|
-
|
113
|
-
|
114
|
-
|
127
|
+
#The file with content should be longer when compiled into the flat application_user.js
|
128
|
+
len_with_content = compile_with_file "./spec/etc/user_compiler/controller0.rb"
|
129
|
+
len_no_content = compile_with_file
|
115
130
|
|
116
|
-
|
117
|
-
|
118
|
-
|
131
|
+
expect(len_no_content).to be < len_with_content
|
132
|
+
end
|
133
|
+
end
|
119
134
|
|
120
135
|
include SpecHelpers
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
-
#Flok.platforms.each do |platform|
|
158
|
-
#flok_new do
|
159
|
-
##Start the server
|
160
|
-
##Get path to the flok binary relative to this file
|
161
|
-
#bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
|
162
|
-
#lib_path = File.join(File.dirname(__FILE__), "../../lib")
|
163
|
-
|
164
|
-
##Now execute the command with a set of arguments
|
165
|
-
#sh2("ruby -I#{lib_path} #{bin_path} server #{platform}", /BUILD RAN/) do |inp, out|
|
166
|
-
##Get the original build
|
167
|
-
#application_user_js = File.read("products/#{platform}/application_user.js")
|
168
|
-
|
169
|
-
##Now add a file
|
170
|
-
#File.write "./app/controllers/test2.rb", %{
|
171
|
-
#controller "my_controller" do
|
172
|
-
#view "my_controller"
|
173
|
-
#action "my_action" do
|
174
|
-
#on_entry %{
|
175
|
-
#}
|
176
|
-
#end
|
177
|
-
#end
|
178
|
-
#}
|
179
|
-
|
180
|
-
##Wait for a rebuild
|
181
|
-
#expect(out).to readline_and_equal_x_within_y_seconds("BUILD RAN", 5.seconds)
|
182
|
-
|
183
|
-
##Get updated version
|
184
|
-
#application_user_js2 = File.read("products/#{platform}/application_user.js")
|
185
|
-
|
186
|
-
##Make sure the compiled file is different and it's somewhat valid (length > 30)
|
187
|
-
#expect(application_user_js2).not_to eq(application_user_js)
|
188
|
-
#expect(application_user_js2.length).to be > 30 #Magic 30 to avoid any problems
|
189
|
-
#end
|
190
|
-
#end
|
191
|
-
#end
|
192
|
-
#end
|
193
|
-
|
194
|
-
it "server does delete existing products when a file is added (before it does a rebuild, i.e. clean)" do
|
136
|
+
it "server does build project when first run" do
|
137
|
+
Flok.platforms.each do |platform|
|
138
|
+
flok_new do
|
139
|
+
#Start the server
|
140
|
+
#Get path to the flok binary relative to this file
|
141
|
+
bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
|
142
|
+
lib_path = File.join(File.dirname(__FILE__), "../../lib")
|
143
|
+
|
144
|
+
#Now execute the command with a set of arguments
|
145
|
+
sh2("ruby -I#{lib_path} #{bin_path} server #{platform}", /BUILD RAN/) do |inp, out|
|
146
|
+
#The server should always trigger a build on it's first run
|
147
|
+
expect(dirs).to include "products"
|
148
|
+
Dir.chdir "products" do
|
149
|
+
#Has a platform folder
|
150
|
+
expect(dirs).to include platform
|
151
|
+
Dir.chdir platform do
|
152
|
+
#Has an application_user.js file
|
153
|
+
expect(files).to include "application_user.js"
|
154
|
+
|
155
|
+
#The application_user.js contains both the glob/application.js and the glob/user_compiler.js
|
156
|
+
glob_application_js = File.read('glob/application.js')
|
157
|
+
glob_user_compiler_js = File.read('glob/user_compiler.js')
|
158
|
+
application_user_js = File.read('application_user.js')
|
159
|
+
expect(application_user_js).to include(glob_application_js)
|
160
|
+
expect(application_user_js).to include(glob_user_compiler_js)
|
161
|
+
|
162
|
+
#Contains the same files as the kernel in the drivers directory
|
163
|
+
expect(dirs).to include "drivers"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
it "server does rebuild project when a file is added" do
|
195
172
|
Flok.platforms.each do |platform|
|
196
173
|
flok_new do
|
197
174
|
#Start the server
|
@@ -215,68 +192,74 @@ RSpec.describe "CLI" do
|
|
215
192
|
end
|
216
193
|
}
|
217
194
|
|
218
|
-
#
|
219
|
-
|
220
|
-
|
195
|
+
#Wait for a rebuild
|
196
|
+
expect(out).to readline_and_equal_x_within_y_seconds("BUILD RAN", 5.seconds)
|
197
|
+
|
198
|
+
#Get updated version
|
199
|
+
application_user_js2 = File.read("products/#{platform}/application_user.js")
|
200
|
+
|
201
|
+
#Make sure the compiled file is different and it's somewhat valid (length > 30)
|
202
|
+
expect(application_user_js2).not_to eq(application_user_js)
|
203
|
+
expect(application_user_js2.length).to be > 30 #Magic 30 to avoid any problems
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
it "server does host products on localhost:9992" do
|
210
|
+
Flok.platforms.each do |platform|
|
211
|
+
flok_new do
|
212
|
+
#Start the server
|
213
|
+
#Get path to the flok binary relative to this file
|
214
|
+
bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
|
215
|
+
lib_path = File.join(File.dirname(__FILE__), "../../lib")
|
216
|
+
|
217
|
+
#Now execute the command with a set of arguments
|
218
|
+
sh2("ruby -I#{lib_path} #{bin_path} server #{platform}", /BUILD RAN/) do |inp, out|
|
219
|
+
real_application_user_js = File.read("products/#{platform}/application_user.js")
|
220
|
+
|
221
|
+
#Grab the application_user.js file
|
222
|
+
res = wget "http://localhost:9992/application_user.js"
|
223
|
+
expect(res).to eq(real_application_user_js)
|
221
224
|
end
|
222
225
|
end
|
223
226
|
end
|
224
227
|
end
|
225
228
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
#
|
237
|
-
|
238
|
-
|
239
|
-
#
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
#
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
#view "my_controller"
|
263
|
-
#action "my_action" do
|
264
|
-
#on_entry %{
|
265
|
-
#}
|
266
|
-
#end
|
267
|
-
#end
|
268
|
-
#}
|
269
|
-
##Wait for a rebuild
|
270
|
-
#expect(out).to readline_and_equal_x_within_y_seconds("BUILD RAN", 5.seconds)
|
271
|
-
|
272
|
-
##Grab new version
|
273
|
-
#application_user_js2 = wget "http://localhost:9992/application_user.js"
|
274
|
-
|
275
|
-
##Make sure the compiled file is different and it's somewhat valid (length > 30)
|
276
|
-
#expect(application_user_js2).not_to eq(application_user_js)
|
277
|
-
#expect(application_user_js2.length).to be > 30 #Magic 30 to avoid any problems
|
278
|
-
#end
|
279
|
-
#end
|
280
|
-
#end
|
281
|
-
#end
|
229
|
+
it "server does host products on localhost:9992 and changes the products when the files change" do
|
230
|
+
Flok.platforms.each do |platform|
|
231
|
+
flok_new do
|
232
|
+
#Start the server
|
233
|
+
#Get path to the flok binary relative to this file
|
234
|
+
bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
|
235
|
+
lib_path = File.join(File.dirname(__FILE__), "../../lib")
|
236
|
+
|
237
|
+
#Now execute the command with a set of arguments
|
238
|
+
sh2("ruby -I#{lib_path} #{bin_path} server #{platform}", /BUILD RAN/) do |inp, out|
|
239
|
+
#Get the original
|
240
|
+
application_user_js = wget "http://localhost:9992/application_user.js"
|
241
|
+
|
242
|
+
#Now add a file
|
243
|
+
File.write "./app/controllers/test2.rb", %{
|
244
|
+
controller "my_controller" do
|
245
|
+
view "my_controller"
|
246
|
+
action "my_action" do
|
247
|
+
on_entry %{
|
248
|
+
}
|
249
|
+
end
|
250
|
+
end
|
251
|
+
}
|
252
|
+
#Wait for a rebuild
|
253
|
+
expect(out).to readline_and_equal_x_within_y_seconds("BUILD RAN", 5.seconds)
|
254
|
+
|
255
|
+
#Grab new version
|
256
|
+
application_user_js2 = wget "http://localhost:9992/application_user.js"
|
257
|
+
|
258
|
+
#Make sure the compiled file is different and it's somewhat valid (length > 30)
|
259
|
+
expect(application_user_js2).not_to eq(application_user_js)
|
260
|
+
expect(application_user_js2.length).to be > 30 #Magic 30 to avoid any problems
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
282
265
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seo
|
@@ -343,6 +343,7 @@ files:
|
|
343
343
|
- lib/flok/platform.rb
|
344
344
|
- lib/flok/project.rb
|
345
345
|
- lib/flok/project_template/Gemfile.erb
|
346
|
+
- lib/flok/project_template/Guardfile
|
346
347
|
- lib/flok/project_template/app/controllers/controller.rb
|
347
348
|
- lib/flok/service_compiler_templates/services.js.erb
|
348
349
|
- lib/flok/services_compiler.rb
|