object_tracker 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console.rb +21 -0
- data/lib/object_tracker.rb +16 -8
- data/lib/object_tracker/version.rb +1 -1
- data/object_tracker.gemspec +2 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87e38e45c8d6bb9872888530e0a0f7cc4de8bd69
|
4
|
+
data.tar.gz: 5bc4f026027c89e0db0f1364221217534496ed4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9302bad570cb193fde06f0dca7793179e10a2e41dfee6a7d4853bb41729aaeacdae7909484dbc709681c1a4800c21ee1faba6bec61846576d49327d8b9fea596
|
7
|
+
data.tar.gz: 02d75cc428385665bd4173c201011c050ba27d7a8721f188788fc98b09f18e7f8b36109bd2a6aaf0043402e9989cc419a7acdbd21b976566d05a0e4d83491dca
|
data/bin/console.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'pp'
|
5
|
+
require 'object_tracker'
|
6
|
+
require 'irb'
|
7
|
+
|
8
|
+
class Wut
|
9
|
+
extend ObjectTracker
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@data = []
|
13
|
+
@info = { name: 'foo', weight: 20 }
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
end
|
18
|
+
track_all!
|
19
|
+
end
|
20
|
+
|
21
|
+
IRB.start
|
data/lib/object_tracker.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'benchmark'
|
2
2
|
require 'object_tracker/version'
|
3
3
|
|
4
|
-
fail "ObjectTracker #{ObjectTracker::VERSION} only supports Ruby 2+" if RUBY_VERSION < '2.0.0'
|
5
|
-
|
6
4
|
module ObjectTracker
|
7
5
|
def track(*args)
|
8
6
|
args.each do |method_name|
|
@@ -77,9 +75,11 @@ module ObjectTracker
|
|
77
75
|
RUBY
|
78
76
|
|
79
77
|
# Handle both instance and class level extension
|
80
|
-
if
|
78
|
+
if Class === self.class
|
79
|
+
prepend(Inspector)
|
81
80
|
prepend(mod)
|
82
81
|
else
|
82
|
+
extend(Inspector)
|
83
83
|
extend(mod)
|
84
84
|
end
|
85
85
|
end
|
@@ -101,11 +101,11 @@ module ObjectTracker
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def track_reserved_methods
|
104
|
-
@__reserved_methods ||=
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
@__reserved_methods ||= begin
|
105
|
+
names = [:__send__, :object_id]
|
106
|
+
names.concat [:default_scope, :base_class, :superclass, :<, :current_scope=] if defined?(Rails)
|
107
|
+
names
|
108
|
+
end
|
109
109
|
end
|
110
110
|
|
111
111
|
class UntrackableMethod < StandardError
|
@@ -113,4 +113,12 @@ module ObjectTracker
|
|
113
113
|
super "Can't track :#{method_name} because it's not defined on this class or it's instance"
|
114
114
|
end
|
115
115
|
end
|
116
|
+
|
117
|
+
module Inspector
|
118
|
+
def inspect
|
119
|
+
ivars = instance_variables - [:@__tracking, :@__tracked_calls, :@__reserved_methods]
|
120
|
+
vars = ivars.map { |ivar| ivar.to_s + "=" + instance_variable_get(ivar).to_s }
|
121
|
+
%Q(#<#{self.class.name}:#{object_id}(tracking)#{' ' if vars.any? }#{vars.join(', ')}>)
|
122
|
+
end
|
123
|
+
end
|
116
124
|
end
|
data/object_tracker.gemspec
CHANGED
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.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,7 +42,8 @@ description: Track method calls to almost any object. Class and instance methods
|
|
42
42
|
be tracked (w/ arguments).
|
43
43
|
email:
|
44
44
|
- arebuckley@gmail.com
|
45
|
-
executables:
|
45
|
+
executables:
|
46
|
+
- console.rb
|
46
47
|
extensions: []
|
47
48
|
extra_rdoc_files: []
|
48
49
|
files:
|
@@ -51,6 +52,7 @@ files:
|
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
55
|
+
- bin/console.rb
|
54
56
|
- lib/object_tracker.rb
|
55
57
|
- lib/object_tracker/version.rb
|
56
58
|
- object_tracker.gemspec
|
@@ -66,7 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
68
|
requirements:
|
67
69
|
- - ">="
|
68
70
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
71
|
+
version: 2.0.0
|
70
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
73
|
requirements:
|
72
74
|
- - ">="
|