evalhook 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
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.2'
9
+ s.version = '0.5.3'
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.0"
16
- s.add_dependency "ruby_parser", ">= 2.0.6"
15
+ s.add_dependency "partialruby", ">= 0.2.3"
16
+ s.add_dependency "ruby_parser", "~> 2.0.0"
17
17
  s.has_rdoc = true
18
18
  s.extra_rdoc_files = [ 'README' ]
19
19
  s.rdoc_options << '--main' << 'README'
@@ -68,7 +68,11 @@ module EvalHook
68
68
  def process_call(tree)
69
69
  original_receiver = tree[1]
70
70
 
71
- receiver = process(original_receiver|| s(:self))
71
+ receiver = if original_receiver
72
+ s(:call, hook_handler_reference, :private_method_check, s(:arglist,process(original_receiver),s(:lit,tree[2])))
73
+ else
74
+ s(:self)
75
+ end
72
76
 
73
77
  firstcall = nil
74
78
  if tree[3] == s(:arglist) or tree[3] == nil
data/lib/evalhook.rb CHANGED
@@ -284,6 +284,11 @@ module EvalHook
284
284
  end
285
285
  end
286
286
 
287
+ def private_method_check(recv, mname)
288
+ recv.public_method(mname) rescue NameError raise NoMethodError
289
+ recv
290
+ end
291
+
287
292
  end
288
293
 
289
294
  module ModuleMethods
@@ -0,0 +1,32 @@
1
+ require "rubygems"
2
+ require "evalhook"
3
+
4
+ describe EvalHook::HookHandler, "hook handler hooks" do
5
+
6
+ it "should raise NoMethodError when tring to call private method" do
7
+ hh = EvalHook::HookHandler.new
8
+ lambda {
9
+ hh.evalhook("{}.system('ls -l')", binding)
10
+ }.should raise_error(NoMethodError)
11
+ end
12
+
13
+
14
+ it "should raise NoMethodError when tring to call private method" do
15
+ hh = EvalHook::HookHandler.new
16
+ lambda {
17
+ hh.evalhook("
18
+ class CALL_SPEC_TEST
19
+ def foo
20
+ bar
21
+ end
22
+ private
23
+ def bar
24
+ end
25
+ end
26
+
27
+ CALL_SPEC_TEST.new.foo
28
+ ", binding)
29
+ }.should_not raise_error
30
+ end
31
+
32
+ end
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.2
4
+ version: 0.5.3
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-04-26 00:00:00.000000000 Z
12
+ date: 2013-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: partialruby
16
- requirement: &71403420 !ruby/object:Gem::Requirement
16
+ requirement: &83073430 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.2.0
21
+ version: 0.2.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *71403420
24
+ version_requirements: *83073430
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ruby_parser
27
- requirement: &71403020 !ruby/object:Gem::Requirement
27
+ requirement: &83072720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.6
32
+ version: 2.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *71403020
35
+ version_requirements: *83072720
36
36
  description:
37
37
  email: robertodarioseminara@gmail.com
38
38
  executables: []
@@ -57,6 +57,7 @@ files:
57
57
  - spec/hook_handler/hook_handler_defaults_spec.rb
58
58
  - spec/hook_handler/hook_handler_multiple_redirect_spec.rb
59
59
  - spec/hook_handler/hook_handler_multiple_spec.rb
60
+ - spec/call/call_spec.rb
60
61
  - spec/validation/hook_handler_spec.rb
61
62
  - LICENSE
62
63
  - AUTHORS