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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 828579d2303be3fb9e31c580619137ec6d1342d4
4
- data.tar.gz: 81cbe724f1c178d7e71b53960b1742f6bcb68d2f
3
+ metadata.gz: 38c819172d891939c51b5e14df92d15f8760ffc7
4
+ data.tar.gz: dd482623f159888438a9c57680e8670b787797b8
5
5
  SHA512:
6
- metadata.gz: 6a9232ebe26755045c48f9c00e25f38bb3a0029da7ad461b5988383d396e5e19e84032db7eaed6ea60e1200ce5bd31321fccf8aceb05343b0b62bec3fbe17f4d
7
- data.tar.gz: 6d91d3108935717fc55cb289f6d3e1c6a0bccaaeec82b9f91750948cd5d21b8e5bac9e5a4d6e08e63673d838cbf316ade16b685494fa92db3b487f5c52600aac
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
@@ -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
- time = Benchmark.realtime { result = super }
60
- msg << " (" << time.to_s << ")"
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
- prefix = obj.class == Class ? '.' : '#'
96
- tracking["#{prefix}#{method_name}".to_sym] = source.join(':').split('/').last(5).join('/')
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
@@ -1,3 +1,3 @@
1
1
  module ObjectTracker
2
- VERSION = '1.1.3'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
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.1.3
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-02 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler