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 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.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", ">= 0.2.3"
16
- s.add_dependency "ruby_parser", "~> 2.0"
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.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-09-14 00:00:00.000000000 Z
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: &71965870 !ruby/object:Gem::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.2.3
21
+ version: '0.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *71965870
24
+ version_requirements: *82865840
25
25
  - !ruby/object:Gem::Dependency
26
- name: ruby_parser
27
- requirement: &71965480 !ruby/object:Gem::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: '2.0'
32
+ version: '4.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *71965480
35
+ version_requirements: *82862480
36
36
  description:
37
37
  email: robertodarioseminara@gmail.com
38
38
  executables: []