evalhook 0.5.5 → 0.5.6
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.
- data/Rakefile +3 -3
- data/lib/evalhook.rb +11 -38
- data/lib/evalhook/tree_processor.rb +0 -3
- metadata +10 -10
data/Rakefile
CHANGED
@@ -6,14 +6,14 @@ require 'rake/testtask'
|
|
6
6
|
|
7
7
|
spec = Gem::Specification.new do |s|
|
8
8
|
s.name = 'evalhook'
|
9
|
-
s.version = '0.5.
|
9
|
+
s.version = '0.5.6'
|
10
10
|
s.author = 'Dario Seminara'
|
11
11
|
s.email = 'robertodarioseminara@gmail.com'
|
12
12
|
s.platform = Gem::Platform::RUBY
|
13
13
|
s.summary = 'Alternate eval which hook all methods executed in the evaluated code'
|
14
14
|
s.homepage = "http://github.com/tario/evalhook"
|
15
|
-
s.add_dependency "partialruby", "
|
16
|
-
s.add_dependency "
|
15
|
+
s.add_dependency "partialruby", "~> 0.3"
|
16
|
+
s.add_dependency "sexp_processor", "~> 4.0"
|
17
17
|
s.has_rdoc = true
|
18
18
|
s.extra_rdoc_files = [ 'README' ]
|
19
19
|
s.rdoc_options << '--main' << 'README'
|
data/lib/evalhook.rb
CHANGED
@@ -38,28 +38,6 @@ module EvalHook
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
class Packet
|
42
|
-
def initialize(emulationcode) #:nodoc:
|
43
|
-
@emulationcode = emulationcode
|
44
|
-
end
|
45
|
-
|
46
|
-
# Executes the code with a given binding, source name (optional) and line (optional)
|
47
|
-
#
|
48
|
-
# See EvalHook::HookHandler#packet for more info
|
49
|
-
#
|
50
|
-
# Example:
|
51
|
-
#
|
52
|
-
# hook_handler = HookHandler.new
|
53
|
-
#
|
54
|
-
# pack = hook_handler.packet('print "hello world\n"')
|
55
|
-
# 10.times do
|
56
|
-
# pack.run
|
57
|
-
# end
|
58
|
-
def run(binding_, name = "(eval)", line = 1)
|
59
|
-
eval(@emulationcode, binding_, name, line)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
41
|
class HookHandler
|
64
42
|
|
65
43
|
include RedirectHelper
|
@@ -71,6 +49,16 @@ module EvalHook
|
|
71
49
|
self.base_namespace = Object
|
72
50
|
end
|
73
51
|
|
52
|
+
def partialruby_context
|
53
|
+
unless @partialruby_context
|
54
|
+
@partialruby_context = PartialRuby::Context.new
|
55
|
+
@partialruby_context.pre_process do |tree|
|
56
|
+
EvalHook::TreeProcessor.new(self).process(tree)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
@partialruby_context
|
60
|
+
end
|
61
|
+
|
74
62
|
def base_namespace=( obj )
|
75
63
|
if obj.instance_of? Symbol
|
76
64
|
@base_namespace = obj
|
@@ -272,22 +260,7 @@ module EvalHook
|
|
272
260
|
# pack.run
|
273
261
|
# end
|
274
262
|
def packet(code)
|
275
|
-
|
276
|
-
tree = nil
|
277
|
-
|
278
|
-
begin
|
279
|
-
tree = RubyParser.new.parse code
|
280
|
-
rescue
|
281
|
-
raise SyntaxError
|
282
|
-
end
|
283
|
-
|
284
|
-
context = PartialRuby::PureRubyContext.new
|
285
|
-
|
286
|
-
tree = EvalHook::TreeProcessor.new(self).process(tree)
|
287
|
-
|
288
|
-
emulationcode = context.emul tree
|
289
|
-
|
290
|
-
EvalHook::Packet.new(emulationcode)
|
263
|
+
partialruby_context.packet(code)
|
291
264
|
end
|
292
265
|
|
293
266
|
if ($evalmimic_defined)
|
@@ -18,13 +18,10 @@ you should have received a copy of the gnu general public license
|
|
18
18
|
along with evalhook. if not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
20
|
=end
|
21
|
-
require "ruby_parser"
|
22
21
|
require "partialruby"
|
23
22
|
require "sexp_processor"
|
24
23
|
|
25
24
|
module EvalHook
|
26
|
-
|
27
|
-
|
28
25
|
class TreeProcessor < SexpProcessor
|
29
26
|
def initialize(hook_handler)
|
30
27
|
super()
|
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.5.
|
4
|
+
version: 0.5.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: partialruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &82865840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: '0.3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *82865840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: sexp_processor
|
27
|
+
requirement: &82862480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '4.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *82862480
|
36
36
|
description:
|
37
37
|
email: robertodarioseminara@gmail.com
|
38
38
|
executables: []
|