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
data/lib/core/tmux.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module Nutella
|
2
|
-
|
3
|
-
class Tmux
|
4
|
-
|
5
|
-
def initialize( run_id )
|
6
|
-
@run_id = run_id
|
7
|
-
end
|
8
|
-
|
9
|
-
def new_bot_window( bot )
|
10
|
-
if defined? @sessions
|
11
|
-
# If a session already exists,
|
12
|
-
# simply create a new window for 'bot'.
|
13
|
-
# -k destroys the window if it can't be created
|
14
|
-
# Print info about creation of window
|
15
|
-
`tmux new-window -kP -n #{bot} &> /dev/null`
|
16
|
-
@sessions.push bot
|
17
|
-
else
|
18
|
-
# If there is no sessions, let's create one and, at the same time, create a new window for the bot
|
19
|
-
`tmux new-session -d -s #{@run_id} -n #{bot} &> /dev/null`
|
20
|
-
@sessions = [bot]
|
21
|
-
end
|
22
|
-
# Select window
|
23
|
-
`tmux select-window -t #{@run_id}:#{@sessions.length-1} &> /dev/null`
|
24
|
-
# Start bot
|
25
|
-
`tmux send-keys "cd bots/#{bot};./startup #{@run_id} #{Nutella.config['broker']}" C-m`
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.kill_session( run_id )
|
29
|
-
`tmux kill-session -t #{run_id} &> /dev/null`
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.session_exist?( run_id )
|
33
|
-
system( "tmux has-session -t #{run_id} &> /dev/null" )
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
data/test/config/test_config.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module Nutella
|
4
|
-
|
5
|
-
class TestNutellaConfig < MiniTest::Test
|
6
|
-
|
7
|
-
def setup
|
8
|
-
Nutella.config.send(:remove_file)
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
should 'set a key value' do
|
13
|
-
assert_equal 'value1', Nutella.config['key1']='value1'
|
14
|
-
end
|
15
|
-
|
16
|
-
should 'return \'nil\' if a key doesn\'t exist' do
|
17
|
-
assert_nil Nutella.config['fakekey']
|
18
|
-
end
|
19
|
-
|
20
|
-
should 'return the value associated with a key whenever that key exists' do
|
21
|
-
Nutella.config['key2']='value2'
|
22
|
-
assert_equal 'value2', Nutella.config['key2']
|
23
|
-
end
|
24
|
-
|
25
|
-
should 'retun true if a key exists' do
|
26
|
-
Nutella.config['key3']='value3'
|
27
|
-
assert Nutella.config.has_key?('key3')
|
28
|
-
end
|
29
|
-
|
30
|
-
should 'retun false if a key doens\'t exist' do
|
31
|
-
refute Nutella.config.has_key?('key4')
|
32
|
-
end
|
33
|
-
|
34
|
-
should 'access nested hashes' do
|
35
|
-
Nutella.config['key5']={'k55' => 'v55'}
|
36
|
-
assert_equal 'v55', Nutella.config['key5']['k55']
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
def teardown
|
41
|
-
Nutella.config.send(:remove_file)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
|
data/test/config/test_project.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module Nutella
|
4
|
-
|
5
|
-
class TestProject < MiniTest::Test
|
6
|
-
|
7
|
-
def setup
|
8
|
-
Dir.chdir NUTELLA_HOME
|
9
|
-
Nutella.execute_command( 'new', ['test_project'] )
|
10
|
-
Dir.chdir "#{NUTELLA_HOME}test_project"
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
should 'return true if the dir is a nutella project' do
|
15
|
-
assert Nutella.current_project.exist?
|
16
|
-
end
|
17
|
-
|
18
|
-
should 'return false if the dir is not a nutella project' do
|
19
|
-
Dir.chdir NUTELLA_HOME
|
20
|
-
refute Nutella.current_project.exist?
|
21
|
-
end
|
22
|
-
|
23
|
-
should 'return the correct version of nutella as read from the project configuration file' do
|
24
|
-
assert_equal File.open("#{NUTELLA_HOME}VERSION", "rb").read, Nutella.current_project.config['nutella_version']
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def teardown
|
29
|
-
FileUtils.rm_rf "#{NUTELLA_HOME}test_project"
|
30
|
-
Dir.chdir NUTELLA_HOME
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
data/test/test_run_command.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module Nutella
|
4
|
-
|
5
|
-
class TestRunCommand < MiniTest::Test
|
6
|
-
|
7
|
-
@@run_cmd = RunCommand.new
|
8
|
-
|
9
|
-
|
10
|
-
should 'parse app long argument' do
|
11
|
-
params = @@run_cmd.send( :extract_parameters, ['--with=bot1,bot2,bot3'] )
|
12
|
-
assert_equal ['bot1', 'bot2', 'bot3'], params[:with]
|
13
|
-
end
|
14
|
-
|
15
|
-
should 'parse without long argument' do
|
16
|
-
params = @@run_cmd.send( :extract_parameters, ['--without=botA,botB,botC'] )
|
17
|
-
assert_equal ['botA', 'botB', 'botC'], params[:without]
|
18
|
-
end
|
19
|
-
|
20
|
-
should 'parse with long argument' do
|
21
|
-
params = @@run_cmd.send( :extract_parameters, ['--with=botX,botY,botZ'] )
|
22
|
-
assert_equal ['botX', 'botY', 'botZ'], params[:with]
|
23
|
-
end
|
24
|
-
|
25
|
-
should 'parse one short argument' do
|
26
|
-
params = @@run_cmd.send( :extract_parameters, ['-w=bot1,bot2,bot3'] )
|
27
|
-
assert_equal ['bot1', 'bot2', 'bot3'], params[:with]
|
28
|
-
end
|
29
|
-
|
30
|
-
should 'parse two long arguments' do
|
31
|
-
params = @@run_cmd.send( :extract_parameters, ['--with=bot1,bot2,bot3', '--without=botA,botB,botC'] )
|
32
|
-
assert_equal ['bot1', 'bot2', 'bot3'], params[:with]
|
33
|
-
assert_equal ['botA', 'botB', 'botC'], params[:without]
|
34
|
-
end
|
35
|
-
|
36
|
-
should 'parse two short arguments' do
|
37
|
-
params = @@run_cmd.send( :extract_parameters, ['-wo=bot1,bot2,bot3', '-w=botA,botB,botC'] )
|
38
|
-
assert_equal ['bot1', 'bot2', 'bot3'], params[:without]
|
39
|
-
assert_equal ['botA', 'botB', 'botC'], params[:with]
|
40
|
-
end
|
41
|
-
|
42
|
-
should 'parse one short and one long argument' do
|
43
|
-
params = @@run_cmd.send( :extract_parameters, ['--with=bot1,bot2,bot3', '-wo=botA,botB,botC'] )
|
44
|
-
assert_equal ['bot1', 'bot2', 'bot3'], params[:with]
|
45
|
-
assert_equal ['botA', 'botB', 'botC'], params[:without]
|
46
|
-
end
|
47
|
-
|
48
|
-
should 'raise an exception when trying to parse params that do not exist' do
|
49
|
-
assert_raises (Slop::UnknownOption) { @@run_cmd.send( :extract_parameters, ['--wit=bot1,bot2,bot3', '-o=botA,botB,botC'] ) }
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
File without changes
|
File without changes
|