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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b64ab16d9d0b0d15225d24cf7121afb3061e88e8
4
- data.tar.gz: 740e4ee7f4eacbbeba0c36211f4c3e032b505d1f
3
+ metadata.gz: f6aa49425a86909a7291774b6ace79da2d1da440
4
+ data.tar.gz: 9fd148b69e64688a29f575af09a6f34f0d0c5564
5
5
  SHA512:
6
- metadata.gz: c1efef10178e161cb122b2c9a21dd4cf283251551100679c3017553dfefd66387558c3e54a3ff9d8ad64c32a9ffe52ba94a4bf2f1ec5c07766e9f1d4d894d9f7
7
- data.tar.gz: 94ece458adbd7320c1d72b2c1f161d149179055dae3f8780baefe15262181b355c1afefb71b901d81cdc22df68510e70800b405961bea26601df63cf4350e17b
6
+ metadata.gz: c3ab300a4893a86d649092fd0fc4ebf8b6b3384b9f76fc1a8fb61b583588019b044ac19645d0ee11ec07bd331cf33aa13e6005f3135c84f036db9b39a2b0d93c
7
+ data.tar.gz: 33a47b94586c4a8b786a4ac9ea9d84a665d3b59e3512ebce1b05f714817203ccd5c31c477b594d9d8e10ca253a4ff9ca6f33143a28ce5af0f63fabc131fbf54f
@@ -1,3 +1,3 @@
1
1
  module ObjectTracker
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -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
- tracking[method_name.to_sym] = source.join(':').split('/').last(5).join('/')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley