mruby_sandbox 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/mruby_sandbox/version.rb +1 -1
- data/lib/mruby_sandbox.rb +11 -11
- data/mruby_sandbox.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4153c1ee7cc6e9c720dc076ac9c5f36b4af7bd18
|
4
|
+
data.tar.gz: 31afc8cb58cdc4abd03d83b1cf72207c8e65c789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79148c19851f533cc0acd46408dae7f86905376cfabcfecfcfd0a2372101c8641109f945d75d42eaec06e000f387db272de17589804ab084afe9b5db26b4289a
|
7
|
+
data.tar.gz: 1d3d6d9ce89fa5e97a97b5bc1859b1c2cc1127dce92b5672f93d9c2eb637962722f9f80abdb25c88683836566b12f1ffb63ee250da59af076a0dc6efa066acf7
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mruby_sandbox (0.
|
5
|
-
pipe_rpc (~> 0.
|
4
|
+
mruby_sandbox (0.4.0)
|
5
|
+
pipe_rpc (~> 0.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.2.5)
|
11
11
|
json (1.8.3)
|
12
|
-
pipe_rpc (0.
|
12
|
+
pipe_rpc (0.3.2)
|
13
13
|
json
|
14
14
|
rspec (3.4.0)
|
15
15
|
rspec-core (~> 3.4.0)
|
16
16
|
rspec-expectations (~> 3.4.0)
|
17
17
|
rspec-mocks (~> 3.4.0)
|
18
|
-
rspec-core (3.4.
|
18
|
+
rspec-core (3.4.4)
|
19
19
|
rspec-support (~> 3.4.0)
|
20
20
|
rspec-expectations (3.4.0)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
rspec-its (1.2.0)
|
24
24
|
rspec-core (>= 3.0.0)
|
25
25
|
rspec-expectations (>= 3.0.0)
|
26
|
-
rspec-mocks (3.4.
|
26
|
+
rspec-mocks (3.4.1)
|
27
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
28
|
rspec-support (~> 3.4.0)
|
29
29
|
rspec-mocks-matchers-send_message (0.3.1)
|
data/lib/mruby_sandbox.rb
CHANGED
@@ -15,22 +15,13 @@ class MrubySandbox
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.finalize(pid)
|
19
|
-
proc do |id|
|
20
|
-
Process.kill 9, pid
|
21
|
-
Process.wait pid
|
22
|
-
logger.debug "Sandbox(#{id}) garbage collected and process #{pid} killed"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
18
|
def initialize
|
27
19
|
input, w = IO.pipe
|
28
20
|
r, output = IO.pipe
|
29
|
-
pid = spawn(executable, in: r, out: w)
|
21
|
+
@pid = spawn(executable, in: r, out: w)
|
30
22
|
r.close; w.close
|
31
23
|
|
32
|
-
self.class.logger.debug "Sandbox(#{__id__}) created with process #{pid}"
|
33
|
-
ObjectSpace.define_finalizer(self, self.class.finalize(pid))
|
24
|
+
self.class.logger.debug "Sandbox(#{__id__}) created with process #{@pid}"
|
34
25
|
|
35
26
|
@hub = PipeRpc::Hub.new(input: input, output: output)
|
36
27
|
@data = {}
|
@@ -66,6 +57,15 @@ class MrubySandbox
|
|
66
57
|
end
|
67
58
|
end
|
68
59
|
|
60
|
+
def tear_down
|
61
|
+
return unless @pid
|
62
|
+
@hub.cancel
|
63
|
+
Process.kill 9, @pid
|
64
|
+
Process.wait @pid
|
65
|
+
self.class.logger.debug "Sandbox(#{__id__}) teared down and process #{@pid} killed"
|
66
|
+
@pid = nil
|
67
|
+
end
|
68
|
+
|
69
69
|
private
|
70
70
|
|
71
71
|
def executable
|
data/mruby_sandbox.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = ["build_mruby_sandbox"]
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_runtime_dependency "pipe_rpc", "~> 0.
|
24
|
+
spec.add_runtime_dependency "pipe_rpc", "~> 0.3"
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.8"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.4"
|
27
27
|
spec.add_development_dependency "rspec-its"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mruby_sandbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Aue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pipe_rpc
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|