nutella_framework 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +3 -4
- data/VERSION +1 -1
- data/data/startup +3 -3
- data/framework_components/example_framework_interface/dandelion-flowers-card.jpg +0 -0
- data/framework_components/example_framework_interface/index.html +18 -0
- data/framework_components/main_interface/main_interface_bot.rb +183 -0
- data/framework_components/main_interface/public/index.html +54 -0
- data/framework_components/main_interface/views/index.erb +63 -0
- data/framework_components/order.json.example +6 -0
- data/framework_components/runs_list_bot/app_runs_list_bot.rb +15 -0
- data/lib/{core/commands → commands}/broker.rb +2 -2
- data/lib/{core/commands → commands}/checkup.rb +2 -2
- data/lib/commands/compile.rb +13 -0
- data/lib/commands/dependencies.rb +13 -0
- data/lib/commands/help.rb +35 -0
- data/lib/{core/commands → commands}/install.rb +19 -15
- data/lib/commands/meta/command.rb +19 -0
- data/lib/commands/meta/run_command.rb +114 -0
- data/lib/{core → commands/meta}/template_command.rb +1 -1
- data/lib/commands/new.rb +60 -0
- data/lib/commands/runs.rb +54 -0
- data/lib/commands/start.rb +321 -0
- data/lib/commands/stop.rb +101 -0
- data/lib/{core/commands → commands}/template.rb +59 -39
- data/lib/config/current_app_utils.rb +51 -0
- data/lib/config/persisted_hash.rb +14 -12
- data/lib/config/runlist.rb +116 -16
- data/lib/{cli → core}/nutella_cli.rb +1 -1
- data/lib/core/nutella_core.rb +2 -6
- data/lib/nutella_framework.rb +5 -3
- data/lib/nutella_lib_framework/api.rb +333 -0
- data/lib/tmux/tmux.rb +76 -0
- data/nutella_framework.gemspec +42 -29
- data/test/commands/test_cmd_cli_params_parsing.rb +56 -0
- data/test/commands/test_command_template.rb +31 -0
- data/test/config/test_current_app_utils.rb +34 -0
- data/test/config/test_persisted_hash.rb +48 -0
- data/test/config/test_runlist.rb +15 -23
- data/test/framework_apis/test_framework_api.rb +74 -0
- metadata +74 -27
- data/actors/main_interface/main_interface_bot.rb +0 -163
- data/actors/main_interface/public/index.html +0 -51
- data/actors/main_interface/views/index.erb +0 -45
- data/lib/config/current_project.rb +0 -58
- data/lib/core/command.rb +0 -12
- data/lib/core/commands/compile.rb +0 -21
- data/lib/core/commands/dependencies.rb +0 -21
- data/lib/core/commands/help.rb +0 -28
- data/lib/core/commands/new.rb +0 -60
- data/lib/core/commands/runs.rb +0 -52
- data/lib/core/commands/start.rb +0 -271
- data/lib/core/commands/stop.rb +0 -100
- data/lib/core/run_command.rb +0 -106
- data/lib/core/tmux.rb +0 -38
- data/test/config/test_config.rb +0 -48
- data/test/config/test_project.rb +0 -34
- data/test/test_run_command.rb +0 -54
- /data/{actors → framework_components}/main_interface/startup +0 -0
- /data/{actors → framework_components}/main_interface/views/not_found_404.erb +0 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Nutella
|
4
|
+
|
5
|
+
class TestNutellaConfig < MiniTest::Test
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@config = PersistedHash.new( 'runlist.json' )
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
should 'set a key value' do
|
13
|
+
assert_equal 'value1', @config['key1']='value1'
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'return \'nil\' if a key doesn\'t exist' do
|
17
|
+
assert_nil @config['fakekey']
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'return the value associated with a key whenever that key exists' do
|
21
|
+
@config['key2']='value2'
|
22
|
+
assert_equal 'value2', @config['key2']
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'return true if a key exists' do
|
26
|
+
@config['key3']='value3'
|
27
|
+
assert @config.has_key?('key3')
|
28
|
+
end
|
29
|
+
|
30
|
+
should 'return false if a key doesn\'t exist' do
|
31
|
+
refute @config.has_key?('key4')
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'access nested hashes' do
|
35
|
+
@config['key5']={'k55' => 'v55'}
|
36
|
+
assert_equal 'v55', @config['key5']['k55']
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
@config.send(:remove_file)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
data/test/config/test_runlist.rb
CHANGED
@@ -5,49 +5,41 @@ module Nutella
|
|
5
5
|
class TestRunList < MiniTest::Test
|
6
6
|
|
7
7
|
def setup
|
8
|
-
|
8
|
+
@runlist = RunListHash.new( 'runlist.json' )
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
should 'return true if the list is empty' do
|
12
|
-
assert
|
12
|
+
assert @runlist.empty?
|
13
13
|
end
|
14
14
|
|
15
15
|
should 'return false if the list is not empty' do
|
16
|
-
|
17
|
-
refute
|
16
|
+
assert @runlist.add?('app_id_a', 'run_id_1', '/just/a/random/path')
|
17
|
+
refute @runlist.empty?
|
18
18
|
end
|
19
19
|
|
20
20
|
should 'return empty array if the list is empty' do
|
21
|
-
assert_empty
|
21
|
+
assert_empty @runlist.all_runs
|
22
22
|
end
|
23
23
|
|
24
24
|
should 'return an array of runs in the list if not empty' do
|
25
|
-
refute_nil
|
26
|
-
refute_nil
|
27
|
-
assert_equal %w{run1 run2},
|
25
|
+
refute_nil @runlist.add?( 'app_a', 'run1', '/path/to/my/run1' )
|
26
|
+
refute_nil @runlist.add?( 'app_a', 'run2', '/path/to/my/run2' )
|
27
|
+
assert_equal %w{run1 run2}, @runlist.runs_for_app('app_a')
|
28
28
|
end
|
29
29
|
|
30
30
|
should 'return false if trying to add the same element twice' do
|
31
|
-
assert
|
32
|
-
refute
|
31
|
+
assert @runlist.add?( 'app_a', 'run1', '/path/to/my/run1' )
|
32
|
+
refute @runlist.add?( 'app_a', 'run1', '/path/to/my/run1' )
|
33
33
|
end
|
34
34
|
|
35
35
|
should 'return properly when deleting an item' do
|
36
|
-
assert
|
37
|
-
assert
|
38
|
-
refute
|
36
|
+
assert @runlist.add?('app_a', 'run1', '/path/to/my/run1' )
|
37
|
+
assert @runlist.delete?('app_a', 'run1')
|
38
|
+
refute @runlist.delete?('app_a', 'run1')
|
39
39
|
end
|
40
40
|
|
41
|
-
should 'properly indicate if an item is in the list' do
|
42
|
-
refute Nutella.runlist.include? 'run1'
|
43
|
-
assert Nutella.runlist.add?( 'run1', '/path/to/my/run1' )
|
44
|
-
assert Nutella.runlist.include? 'run1'
|
45
|
-
assert Nutella.runlist.delete? 'run1'
|
46
|
-
refute Nutella.runlist.include? 'run1'
|
47
|
-
end
|
48
|
-
|
49
41
|
def teardown
|
50
|
-
|
42
|
+
@runlist.remove_file
|
51
43
|
end
|
52
44
|
|
53
45
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
require_relative '../../lib/nutella_lib_framework/api'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
module Nutella
|
8
|
+
class TestFrameworkApi < MiniTest::Test
|
9
|
+
|
10
|
+
# nutella.init_as_f_component('localhost', 'my_component_id')
|
11
|
+
|
12
|
+
|
13
|
+
# should 'pub_sub_on_framework_channels' do
|
14
|
+
# cb_executed = false
|
15
|
+
# cb = lambda do |message, from|
|
16
|
+
# cb_executed = true
|
17
|
+
# puts "Received message from #{from['component_id']}/#{from['resource_id']}. Message: #{message}"
|
18
|
+
# end
|
19
|
+
# nutella.net.f.subscribe('demo0', cb)
|
20
|
+
# sleep 1
|
21
|
+
# nutella.net.f.publish('demo0', 'test_message')
|
22
|
+
# # Make sure we wait for the message to be delivered
|
23
|
+
# sleep 1
|
24
|
+
# assert cb_executed
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
#
|
28
|
+
# should 'request_response_on_framework_channel' do
|
29
|
+
# nutella.set_resource_id 'my_resource_id_3'
|
30
|
+
# nutella.net.f.handle_requests('demo3', lambda do |message, from|
|
31
|
+
# puts "We received a request: message #{message}, from #{from['component_id']}/#{from['resource_id']}."
|
32
|
+
# #Then we are going to return some random JSON
|
33
|
+
# {my:'json'}
|
34
|
+
# end)
|
35
|
+
# response = nutella.net.f.sync_request('demo3', 'my request is a string')
|
36
|
+
# assert_equal({'my' => 'json'}, response)
|
37
|
+
# nutella.net.f.async_request( 'demo3', 'my request is a string', lambda do |response|
|
38
|
+
# assert_equal({'my' => 'json'}, response)
|
39
|
+
# end)
|
40
|
+
# sleep 2
|
41
|
+
# end
|
42
|
+
|
43
|
+
|
44
|
+
# Framework-to-run (broadcasting)
|
45
|
+
|
46
|
+
# should 'test_app_run_pub_sub_all' do
|
47
|
+
# nutella.set_resource_id 'my_resource_id_5'
|
48
|
+
# cb = lambda do |message, app_id, run_id, from|
|
49
|
+
# puts "Received message from run_id #{from['run_id']} on #{app_id}/#{run_id}. Message: #{message}"
|
50
|
+
# # nutella.net.f.unsubscribe_from_all_runs 'demo5'
|
51
|
+
# end
|
52
|
+
# nutella.net.f.subscribe_to_all_runs('demo5', cb)
|
53
|
+
# sleep 1
|
54
|
+
# nutella.net.f.publish_to_all_runs('demo5', 'test_message')
|
55
|
+
# # Make sure we wait for the message to be delivered
|
56
|
+
# sleep 2
|
57
|
+
# end
|
58
|
+
|
59
|
+
# def test_app_run_req_res_all
|
60
|
+
# nutella.set_resource_id 'my_resource_id_6'
|
61
|
+
# nutella.net.f.handle_requests_on_all_runs('demo6', lambda do |message, app_id, run_id, from|
|
62
|
+
# puts "We received a request: message '#{message}', on app_id/run_id #{app_id}/#{run_id} from #{from}."
|
63
|
+
# 'response' # Return something
|
64
|
+
# end)
|
65
|
+
# sleep 1
|
66
|
+
# nutella.net.f.async_request_to_all_runs('demo6', 'my request is a string', lambda do |response|
|
67
|
+
# puts response
|
68
|
+
# end)
|
69
|
+
# sleep 2
|
70
|
+
# end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutella_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Gnoli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ansi
|
@@ -110,6 +110,26 @@ dependencies:
|
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 1.4.5
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: thin
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 1.6.3
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.6.3
|
123
|
+
type: :runtime
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 1.6.3
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 1.6.3
|
113
133
|
- !ruby/object:Gem::Dependency
|
114
134
|
name: nokogiri
|
115
135
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +170,26 @@ dependencies:
|
|
150
170
|
- - "~>"
|
151
171
|
- !ruby/object:Gem::Version
|
152
172
|
version: 4.0.0
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: nutella_lib
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 0.4.0
|
180
|
+
- - "~>"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 0.4.0
|
183
|
+
type: :runtime
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 0.4.0
|
190
|
+
- - "~>"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: 0.4.0
|
153
193
|
- !ruby/object:Gem::Dependency
|
154
194
|
name: shoulda
|
155
195
|
requirement: !ruby/object:Gem::Requirement
|
@@ -286,46 +326,53 @@ files:
|
|
286
326
|
- README.md
|
287
327
|
- Rakefile
|
288
328
|
- VERSION
|
289
|
-
- actors/main_interface/main_interface_bot.rb
|
290
|
-
- actors/main_interface/public/index.html
|
291
|
-
- actors/main_interface/startup
|
292
|
-
- actors/main_interface/views/index.erb
|
293
|
-
- actors/main_interface/views/not_found_404.erb
|
294
329
|
- bin/nutella
|
295
330
|
- data/index.html
|
296
331
|
- data/startup
|
297
|
-
-
|
332
|
+
- framework_components/example_framework_interface/dandelion-flowers-card.jpg
|
333
|
+
- framework_components/example_framework_interface/index.html
|
334
|
+
- framework_components/main_interface/main_interface_bot.rb
|
335
|
+
- framework_components/main_interface/public/index.html
|
336
|
+
- framework_components/main_interface/startup
|
337
|
+
- framework_components/main_interface/views/index.erb
|
338
|
+
- framework_components/main_interface/views/not_found_404.erb
|
339
|
+
- framework_components/order.json.example
|
340
|
+
- framework_components/runs_list_bot/app_runs_list_bot.rb
|
341
|
+
- lib/commands/broker.rb
|
342
|
+
- lib/commands/checkup.rb
|
343
|
+
- lib/commands/compile.rb
|
344
|
+
- lib/commands/dependencies.rb
|
345
|
+
- lib/commands/help.rb
|
346
|
+
- lib/commands/install.rb
|
347
|
+
- lib/commands/meta/command.rb
|
348
|
+
- lib/commands/meta/run_command.rb
|
349
|
+
- lib/commands/meta/template_command.rb
|
350
|
+
- lib/commands/new.rb
|
351
|
+
- lib/commands/runs.rb
|
352
|
+
- lib/commands/start.rb
|
353
|
+
- lib/commands/stop.rb
|
354
|
+
- lib/commands/template.rb
|
298
355
|
- lib/config/config.rb
|
299
|
-
- lib/config/
|
356
|
+
- lib/config/current_app_utils.rb
|
300
357
|
- lib/config/persisted_hash.rb
|
301
358
|
- lib/config/runlist.rb
|
302
|
-
- lib/core/
|
303
|
-
- lib/core/commands/broker.rb
|
304
|
-
- lib/core/commands/checkup.rb
|
305
|
-
- lib/core/commands/compile.rb
|
306
|
-
- lib/core/commands/dependencies.rb
|
307
|
-
- lib/core/commands/help.rb
|
308
|
-
- lib/core/commands/install.rb
|
309
|
-
- lib/core/commands/new.rb
|
310
|
-
- lib/core/commands/runs.rb
|
311
|
-
- lib/core/commands/start.rb
|
312
|
-
- lib/core/commands/stop.rb
|
313
|
-
- lib/core/commands/template.rb
|
359
|
+
- lib/core/nutella_cli.rb
|
314
360
|
- lib/core/nutella_core.rb
|
315
|
-
- lib/core/run_command.rb
|
316
|
-
- lib/core/template_command.rb
|
317
|
-
- lib/core/tmux.rb
|
318
361
|
- lib/logging/nutella_logger-remote.rb
|
319
362
|
- lib/logging/nutella_logger.rb
|
320
363
|
- lib/logging/nutella_logging.rb
|
321
364
|
- lib/nutella_framework.rb
|
365
|
+
- lib/nutella_lib_framework/api.rb
|
366
|
+
- lib/tmux/tmux.rb
|
322
367
|
- nutella_framework.gemspec
|
323
|
-
- test/
|
324
|
-
- test/
|
368
|
+
- test/commands/test_cmd_cli_params_parsing.rb
|
369
|
+
- test/commands/test_command_template.rb
|
370
|
+
- test/config/test_current_app_utils.rb
|
371
|
+
- test/config/test_persisted_hash.rb
|
325
372
|
- test/config/test_runlist.rb
|
373
|
+
- test/framework_apis/test_framework_api.rb
|
326
374
|
- test/helper.rb
|
327
375
|
- test/logging/test_logging.rb
|
328
|
-
- test/test_run_command.rb
|
329
376
|
homepage: https://github.com/nutella-framework/nutella_framework
|
330
377
|
licenses:
|
331
378
|
- MIT
|
@@ -1,163 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'sinatra'
|
3
|
-
require 'nokogiri'
|
4
|
-
|
5
|
-
# Configuration file and runlist (runlist as global)
|
6
|
-
config_file = ARGV[0]
|
7
|
-
$runlist_file = ARGV[1]
|
8
|
-
|
9
|
-
# Try to parse the both config file and runlist and terminate if we can't
|
10
|
-
begin
|
11
|
-
config_h = JSON.parse(IO.read(config_file))
|
12
|
-
JSON.parse(IO.read($runlist_file))
|
13
|
-
rescue
|
14
|
-
# something went wrong
|
15
|
-
abort 'Impossible to parse configuration and/or runlist files!'
|
16
|
-
end
|
17
|
-
|
18
|
-
# Set Sinatra to run in production mode
|
19
|
-
set :environment, :production
|
20
|
-
|
21
|
-
# Set Sinatra's port to nutella's main_interface_port
|
22
|
-
set :port, config_h['main_interface_port']
|
23
|
-
|
24
|
-
|
25
|
-
# Display the form to input the run_id
|
26
|
-
get '/' do
|
27
|
-
send_file File.join("#{config_h['nutella_home']}/actors/main_interface/public", 'index.html')
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
# Redirect if there is no slash after the run_id
|
32
|
-
get '/:run_id' do
|
33
|
-
redirect "#{request.url}/"
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
# Renders the run template
|
38
|
-
get '/:run_id/' do
|
39
|
-
|
40
|
-
# Parse the run_id from URL and extract the run path from runlist.json
|
41
|
-
@run_id = params[:run_id]
|
42
|
-
@run_path = get_run_path @run_id
|
43
|
-
@project_name = @run_path[@run_path.rindex('/')+1..@run_path.length] unless @run_path.nil?
|
44
|
-
|
45
|
-
# If there is no run with this name, render error page
|
46
|
-
return erb( :not_found_404, :locals => {:not_found_type => 'run'} ) if @run_path.nil?
|
47
|
-
|
48
|
-
# If there is an 'index.erb' file inside the 'interfaces' folder, render it
|
49
|
-
custom_index_file = "#{@run_path}/interfaces/index.erb"
|
50
|
-
return erb(File.read( custom_index_file )) if File.exist? custom_index_file
|
51
|
-
|
52
|
-
# If no 'index.erb' is provided we need to generate one
|
53
|
-
# In order to do so we need to load a bunch of details
|
54
|
-
# (folder, title/name, description) for each interface
|
55
|
-
@interfaces = load_interfaces_details
|
56
|
-
|
57
|
-
# Finally render the interfaces summary page
|
58
|
-
erb :index
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
# Redirect if there is a slash after the interface
|
63
|
-
get '/:run_id/:interface/' do
|
64
|
-
redirect "#{request.url[0..-2]}"
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
# Serves the index.html file for each individual interface augmented with nutella query string parameters
|
69
|
-
get '/:run_id/:interface' do
|
70
|
-
|
71
|
-
# Parse the run_id and the interface name from URL
|
72
|
-
run_id = params[:run_id]
|
73
|
-
interface = params[:interface]
|
74
|
-
|
75
|
-
# Extract the run path from runlist.json
|
76
|
-
run_path = get_run_path run_id
|
77
|
-
|
78
|
-
# Compose the path of interface index file
|
79
|
-
index_file_path = "#{run_path}/interfaces/#{interface}/index.html"
|
80
|
-
|
81
|
-
# If the index file doesn't exist, render error page
|
82
|
-
return erb( :not_found_404, :locals => {:not_found_type => 'idx'} ) unless File.exist? index_file_path
|
83
|
-
|
84
|
-
# If the index file exists, compose query string and redirect
|
85
|
-
index_with_query_url = "#{request.path}/index.html?run_id=#{run_id}&broker=#{config_h['broker']}"
|
86
|
-
redirect index_with_query_url
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
# Serves the files contained in each interface folder
|
91
|
-
get '/:run_id/:interface/*' do
|
92
|
-
|
93
|
-
# Parse the run_id, the interface name and the file_path from URL
|
94
|
-
run_id = params[:run_id]
|
95
|
-
interface = params[:interface]
|
96
|
-
relative_file_path = params[:splat][0]
|
97
|
-
|
98
|
-
# Extract the run path from runlist.json
|
99
|
-
run_path = get_run_path run_id
|
100
|
-
|
101
|
-
# Compose the path of the file we are trying to serve
|
102
|
-
file_path = "#{run_path}/interfaces/#{interface}/#{relative_file_path}"
|
103
|
-
|
104
|
-
# If the file we are trying to serve doesn't exist, render error page
|
105
|
-
return erb( :not_found_404, :locals => {:not_found_type => 'file'} ) unless File.exist? file_path
|
106
|
-
|
107
|
-
# If the file exists, render it
|
108
|
-
send_file file_path
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
# Utility function:
|
113
|
-
# Gets the path associated with a certain run
|
114
|
-
def get_run_path (run_id)
|
115
|
-
begin
|
116
|
-
runs_h = JSON.parse(IO.read($runlist_file))
|
117
|
-
runs_h[run_id]
|
118
|
-
rescue
|
119
|
-
nil
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# Utility function:
|
124
|
-
# Loads all the details for all interfaces and stores them into an array of hashes
|
125
|
-
def load_interfaces_details
|
126
|
-
interfaces = Array.new
|
127
|
-
interfaces_path = "#{@run_path}/interfaces/"
|
128
|
-
Dir.entries(interfaces_path).select {|entry| File.directory?(File.join(interfaces_path, entry)) && !(entry =='.' || entry == '..') }.each do |iface_dir|
|
129
|
-
interfaces.push extract_interface_info( interfaces_path, iface_dir )
|
130
|
-
end
|
131
|
-
interfaces
|
132
|
-
end
|
133
|
-
|
134
|
-
# Utility function:
|
135
|
-
# Extracts name, description and folder for a single interface
|
136
|
-
def extract_interface_info( interfaces_path, iface_dir )
|
137
|
-
iface_props = Hash.new
|
138
|
-
|
139
|
-
index_path = "#{interfaces_path}#{iface_dir}/index.html"
|
140
|
-
|
141
|
-
unless File.exist? index_path
|
142
|
-
iface_props[:name] = iface_dir
|
143
|
-
iface_props[:description] = 'My designer was a bit lazy and didn\'t include an index.html file in the main interface directory :('
|
144
|
-
return iface_props
|
145
|
-
end
|
146
|
-
|
147
|
-
# If file exists, parse it and extract info
|
148
|
-
f = File.open index_path
|
149
|
-
doc = Nokogiri::HTML f
|
150
|
-
f.close
|
151
|
-
iface_props[:name] = doc.css('title').empty? ? iface_dir : doc.css('title').text
|
152
|
-
if doc.css("meta[name='description']").empty?
|
153
|
-
iface_props[:description] = 'My designer was a bit lazy and didn\'t include a <meta name="description" content="Description of this interface"> tag in the index.html file :('
|
154
|
-
else
|
155
|
-
if doc.css("meta[name='description']").attribute('content').nil?
|
156
|
-
iface_props[:description] = 'There was no attribute content in <meta name="description" content="Description of this interface"> tag in the index.html file :('
|
157
|
-
else
|
158
|
-
iface_props[:description] = doc.css("meta[name='description']").attribute('content').text
|
159
|
-
end
|
160
|
-
end
|
161
|
-
iface_props[:url] = "#{iface_dir}"
|
162
|
-
iface_props
|
163
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
-
<title>Welcome to nutella</title>
|
8
|
-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
9
|
-
|
10
|
-
<style type="text/css">
|
11
|
-
div {
|
12
|
-
margin-top: 4em;
|
13
|
-
text-align: center;
|
14
|
-
font-size: 3em;
|
15
|
-
}
|
16
|
-
.form-control {
|
17
|
-
height: 50px;
|
18
|
-
width: 40%;
|
19
|
-
text-align: center;
|
20
|
-
font-size: .7em;
|
21
|
-
display: inline-block;
|
22
|
-
}
|
23
|
-
.center {
|
24
|
-
text-align:center;
|
25
|
-
}
|
26
|
-
.center form {
|
27
|
-
display:inline-block;
|
28
|
-
}
|
29
|
-
</style>
|
30
|
-
</head>
|
31
|
-
<body>
|
32
|
-
|
33
|
-
<!-- Content -->
|
34
|
-
<div>
|
35
|
-
<p>What is your run id?</p>
|
36
|
-
<input id="run_id_input" type="text" value="" class="form-control" autofocus>
|
37
|
-
</div>
|
38
|
-
|
39
|
-
<!-- Scripts -->
|
40
|
-
<script>
|
41
|
-
el = document.getElementById('run_id_input');
|
42
|
-
el.addEventListener('change', function() {
|
43
|
-
url = location.href
|
44
|
-
if (url.substr(url.length - 1)=="/")
|
45
|
-
window.location = url + this.value + '/';
|
46
|
-
else
|
47
|
-
window.location = url + '/' + this.value + '/';
|
48
|
-
});
|
49
|
-
</script>
|
50
|
-
</body>
|
51
|
-
</html>
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
-
<title><%= @run_id %> interfaces</title>
|
8
|
-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
9
|
-
|
10
|
-
<style type="text/css">
|
11
|
-
.row {
|
12
|
-
margin-bottom: 20px;
|
13
|
-
}
|
14
|
-
</style>
|
15
|
-
</head>
|
16
|
-
<body>
|
17
|
-
|
18
|
-
<!-- Content -->
|
19
|
-
<div class="container">
|
20
|
-
<div class="page-header">
|
21
|
-
<% if @run_id == @project_name %>
|
22
|
-
<h1>Welcome to <em><%= @project_name %></em></h1>
|
23
|
-
<% else %>
|
24
|
-
<h1>Welcome to <em><%= @project_name %></em>, run <em><%= @run_id %></em></h1>
|
25
|
-
<% end %>
|
26
|
-
<p class="lead">Click on the buttons to launch the intereface</p>
|
27
|
-
</div>
|
28
|
-
|
29
|
-
<% @interfaces.each do |i| %>
|
30
|
-
<div class="row">
|
31
|
-
<div class="col-xs-1 col-sm-1 col-lg-1"><a href="<%= i[:url] %>" target="_blank" type="button" class="btn btn-danger">Launch!</a></div>
|
32
|
-
<div class="col-xs-2 col-sm-2 col-lg-2 text-center"><strong><%= i[:name] %></strong></div>
|
33
|
-
<div class="col-xs-9 col-sm-9 col-lg-9"><%= i[:description] %></div>
|
34
|
-
</div>
|
35
|
-
|
36
|
-
<% end %>
|
37
|
-
|
38
|
-
</div>
|
39
|
-
|
40
|
-
<!-- Scripts -->
|
41
|
-
<script>
|
42
|
-
|
43
|
-
</script>
|
44
|
-
</body>
|
45
|
-
</html>
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# handles current project files
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module Nutella
|
5
|
-
|
6
|
-
module CurrentProjectUtils
|
7
|
-
|
8
|
-
# Checks that the current directory is actually a nutella project
|
9
|
-
# @return [Boolean] true if the current directory is a nutella project, false otherwise
|
10
|
-
def CurrentProjectUtils.exist?
|
11
|
-
cur_prj_dir = Dir.pwd
|
12
|
-
nutella_json_file = "#{cur_prj_dir}/nutella.json"
|
13
|
-
# Check that there is a nutella.json file in the main directory of the project
|
14
|
-
if File.exist? nutella_json_file
|
15
|
-
conf = JSON.parse( IO.read(nutella_json_file) )
|
16
|
-
if conf['nutella_version'].nil?
|
17
|
-
console.warn 'The current directory is not a nutella project: nutella_version unspecified in nutella.json file'
|
18
|
-
return false
|
19
|
-
end
|
20
|
-
else
|
21
|
-
console.warn 'The current directory is not a nutella project: impossible to read nutella.json file'
|
22
|
-
return false
|
23
|
-
end
|
24
|
-
true
|
25
|
-
end
|
26
|
-
|
27
|
-
# Builds a PersistedHash of the project nutella.json file and returns it.
|
28
|
-
# This method is used to ease access to the project nutella.json file.
|
29
|
-
# @return [PersistedHash] the PersistedHash of the project nutella.json file
|
30
|
-
def CurrentProjectUtils.config
|
31
|
-
cur_prj_dir = Dir.pwd
|
32
|
-
nutella_json_file = "#{cur_prj_dir}/nutella.json"
|
33
|
-
if File.exist? nutella_json_file
|
34
|
-
return PersistedHash.new nutella_json_file
|
35
|
-
else
|
36
|
-
console.error 'The current directory is not a nutella project: impossible to read nutella.json file'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# Retrieves the current project directory
|
41
|
-
# @return [String] the current project home
|
42
|
-
def CurrentProjectUtils.dir
|
43
|
-
Dir.pwd
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
# Calling this method (Nutella.current_project) simply returns
|
50
|
-
# a reference to the CurrentProjectUtils module
|
51
|
-
def Nutella.current_project
|
52
|
-
CurrentProjectUtils
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
|
data/lib/core/command.rb
DELETED