object_tracker 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/object_tracker/version.rb +1 -1
- data/lib/object_tracker.rb +8 -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: f6aa49425a86909a7291774b6ace79da2d1da440
|
4
|
+
data.tar.gz: 9fd148b69e64688a29f575af09a6f34f0d0c5564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3ab300a4893a86d649092fd0fc4ebf8b6b3384b9f76fc1a8fb61b583588019b044ac19645d0ee11ec07bd331cf33aa13e6005f3135c84f036db9b39a2b0d93c
|
7
|
+
data.tar.gz: 33a47b94586c4a8b786a4ac9ea9d84a665d3b59e3512ebce1b05f714817203ccd5c31c477b594d9d8e10ca253a4ff9ca6f33143a28ce5af0f63fabc131fbf54f
|
data/lib/object_tracker.rb
CHANGED
@@ -23,7 +23,7 @@ module ObjectTracker
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def tracking?(method_name)
|
26
|
-
tracking.keys.include?(method_name.to_sym)
|
26
|
+
tracking.keys.include?(cleanse(method_name).to_sym)
|
27
27
|
end
|
28
28
|
|
29
29
|
def track_not(*args)
|
@@ -43,11 +43,15 @@ module ObjectTracker
|
|
43
43
|
# PRIVATE
|
44
44
|
#
|
45
45
|
|
46
|
+
def cleanse(str)
|
47
|
+
str.to_s.sub(/^[#.]/, '')
|
48
|
+
end
|
49
|
+
|
46
50
|
def track!(method_names = nil)
|
47
51
|
mod = Module.new
|
48
52
|
Array(method_names || tracking).each do |method_name, source_def|
|
49
53
|
mod.module_eval <<-RUBY, __FILE__, __LINE__
|
50
|
-
def #{method_name}(*args, &block)
|
54
|
+
def #{cleanse(method_name)}(*args, &block)
|
51
55
|
msg = %Q( * called "#{method_name}" )
|
52
56
|
msg << "with " << args.join(', ') << " " if args.any?
|
53
57
|
msg << "[#{source_def}]"
|
@@ -81,7 +85,8 @@ module ObjectTracker
|
|
81
85
|
|
82
86
|
def track_with_source(obj, method_name)
|
83
87
|
source = obj.method(method_name).source_location || ['RUBY CORE']
|
84
|
-
|
88
|
+
prefix = obj.class == Class ? '.' : '#'
|
89
|
+
tracking["#{prefix}#{method_name}".to_sym] = source.join(':').split('/').last(5).join('/')
|
85
90
|
end
|
86
91
|
|
87
92
|
def tracking
|