ferb 0.6.1 → 0.6.2

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.
Files changed (2) hide show
  1. data/lib/method_args.rb +29 -8
  2. metadata +1 -1
data/lib/method_args.rb CHANGED
@@ -21,9 +21,16 @@ class MethodArgs
21
21
  MAX_ARGS = 20
22
22
  attr_reader :params
23
23
 
24
+ def test_method(object,meth,*args)
25
+ m = object.method(meth)
26
+ m.call(*args)
27
+ end
28
+
24
29
  def output_method_info(klass, object, meth, is_singleton = false)
25
30
  @params = nil
26
31
  @values = nil
32
+ @arg_count = nil
33
+ @arity = nil
27
34
  num_args = 0
28
35
  unless %w[initialize].include?(meth.to_s)
29
36
  if is_singleton
@@ -38,6 +45,11 @@ class MethodArgs
38
45
  if event[/call/] && classname == MethodArgsHelper && id == meth
39
46
  @params = eval("local_variables", binding)
40
47
  @values = eval("local_variables.map{|x| eval(x)}", binding)
48
+ if (@arg_count >= @arity) and (@params.length > @arity)
49
+ if @values[-1].nil?
50
+ @params[-1] = "&#{@params[-1]}"
51
+ end
52
+ end
41
53
  throw :done
42
54
  end
43
55
  rescue Exception
@@ -45,13 +57,19 @@ class MethodArgs
45
57
  }
46
58
  if arity >= 0
47
59
  num_args = arity
48
- catch(:done){ object.send(meth, *(0...arity)) }
60
+ catch(:done) do
61
+ @arg_count = arity
62
+ @arity = arity
63
+ test_method(object,meth,*(0...arity))
64
+ end
49
65
  else
50
66
  # determine number of args (including splat & block)
51
67
  MAX_ARGS.downto(arity.abs - 1) do |i|
52
68
  catch(:done) do
53
69
  begin
54
- object.send(meth, *(0...i))
70
+ @arg_count = i
71
+ @arity = arity.abs - 1
72
+ test_method(object,meth,*(0...i))
55
73
  rescue Exception
56
74
  end
57
75
  end
@@ -66,7 +84,15 @@ class MethodArgs
66
84
  end
67
85
  args = (0...arity.abs-1).to_a
68
86
  catch(:done) do
69
- args.empty? ? object.send(meth) : object.send(meth, *args)
87
+ if args.empty?
88
+ @arg_count = 0
89
+ @arity = 0
90
+ test_method(object,meth)
91
+ else
92
+ @arg_count = args.length
93
+ @arity = args.length
94
+ test_method(object,meth,*args)
95
+ end
70
96
  end
71
97
  end
72
98
  set_trace_func(nil)
@@ -80,12 +106,7 @@ class MethodArgs
80
106
  end.first
81
107
  end
82
108
  original_params = @params
83
- @params ||= []
84
- @params = @params[0,num_args]
85
109
  @params = fmt_params.call(@params,arity)
86
- if @params.length < original_params.length
87
- @params << "&#{original_params[-1]}"
88
- end
89
110
  set_trace_func(nil)
90
111
  end
91
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Powers