nutella_framework 0.3.0 → 0.3.1
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/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/config/config.rb +1 -1
- data/lib/config/persisted_hash.rb +3 -0
- data/lib/config/runlist.rb +1 -1
- data/lib/core/commands/checkup.rb +3 -2
- data/lib/core/commands/install.rb +6 -1
- data/lib/core/commands/new.rb +1 -1
- data/lib/core/commands/start.rb +8 -8
- data/lib/core/commands/stop.rb +1 -1
- data/lib/core/nutella_core.rb +4 -2
- data/lib/core/run_command.rb +8 -0
- data/lib/nutella_framework.rb +1 -0
- data/nutella_framework.gemspec +6 -6
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74e4ed28b0dc3798dd7c0d2316d4cc1b7b4b00dc
|
4
|
+
data.tar.gz: 8b1bd9b75e807c5e061720bdf21a2a367c969d6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7416f84abc2fcde32f84d728d41c9f229e194aadf07be54f77e54231b33f3359f932d1742259064a3e29987072836811cdd485b921fd59f4bff3cf22b34e7bd
|
7
|
+
data.tar.gz: 9e03507f6f0a018ad06c64ac5b29b02d6989b5fbebb323ff1edc588e464ddb51aa3351c21bf26fa0c7d5407edef08a77df1529ea2b9a59d3533f8aa919b60bae
|
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.name = "nutella_framework"
|
18
18
|
gem.homepage = "https://github.com/nutella-framework/nutella_framework"
|
19
19
|
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{
|
21
|
-
gem.description = %Q{Nutella is a framework to
|
20
|
+
gem.summary = %Q{A framework to create and run classroom narratives}
|
21
|
+
gem.description = %Q{Nutella is a framework to create and run classroom narratives}
|
22
22
|
gem.email = "tebemis@gmail.com"
|
23
23
|
gem.authors = ["Alessandro Gnoli"]
|
24
24
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/config/config.rb
CHANGED
@@ -5,7 +5,7 @@ module Nutella
|
|
5
5
|
# Calling this method (Nutella.config) simply returns and instance of
|
6
6
|
# PersistedHash linked to file config.json in nutella home directory
|
7
7
|
def Nutella.config
|
8
|
-
PersistedHash.new("#{
|
8
|
+
PersistedHash.new( "#{ENV['HOME']}/.nutella/config.json" )
|
9
9
|
end
|
10
10
|
|
11
11
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module Nutella
|
4
5
|
|
@@ -90,6 +91,8 @@ module Nutella
|
|
90
91
|
private
|
91
92
|
|
92
93
|
def store_hash(hash)
|
94
|
+
dirname = File.dirname(@config_file)
|
95
|
+
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
93
96
|
File.open(@config_file, 'w+') do |f|
|
94
97
|
f.write(JSON.pretty_generate(hash))
|
95
98
|
end
|
data/lib/config/runlist.rb
CHANGED
@@ -26,7 +26,7 @@ module Nutella
|
|
26
26
|
# Calling this method (Nutella.runlist) simply returns and instance of
|
27
27
|
# RunListHash linked to file runlist.json in the nutella home directory
|
28
28
|
def Nutella.runlist
|
29
|
-
RunListHash.new( "#{
|
29
|
+
RunListHash.new( "#{ENV['HOME']}/.nutella/runlist.json" )
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
@@ -35,12 +35,13 @@ module Nutella
|
|
35
35
|
|
36
36
|
def install_local_broker
|
37
37
|
# Clone, cd and npm install
|
38
|
-
|
38
|
+
broker_version = 'v0.28.1'
|
39
|
+
out1 = system "git clone -b #{broker_version} --depth 1 git://github.com/mcollina/mosca.git #{Nutella.config['broker_dir']} > /dev/null 2>&1"
|
39
40
|
Dir.chdir(Nutella.config['broker_dir'])
|
40
41
|
out2 = system 'npm install > /dev/null 2>&1'
|
41
42
|
|
42
43
|
# Add startup script and make it executable
|
43
|
-
File.open('startup', 'w') { |file| file.write("#!/bin/sh\n\nBASEDIR=$(dirname $0)\n$BASEDIR/bin/mosca --http-port 1884 &\necho $! > $BASEDIR/bin/.pid\n") }
|
44
|
+
File.open('startup', 'w') { |file| file.write("#!/bin/sh\n\nBASEDIR=$(dirname $0)\n$BASEDIR/bin/mosca --http-port 1884 > /dev/null 2>&1 &\necho $! > $BASEDIR/bin/.pid\n") }
|
44
45
|
File.chmod( 0755, 'startup' )
|
45
46
|
|
46
47
|
# Write configuration into config.json
|
@@ -47,8 +47,13 @@ module Nutella
|
|
47
47
|
|
48
48
|
|
49
49
|
def is_template_a_git_repo?( template_git_url )
|
50
|
+
return false unless template_git_url =~ /\A#{URI::regexp(['http', 'https'])}\z/
|
50
51
|
begin
|
51
|
-
|
52
|
+
if template_git_url.end_with? '.git'
|
53
|
+
tmp_dest_dir = template_git_url[template_git_url.rindex('/')+1 .. template_git_url.length-5]
|
54
|
+
else
|
55
|
+
tmp_dest_dir = template_git_url[template_git_url.rindex('/')+1 .. template_git_url.length]
|
56
|
+
end
|
52
57
|
clone_template_from_repo_to( template_git_url, tmp_dest_dir )
|
53
58
|
return validate_template "#{Nutella.config['tmp_dir']}/#{tmp_dest_dir}"
|
54
59
|
rescue
|
data/lib/core/commands/new.rb
CHANGED
@@ -46,7 +46,7 @@ module Nutella
|
|
46
46
|
config_file_hash = {
|
47
47
|
:name => cur_prj_dir,
|
48
48
|
:version => '0.1.0',
|
49
|
-
:nutella_version => File.open("#{
|
49
|
+
:nutella_version => File.open("#{Nutella.config['nutella_home']}VERSION", 'rb').read,
|
50
50
|
:type => 'project',
|
51
51
|
:description => 'A quick description of your project'
|
52
52
|
}
|
data/lib/core/commands/start.rb
CHANGED
@@ -38,7 +38,7 @@ module Nutella
|
|
38
38
|
|
39
39
|
# Check that there is at least a regular bot that will be started,
|
40
40
|
# otherwise it makes no sense to create a run
|
41
|
-
if
|
41
|
+
if bots_list_wo_project(cur_prj_dir, params).empty? && project_bots_started?
|
42
42
|
console.warn "Run #{run} not created: your project bots are already started and you specified no regular bots exclusively for this run"
|
43
43
|
return
|
44
44
|
end
|
@@ -48,7 +48,7 @@ module Nutella
|
|
48
48
|
return unless add_to_run_list( run_id, cur_prj_dir )
|
49
49
|
|
50
50
|
# If running on the internal broker, start it if needed
|
51
|
-
if
|
51
|
+
if running_on_internal_broker?
|
52
52
|
return unless start_internal_broker
|
53
53
|
end
|
54
54
|
|
@@ -70,7 +70,7 @@ module Nutella
|
|
70
70
|
private
|
71
71
|
|
72
72
|
|
73
|
-
def
|
73
|
+
def bots_list_wo_project( cur_prj_dir, params )
|
74
74
|
# Fetch the list of project bots
|
75
75
|
project_bots_list = Nutella.current_project.config['project_bots']
|
76
76
|
run_bots_list = run_actors_list("#{cur_prj_dir}/bots/")
|
@@ -90,7 +90,7 @@ module Nutella
|
|
90
90
|
def project_bots_started?
|
91
91
|
project_name = Nutella.current_project.config['name']
|
92
92
|
tmux_session_name = "#{project_name}-project-bots"
|
93
|
-
|
93
|
+
Tmux.session_exist? tmux_session_name
|
94
94
|
end
|
95
95
|
|
96
96
|
|
@@ -186,8 +186,8 @@ module Nutella
|
|
186
186
|
# Actor is not running and there is no pid file so we try to start
|
187
187
|
# the actor and create a new pid file. Note that the pid file is created by
|
188
188
|
# the startup script!
|
189
|
-
nutella_config_file = "#{Nutella.config['
|
190
|
-
runs_list_file = "#{Nutella.config['
|
189
|
+
nutella_config_file = "#{Nutella.config['config_dir']}config.json"
|
190
|
+
runs_list_file = "#{Nutella.config['config_dir']}runlist.json"
|
191
191
|
if nutella_config_file==nil || runs_list_file==nil
|
192
192
|
return false
|
193
193
|
end
|
@@ -231,7 +231,7 @@ module Nutella
|
|
231
231
|
# Fetch bots dir
|
232
232
|
bots_dir = "#{cur_prj_dir}/bots/"
|
233
233
|
# Start the appropriate bots
|
234
|
-
|
234
|
+
bots_list_wo_project( cur_prj_dir, params ).each { |bot| start_bot(bots_dir, bot, tmux) }
|
235
235
|
true
|
236
236
|
end
|
237
237
|
|
@@ -255,7 +255,7 @@ module Nutella
|
|
255
255
|
unless project_bots_list.nil? || project_bots_list.empty?
|
256
256
|
console.success "Do `tmux attach-session -t #{tmux_session_name}` to monitor your project bots."
|
257
257
|
end
|
258
|
-
if
|
258
|
+
if bots_list_wo_project(cur_prj_dir, params).empty?
|
259
259
|
console.success 'No tmux session was created for this run because you specified no regular bots exclusively for this run'
|
260
260
|
else
|
261
261
|
console.success "Do `tmux attach-session -t #{run_id}` to monitor your bots."
|
data/lib/core/commands/stop.rb
CHANGED
data/lib/core/nutella_core.rb
CHANGED
@@ -29,14 +29,16 @@ module Nutella
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# This method initializes the nutella configuration file (config.json) with:
|
32
|
-
# -
|
32
|
+
# - nutella_home: the directory nutella is installed in
|
33
33
|
# - tmp_dir: temporary directory used when installing remote templates
|
34
|
+
# - config_dir: directory where the configuration files are stored in
|
34
35
|
# - broker_dir: directory where the local broker is installed in
|
35
36
|
# - main_interface_port: the port used to serve interfaces
|
36
37
|
def Nutella.init
|
37
38
|
Nutella.config['nutella_home'] = NUTELLA_HOME
|
38
39
|
Nutella.config['tmp_dir'] = "#{NUTELLA_HOME}.tmp/"
|
39
|
-
Nutella.config['
|
40
|
+
Nutella.config['config_dir'] = "#{ENV['HOME']}/.nutella/"
|
41
|
+
Nutella.config['broker_dir'] = "#{Nutella.config['config_dir']}broker/"
|
40
42
|
Nutella.config['main_interface_port'] = 57880
|
41
43
|
end
|
42
44
|
|
data/lib/core/run_command.rb
CHANGED
@@ -93,6 +93,14 @@ module Nutella
|
|
93
93
|
end
|
94
94
|
|
95
95
|
|
96
|
+
# If the broker is set to one of the current ip addresses,
|
97
|
+
# localhost or 127.0.0.1 return true.
|
98
|
+
def running_on_internal_broker?
|
99
|
+
broker = Nutella.config['broker']
|
100
|
+
Socket.ip_address_list.find_all{|a| a.ipv4? }.map{|a| a.ip_address}.include?(broker) || broker == 'localhost' || broker == '127.0.0.1'
|
101
|
+
end
|
102
|
+
|
103
|
+
|
96
104
|
end
|
97
105
|
|
98
106
|
end
|
data/lib/nutella_framework.rb
CHANGED
data/nutella_framework.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: nutella_framework 0.3.
|
5
|
+
# stub: nutella_framework 0.3.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "nutella_framework"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Alessandro Gnoli"]
|
14
|
-
s.date = "2015-
|
15
|
-
s.description = "Nutella is a framework to
|
14
|
+
s.date = "2015-02-26"
|
15
|
+
s.description = "Nutella is a framework to create and run classroom narratives"
|
16
16
|
s.email = "tebemis@gmail.com"
|
17
17
|
s.executables = ["nutella"]
|
18
18
|
s.extra_rdoc_files = [
|
@@ -70,8 +70,8 @@ Gem::Specification.new do |s|
|
|
70
70
|
]
|
71
71
|
s.homepage = "https://github.com/nutella-framework/nutella_framework"
|
72
72
|
s.licenses = ["MIT"]
|
73
|
-
s.rubygems_version = "2.
|
74
|
-
s.summary = "
|
73
|
+
s.rubygems_version = "2.4.3"
|
74
|
+
s.summary = "A framework to create and run classroom narratives"
|
75
75
|
|
76
76
|
if s.respond_to? :specification_version then
|
77
77
|
s.specification_version = 4
|
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.3.
|
4
|
+
version: 0.3.1
|
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-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ansi
|
@@ -270,8 +270,7 @@ dependencies:
|
|
270
270
|
- - "~>"
|
271
271
|
- !ruby/object:Gem::Version
|
272
272
|
version: '0'
|
273
|
-
description: Nutella is a framework to
|
274
|
-
applications
|
273
|
+
description: Nutella is a framework to create and run classroom narratives
|
275
274
|
email: tebemis@gmail.com
|
276
275
|
executables:
|
277
276
|
- nutella
|
@@ -347,8 +346,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
347
346
|
version: '0'
|
348
347
|
requirements: []
|
349
348
|
rubyforge_project:
|
350
|
-
rubygems_version: 2.
|
349
|
+
rubygems_version: 2.4.3
|
351
350
|
signing_key:
|
352
351
|
specification_version: 4
|
353
|
-
summary:
|
352
|
+
summary: A framework to create and run classroom narratives
|
354
353
|
test_files: []
|