jinyu-debug-tools 0.0.5 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/utils/method_debugger.rb +30 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4eca0e3f24fc6606bb268362ec4a2b488140129
|
4
|
+
data.tar.gz: ca076f86be97abb5e451f98d0cc7f1e764488aac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 622d37fb9dbd6e5c851388100c9c0698ab3961c4faadb8595ac16d3eed8ca804326d3fd55c4ba765101214b7512ec66a91b19140ba082989d0cae92b95b416bc
|
7
|
+
data.tar.gz: 3d3e0ef9fceaeb99b0190a690addc972d540480e3a5adcd4a91010db6f61eb221fb0ffedc8dc406a1e54b0578153f42128f9ac19005a643b2f96488030e65fda
|
@@ -1,9 +1,10 @@
|
|
1
|
-
module JinyuDebugTools
|
2
1
|
module MethodDebugger
|
3
2
|
def self.included(sub_klass)
|
3
|
+
|
4
4
|
sub_klass.class_eval do
|
5
5
|
@@__debug_log = []
|
6
6
|
@@__method_table = Hash.new{|hash, key| hash[key] = {}}
|
7
|
+
@@__singleton_method_table = Hash.new{|hash, key| hash[key] = {}}
|
7
8
|
|
8
9
|
def self.method_added(method_name)
|
9
10
|
return if @@__method_table[self][method_name]
|
@@ -17,14 +18,40 @@ module JinyuDebugTools
|
|
17
18
|
define_method(method_name) do |*method_args, &block|
|
18
19
|
caller_file = caller[0].split('/').last
|
19
20
|
puts "jinyu.debug: #{caller_file} calls #{method_name}, #{method_args.map(&:class)}"
|
21
|
+
#p "#{self}.send(__#{method_name})"
|
22
|
+
#puts "\n"
|
20
23
|
|
21
|
-
# hit 'super' keyword issue, check with
|
22
|
-
|
24
|
+
# hit 'super' keyword issue, check with
|
25
|
+
#https://stackoverflow.com/questions/18448831/calling-method-in-parent-class-from-subclass-methods-in-ruby
|
23
26
|
#self.send("__#{method_name}".to_sym, *method_args, &block)
|
24
27
|
|
25
28
|
self_class.instance_method("__#{method_name}".to_sym).bind(self).call(*method_args, &block)
|
26
29
|
end
|
27
30
|
end
|
31
|
+
|
32
|
+
def self.singleton_method_added(method_name)
|
33
|
+
return if method_name == :singleton_method_added
|
34
|
+
|
35
|
+
return if @@__singleton_method_table[self][method_name]
|
36
|
+
@@__singleton_method_table[self][method_name] = true
|
37
|
+
|
38
|
+
return if method_name.to_s.match(/^__/)
|
39
|
+
|
40
|
+
singleton_class.class_eval do
|
41
|
+
alias_method "__#{method_name}".to_sym, method_name
|
42
|
+
self_class = self
|
43
|
+
|
44
|
+
define_method(method_name) do |*method_args, &block|
|
45
|
+
caller_file = caller[0].split('/').last
|
46
|
+
puts "jinyu.debug: #{caller_file} calls #{method_name}, #{method_args.map(&:class)}"
|
47
|
+
|
48
|
+
# hit 'super' keyword issue, check with
|
49
|
+
#https://stackoverflow.com/questions/18448831/calling-method-in-parent-class-from-subclass-methods-in-ruby #self.send("__#{method_name}".to_sym, *method_args, &block)
|
50
|
+
|
51
|
+
self_class.instance_method("__#{method_name}".to_sym).bind(self).call(*method_args, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
28
55
|
end
|
29
56
|
end
|
30
57
|
end
|