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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bdd0e73ce51527ed47bbeb40ec3f891488f4265
4
- data.tar.gz: 692562bb5786d8cd4c03a74db6aa3954b8f64955
3
+ metadata.gz: 36ee09730e9f19e332b7c1cee80be3b26bf5c11e
4
+ data.tar.gz: b1f842a2a19bea7cd6db737cd1a29e6813d35e08
5
5
  SHA512:
6
- metadata.gz: 35d8ce34aa667a0d0d5c840e50ae4531167b67af3561057e0ab13a807a061e3af93ea6366dd308290958977e26cdf930ab8165c02fb755e150e2dfe1265c3bf4
7
- data.tar.gz: 9698f5d86ba29a377308a4ab414744ad466959115dab251dc102f0a11337def7ef0e1c9d468ae6b1c7a96db190e1104dd34c01dde9052ef2d44ca6181453a8e7
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
 
@@ -1,2 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'flok'
@@ -0,0 +1,7 @@
1
+ #This file is used for `flok server`
2
+ guard :shell, :all_on_start => true do
3
+ watch %r{app/.*} do |m|
4
+ res = system("flok build #{ENV['PLATFORM']}");
5
+ $stdout.puts "BUILD RAN"
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Flok
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.23"
3
3
  end
@@ -11,19 +11,23 @@ require 'securerandom'
11
11
 
12
12
  #Execute flok binary
13
13
  def flok args
14
- #Get path to the flok binary relative to this file
15
- bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
16
- lib_path = File.join(File.dirname(__FILE__), "../../lib")
17
-
18
- #Now execute the command with a set of arguments
19
- system("ruby -I#{lib_path} #{bin_path} #{args}")
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 "new test"
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
- # it "Can create a new project with correct directories" do
35
- #flok_new do
36
- ##Should include all entities in the project template with the exception
37
- ##of erb extenseded entities (which will still be included, but they each
38
- ##will not have the erb ending
39
- #template_nodes = nil
40
- #Dir.chdir File.join(File.dirname(__FILE__), "../../lib/flok/project_template") do
41
- #template_nodes = Dir["**/*"].map{|e| e.gsub(/\.erb$/i, "")}
42
- #end
43
- #new_proj_nodes = Dir["**/*"]
44
- #$stderr.puts "Flok version = #{Flok::VERSION}"
45
- #expect(new_proj_nodes).to eq(template_nodes)
46
-
47
- #expect(files).to include("Gemfile")
48
- #end
49
- #end
50
-
51
- #it "Can build a project with every type of platform" do
52
- #Flok.platforms.each do |platform|
53
- #flok_new do
54
- ##Build a new project
55
- #flok "build #{platform}"
56
-
57
- ##Check it's products directory
58
- #expect(dirs).to include "products"
59
- #Dir.chdir "products" do
60
- ##Has a platform folder
61
- #expect(dirs).to include platform
62
- #Dir.chdir platform do
63
- ##Has an application_user.js file
64
- #expect(files).to include "application_user.js"
65
-
66
- ##The application_user.js contains both the glob/application.js and the glob/user_compiler.js
67
- #glob_application_js = File.read('glob/application.js')
68
- #glob_user_compiler_js = File.read('glob/user_compiler.js')
69
- #application_user_js = File.read('application_user.js')
70
- #expect(application_user_js).to include(glob_application_js)
71
- #expect(application_user_js).to include(glob_user_compiler_js)
72
-
73
- ##Contains the same files as the kernel in the drivers directory
74
- #expect(dirs).to include "drivers"
75
- #end
76
- #end
77
- #end
78
- #end
79
- #end
80
-
81
- #it "Can build a project with a controller file for each platform" do
82
- ##Compile and then return the length of the application_user.js file
83
- #def compile_with_file path=nil
84
- ##Custom controller to test source with
85
- #controller_src = File.read(path) if path
86
- #flok_new do
87
- #File.write "./app/controllers/controller0.rb", controller_src if path
88
-
89
- ##Build a new project
90
- #flok "build #{@platform}"
91
-
92
- ##Check it's products directory
93
- #Dir.chdir "products" do
94
- ##Has a platform folder
95
- #Dir.chdir @platform do
96
- #glob_application_js = File.read('glob/application.js')
97
- #glob_user_compiler_js = File.read('glob/user_compiler.js')
98
- #application_user_js = File.read('application_user.js')
99
-
100
- #return application_user_js.split("\n").count
101
- #end
102
- #end
103
- #end
104
- #end
105
-
106
- #Flok.platforms.each do |platform|
107
- #@platform = platform
108
- #controller_rb = File.read('./spec/etc/user_compiler/controller0.rb')
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
- ##The file with content should be longer when compiled into the flat application_user.js
113
- #len_with_content = compile_with_file "./spec/etc/user_compiler/controller0.rb"
114
- #len_no_content = compile_with_file
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
- #expect(len_no_content).to be < len_with_content
117
- #end
118
- #end
131
+ expect(len_no_content).to be < len_with_content
132
+ end
133
+ end
119
134
 
120
135
  include SpecHelpers
121
- # it "server does build project when first run" do
122
- #Flok.platforms.each do |platform|
123
- #flok_new do
124
- ##Start the server
125
- ##Get path to the flok binary relative to this file
126
- #bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
127
- #lib_path = File.join(File.dirname(__FILE__), "../../lib")
128
-
129
- ##Now execute the command with a set of arguments
130
- #sh2("ruby -I#{lib_path} #{bin_path} server #{platform}", /BUILD RAN/) do |inp, out|
131
- ##The server should always trigger a build on it's first run
132
- #expect(dirs).to include "products"
133
- #Dir.chdir "products" do
134
- ##Has a platform folder
135
- #expect(dirs).to include platform
136
- #Dir.chdir platform do
137
- ##Has an application_user.js file
138
- #expect(files).to include "application_user.js"
139
-
140
- ##The application_user.js contains both the glob/application.js and the glob/user_compiler.js
141
- #glob_application_js = File.read('glob/application.js')
142
- #glob_user_compiler_js = File.read('glob/user_compiler.js')
143
- #application_user_js = File.read('application_user.js')
144
- #expect(application_user_js).to include(glob_application_js)
145
- #expect(application_user_js).to include(glob_user_compiler_js)
146
-
147
- ##Contains the same files as the kernel in the drivers directory
148
- #expect(dirs).to include "drivers"
149
- #end
150
- #end
151
- #end
152
- #end
153
- #end
154
- #end
155
-
156
- #it "server does rebuild project when a file is added" do
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
- #DONT Wait for a rebuild
219
- is_dir = File.directory?("products/#{platform}")
220
- expect(is_dir).to eq(false)
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
- #it "server does host products on localhost:9992" do
227
- #Flok.platforms.each do |platform|
228
- #flok_new do
229
- ##Start the server
230
- ##Get path to the flok binary relative to this file
231
- #bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
232
- #lib_path = File.join(File.dirname(__FILE__), "../../lib")
233
-
234
- ##Now execute the command with a set of arguments
235
- #sh2("ruby -I#{lib_path} #{bin_path} server #{platform}", /BUILD RAN/) do |inp, out|
236
- #real_application_user_js = File.read("products/#{platform}/application_user.js")
237
-
238
- ##Grab the application_user.js file
239
- #res = wget "http://localhost:9992/application_user.js"
240
- #expect(res).to eq(real_application_user_js)
241
- #end
242
- #end
243
- #end
244
- #end
245
-
246
- #it "server does host products on localhost:9992 and changes the products when the files change" do
247
- #Flok.platforms.each do |platform|
248
- #flok_new do
249
- ##Start the server
250
- ##Get path to the flok binary relative to this file
251
- #bin_path = File.join(File.dirname(__FILE__), "../../bin/flok")
252
- #lib_path = File.join(File.dirname(__FILE__), "../../lib")
253
-
254
- ##Now execute the command with a set of arguments
255
- #sh2("ruby -I#{lib_path} #{bin_path} server #{platform}", /BUILD RAN/) do |inp, out|
256
- ##Get the original
257
- #application_user_js = wget "http://localhost:9992/application_user.js"
258
-
259
- ##Now add a file
260
- #File.write "./app/controllers/test2.rb", %{
261
- #controller "my_controller" do
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.21
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