object_tracker 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/object_tracker.rb +14 -5
- data/lib/object_tracker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c819172d891939c51b5e14df92d15f8760ffc7
|
4
|
+
data.tar.gz: dd482623f159888438a9c57680e8670b787797b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e9c235ef8a434f4130946d6d48c603d1b35e79e3a1ed1ed738259f9e679b62db6677fdf9fb74da7476b2ee176629e501d8c8b59de8d3dd0babc483050460611
|
7
|
+
data.tar.gz: 9e665c361430a7d8002649a5da07478adbeb8f9ef729a7eb7f82f2ef33474172b680d1f70ee8f237624b25f1230dd36afb233c823dc50afa2fb3744bb66efb21
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Ruby ObjectTracker
|
1
|
+
# Ruby ObjectTracker [![Gem Version](https://badge.fury.io/rb/object_tracker.svg)](http://badge.fury.io/rb/object_tracker)
|
2
2
|
|
3
3
|
Track class and instance methods, including arguments and definition source. You can extend a class to track calls to itself and it's
|
4
4
|
instances, or extend instances directly. This can be helpful for debugging by providing info on what methods are being called on your object
|
data/lib/object_tracker.rb
CHANGED
@@ -44,7 +44,7 @@ module ObjectTracker
|
|
44
44
|
#
|
45
45
|
|
46
46
|
def cleanse(str)
|
47
|
-
str.to_s.sub(
|
47
|
+
str.to_s.sub(/^\w*[#.]/, '')
|
48
48
|
end
|
49
49
|
|
50
50
|
def track!(method_names = nil)
|
@@ -56,8 +56,8 @@ module ObjectTracker
|
|
56
56
|
msg << "with " << args.join(', ') << " " if args.any?
|
57
57
|
msg << "[#{source_def}]"
|
58
58
|
result = nil
|
59
|
-
|
60
|
-
msg << " ("
|
59
|
+
bm = Benchmark.measure { result = super }
|
60
|
+
msg << " (%.5f)" % bm.real
|
61
61
|
puts msg
|
62
62
|
@__tracked_calls ||= Set.new
|
63
63
|
@__tracked_calls << "#{method_name}"
|
@@ -92,8 +92,17 @@ module ObjectTracker
|
|
92
92
|
|
93
93
|
def track_with_source(obj, method_name)
|
94
94
|
source = obj.method(method_name).source_location || ['RUBY CORE']
|
95
|
-
|
96
|
-
|
95
|
+
if Class === obj || Module === obj
|
96
|
+
name = obj.name
|
97
|
+
prefix = '.'
|
98
|
+
elsif obj.class === Class
|
99
|
+
prefix = '.'
|
100
|
+
name = obj.class.name
|
101
|
+
else
|
102
|
+
prefix = '#'
|
103
|
+
name = obj.class.name
|
104
|
+
end
|
105
|
+
tracking["#{name}#{prefix}#{method_name}".to_sym] = source.join(':').split('/').last(5).join('/')
|
97
106
|
end
|
98
107
|
|
99
108
|
def tracking
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|