evalhook 0.5.8 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Rakefile +1 -1
- data/lib/evalhook.rb +37 -2
- data/lib/evalhook/tree_processor.rb +2 -9
- metadata +6 -6
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/lib/evalhook.rb
CHANGED
@@ -38,6 +38,21 @@ module EvalHook
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
class Packet
|
42
|
+
def initialize(partialruby_packet, global_variable_name)
|
43
|
+
@partialruby_packet = partialruby_packet
|
44
|
+
@global_variable_name = global_variable_name
|
45
|
+
end
|
46
|
+
|
47
|
+
def run(*args)
|
48
|
+
@partialruby_packet.run(*args)
|
49
|
+
end
|
50
|
+
|
51
|
+
def dispose
|
52
|
+
eval("#{@global_variable_name} = nil") if @global_variable_name
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
41
56
|
class HookHandler
|
42
57
|
|
43
58
|
include RedirectHelper
|
@@ -52,8 +67,12 @@ module EvalHook
|
|
52
67
|
def partialruby_context
|
53
68
|
unless @partialruby_context
|
54
69
|
@partialruby_context = PartialRuby::Context.new
|
70
|
+
|
55
71
|
@partialruby_context.pre_process do |tree|
|
56
|
-
|
72
|
+
@global_variable_name = "$hook_handler_" + rand(10000000000).to_s
|
73
|
+
eval("#{@global_variable_name} = self")
|
74
|
+
|
75
|
+
EvalHook::TreeProcessor.new(self, @global_variable_name).process(tree)
|
57
76
|
end
|
58
77
|
end
|
59
78
|
@partialruby_context
|
@@ -259,8 +278,24 @@ module EvalHook
|
|
259
278
|
# 10.times do
|
260
279
|
# pack.run
|
261
280
|
# end
|
281
|
+
#
|
282
|
+
# pack.dispose
|
283
|
+
#
|
262
284
|
def packet(code)
|
263
|
-
|
285
|
+
@global_variable_name = nil
|
286
|
+
partialruby_packet = partialruby_context.packet(code)
|
287
|
+
|
288
|
+
@all_packets ||= []
|
289
|
+
newpacket = EvalHook::Packet.new(partialruby_packet, @global_variable_name)
|
290
|
+
@all_packets << newpacket
|
291
|
+
newpacket
|
292
|
+
end
|
293
|
+
|
294
|
+
# Disposes all code packets created on this context
|
295
|
+
def dispose
|
296
|
+
if @all_packets
|
297
|
+
@all_packets.each(&:dispose)
|
298
|
+
end
|
264
299
|
end
|
265
300
|
|
266
301
|
if ($evalmimic_defined)
|
@@ -23,8 +23,9 @@ require "sexp_processor"
|
|
23
23
|
|
24
24
|
module EvalHook
|
25
25
|
class TreeProcessor < SexpProcessor
|
26
|
-
def initialize(hook_handler)
|
26
|
+
def initialize(hook_handler, global_variable_name)
|
27
27
|
super()
|
28
|
+
@hh_ref_global_name = global_variable_name
|
28
29
|
@hook_handler = hook_handler
|
29
30
|
@def_scope = Array.new
|
30
31
|
self.require_empty = false
|
@@ -43,14 +44,6 @@ module EvalHook
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def hook_handler_reference
|
46
|
-
# create a global_variable name
|
47
|
-
unless @hh_ref_global_name
|
48
|
-
global_variable_name = "$hook_handler_" + rand(10000000000).to_s
|
49
|
-
eval("#{global_variable_name} = @hook_handler")
|
50
|
-
|
51
|
-
@hh_ref_global_name = global_variable_name.to_sym
|
52
|
-
end
|
53
|
-
|
54
47
|
s(:gvar, @hh_ref_global_name)
|
55
48
|
end
|
56
49
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evalhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: partialruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &82974890 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *82974890
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sexp_processor
|
27
|
-
requirement: &
|
27
|
+
requirement: &82973900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '4.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *82973900
|
36
36
|
description:
|
37
37
|
email: robertodarioseminara@gmail.com
|
38
38
|
executables: []
|