jinyu-debug-tools 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/utils/method_debugger.rb +14 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce6a9eb9305ef6c54795a0d81ba79e34566d204b
4
- data.tar.gz: 6cc7b799c06e4ed5f6baa6d6161e4271a9566ce8
3
+ metadata.gz: 04b28856f2f9ef3e5b61da97680c38fbf488406b
4
+ data.tar.gz: aadcf61df0c48701a89575e4cefe3f5280588aa5
5
5
  SHA512:
6
- metadata.gz: e1d91a5ed67df0f46b464c6d514d89b08af4ea1e5b7a59752821f6673e5dc7a20fa2b72cabf1978dbd48380a6298f91de2d6c0512d3629b1f1056b3dc4096d27
7
- data.tar.gz: a54b4f8217b5fb5ed89745cf9dc63efa62ad5771daa2aafcb934ba2694abe4a3cc0a5ff6757543d7a90907141af7df3db8ced828eafa2cd490baffe53e322425
6
+ metadata.gz: cabcae7d7efbf8ca7067eed783143ef8cc051b07db5959d08fd73782662661adaba505eb0f713e3e4670c3561af91231cfd739f42edbff6aba179fc2567a0717
7
+ data.tar.gz: c1eff24c9ae617bf7f86d632eeb79f925f5c35af54af29f2c00d9f48acd0fa368cd3bc7f32f70c44a90c6420b7ba2867bdc1672f54eefb96c6a8e478907d2f40
@@ -2,19 +2,27 @@ module JinyuDebugTools
2
2
  module MethodDebugger
3
3
  def self.included(sub_klass)
4
4
  sub_klass.class_eval do
5
- @method_table = {}
5
+ @@__debug_log = []
6
+ @@__method_table = Hash.new{|hash, key| hash[key] = {}}
6
7
 
7
8
  def self.method_added(method_name)
8
- return if @method_table[method_name]
9
- @method_table[method_name] = true
10
- return if method_name.to_s.match(/^____/)
9
+ return if @@__method_table[self][method_name]
10
+ @@__method_table[self][method_name] = true
11
11
 
12
+ return if method_name.to_s.match(/^__/)
13
+ #p "alias_method #{self}.__#{method_name}, #{method_name}"
12
14
  alias_method "__#{method_name}".to_sym, method_name
15
+ self_class = self
13
16
 
14
17
  define_method(method_name) do |*method_args, &block|
15
18
  caller_file = caller[0].split('/').last
16
- puts "jinyu.debug: #{caller_file} calls #{method_name}, #{method_args.map(&:class)}" if !method_name.to_sym.match(/^__/)
17
- self.send("__#{method_name}".to_sym, *method_args, &block)
19
+ puts "jinyu.debug: #{caller_file} calls #{method_name}, #{method_args.map(&:class)}"
20
+
21
+ # hit 'super' keyword issue, check with https://stackoverflow.com/questions/18448831
22
+ # remove line below
23
+ #self.send("__#{method_name}".to_sym, *method_args, &block)
24
+
25
+ self_class.instance_method("__#{method_name}".to_sym).bind(self).call(*method_args, &block)
18
26
  end
19
27
  end
20
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jinyu-debug-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukai Jin