object_tracker 1.1.0 → 1.1.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: bfd7b109271fd7711dc44cd0d4e0470ca476d405
4
- data.tar.gz: becc3082a28a2f1eb0ee73f4a727f58e07a1d1c6
3
+ metadata.gz: a059858f4b2035c15ff8c845c537b3a5731d8cba
4
+ data.tar.gz: 361ea1ca3cbdacec35bb28c871976ad5d3a103b7
5
5
  SHA512:
6
- metadata.gz: 102d330f30f4a7952ecd06f2c1a0967a1ff67277053b69b51006bcd86b9b3a40a215de08cd235a8b542bec4d6f69b4cf920b8bc325541e3ffc3603d96dbdd281
7
- data.tar.gz: a92c6e9d0fa2e2635bcb91cf5377b64c5c29956ed11f9853a0acab61e83393ee790a92c3f8ee499056e3245037d96ed0278525421668f0afd99821457eeba559
6
+ metadata.gz: b07a26e80d2f4279df58e1956ffb675f5a3b5a9184c9f81bee6d88173f8b4dca793ee782c92e40230bbdb26429766189490aa47f3c112c28f2111d0c910dadbb
7
+ data.tar.gz: 0d7137d415304e83df80352d251c52185a31fd23bd5778b61c8df5619c6e8d59c109e0e411a90e013d1a38bb7ba256ad0dc50276026abb02b9a53aa94909b96a
data/README.md CHANGED
@@ -234,6 +234,25 @@ MyKlass.track_not :bad_method
234
234
  MyKlass.track_all! #=> will exclude tracking for :bad_method
235
235
  ```
236
236
 
237
+ I've also noticed it doesn't work so well with namespaced classes in the format:
238
+
239
+ ```ruby
240
+ class TopLevel::MyKlass
241
+ extend ObjectTracker
242
+ track_all!
243
+ end
244
+ ```
245
+
246
+ If you encounter that problem, either extend the particular instance you're using, or if you can, rewrite it as:
247
+
248
+ ```ruby
249
+ class TopLevel
250
+ class MyKlass
251
+ extend ObjectTracker
252
+ track_all!
253
+ end
254
+ end
255
+ ```
237
256
  ## Issues
238
257
 
239
258
  Doesn't work well (or at all) when trying to track Ruby core objects (`String`, `Array`, etc). You can work around this by
@@ -1,3 +1,3 @@
1
1
  module ObjectTracker
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
@@ -53,7 +53,7 @@ module ObjectTracker
53
53
  mod = Module.new
54
54
  Array(method_names || tracking).each do |method_name, source_def|
55
55
  mod.module_eval <<-RUBY, __FILE__, __LINE__
56
- def #{cleanse(method_name)}(*args, &block)
56
+ def #{cleanse(method_name)}(*args)
57
57
  msg = %Q( * called "#{method_name}" )
58
58
  msg << "with " << args.join(', ') << " " if args.any?
59
59
  msg << "[#{source_def}]"
@@ -61,6 +61,8 @@ module ObjectTracker
61
61
  time = Benchmark.realtime { result = super }
62
62
  msg << " (" << time.to_s << ")"
63
63
  puts msg
64
+ @__tracked_calls ||= Set.new
65
+ @__tracked_calls << "#{method_name}"
64
66
  result
65
67
  rescue NoMethodError => e
66
68
  raise e if e.message !~ /no superclass/
@@ -99,37 +101,11 @@ module ObjectTracker
99
101
  end
100
102
 
101
103
  def track_reserved_methods
102
- @__reserved_methods ||= [
103
- :!,
104
- :!=,
105
- :!~,
106
- :<,
107
- :<=,
108
- :<=>,
109
- :==,
110
- :===,
111
- :=~,
112
- :>,
113
- :>=,
114
- :[],
115
- :[]=,
116
- :__id__,
117
- :__send__,
118
- :`,
119
- :public_send,
120
- :send,
121
- :class,
122
- :object_id,
123
- :track,
124
- :tracking?,
125
- :track_not,
126
- :track_all!,
127
- :track!,
128
- :track_methods_for,
129
- :track_with_source,
130
- :tracking,
131
- :track_reserved_methods
132
- ]
104
+ @__reserved_methods ||= (defined?(Rails) ? [:default_scope, :base_class, :superclass, :<, :current_scope=] : [])
105
+ end
106
+
107
+ def tracked_calls
108
+ @__tracked_calls
133
109
  end
134
110
 
135
111
  class UntrackableMethod < StandardError
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  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.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-27 00:00:00.000000000 Z
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.4.8
77
+ rubygems_version: 2.4.6
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Track method calls to almost any object.