muzang-plugins 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,20 +1,18 @@
1
1
  module Muzang
2
2
  module Plugins
3
- module Safe; end
4
- class << Safe
3
+ class Safe
5
4
  def safe(code, sandbox=nil)
6
5
  error = nil
7
6
 
8
7
  begin
9
8
  $-w = nil
10
- sandbox ||= Object.new.taint
11
- yield(sandbox) if block_given?
9
+ @sandbox ||= Object.new
10
+ yield(@sandbox) if block_given?
12
11
 
13
- $SAFE = 5
14
- value = eval(code, sandbox.send(:binding))
15
- result = Marshal.load(Marshal.dump(value))
12
+ $SAFE = 3
13
+ result = eval(code, @sandbox.send(:binding))
16
14
  rescue Exception => error
17
- error = Marshal.load(Marshal.dump(error))
15
+ error = error
18
16
  end
19
17
 
20
18
  return result, error
@@ -46,7 +44,8 @@ module Muzang
46
44
 
47
45
  def safe(*args, &block)
48
46
  unless args.first =~ /EM|EventMachine/
49
- Safe::safe(*args, &block)
47
+ @safe ||= Safe.new
48
+ @safe.safe(*args, &block)
50
49
  end
51
50
  end
52
51
  end
@@ -1,5 +1,5 @@
1
1
  module Muzang
2
2
  module Plugins
3
- VERSION = "1.1.5"
3
+ VERSION = "1.1.6"
4
4
  end
5
5
  end
@@ -41,5 +41,22 @@ module Muzang::Plugins
41
41
  eventually(true) { @connection.messages.include? "Error: Exception" }
42
42
  end
43
43
  end
44
+
45
+ it "should keep state" do
46
+ @message.message = '% @state = {:true => true}'
47
+ EM.run do
48
+ @message_state = @message.dup
49
+ @message_state.message = '% "super #{@state}"'
50
+ @eval.call(@connection, @message)
51
+ EM.add_timer(0.5) do
52
+ @eval.call(@connection, @message_state)
53
+ end
54
+
55
+ eventually(true) do
56
+ @connection.messages.include?("{:true=>true}") &&
57
+ @connection.messages.include?("super {:true=>true}")
58
+ end
59
+ end
60
+ end
44
61
  end
45
62
  end
@@ -12,4 +12,4 @@ class ConnectionMock
12
12
  @message_count += 1
13
13
  (@messages ||= []) << message
14
14
  end
15
- end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muzang-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: