unroller 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Readme +23 -1
  2. data/lib/unroller.rb +5 -0
  3. metadata +2 -2
data/Readme CHANGED
@@ -225,7 +225,7 @@ I've also heard rumors that Ruby comes standard with some kind of debugger (?) .
225
225
 
226
226
  ==To do
227
227
 
228
- You're welcome to submit comments and/or patches.
228
+ You're welcome to submit comments, ideas, and/or patches.
229
229
 
230
230
  * Make a GUI interface that lets you quickly collapse/nodes nodes of the tree.
231
231
  * :include_classes option in addition to :exclude_classes?
@@ -235,4 +235,26 @@ You're welcome to submit comments and/or patches.
235
235
  * :preset => :'ActiveRecord high level' : excludes the lowel-level database stuff (like the individual adapter (SQLite, MySQL, ...).
236
236
  * :preset => :'ActiveRecord low level'
237
237
 
238
+ ==="Watch for" conditions===
239
+
240
+ Only traces / shows you when/if a certain condition is met.
241
+
242
+ You could use it, for example, to answer the question, "When did this method get added?? I don't remember adding that?!"
243
+
244
+ Useful when you see evidence that something *is* happening but you just can't figure out *where* it's happening or *why*.
245
+
246
+ You'd just start the tracer at the very beginning of your application and tell it to watch for lines that might have caused it to be added.
247
+
248
+ It wouldn't be perfect by any means, but it it might be better than nothing...
249
+
250
+ * You'd kind of have to know a lot about Ruby and the various ways methods can get added. (Normal def statements or alias or alias_method or alias_method_chain, etc.)
251
+ * It would be a rather inexact test, as it would probably use string/Regexp matching, which can easily be too broad or too strict
252
+ * It wouldn't work for stuff that happens during c-calls or if people don't specify the correct file/line for their evals (because if they don't do that, we can't read the source code)
253
+
254
+ Might look something like this...
255
+
256
+ Unroller::trace, :watch_for => proc {|event| event.type =~ /line/ && (event.code =~ /def/ || event.method =~ /method/) }
257
+ end
258
+
259
+ Other name ideas: :match_code, :match_event, :event_match, :only_events
238
260
 
data/lib/unroller.rb CHANGED
@@ -71,6 +71,7 @@ class Unroller
71
71
  @max_lines = nil # Stop tracing (permanently) after we have produced @max_lines lines of output. If you don't know where to place the trace(false) and you just want it to stop on its own after so many lines, you could use this...
72
72
  @max_depth = nil # Don't trace anything when the depth is greater than this threshold. (This is *relative* to the starting depth, so whatever level you start at is considered depth "1".)
73
73
  @exclude_classes = []
74
+ @include_classes = [] # These will override classes that have been excluded via exclude_classes. So if you both exclude and include a class, it will be included.
74
75
  @show_args = true
75
76
  @show_locals = false
76
77
  @show_filename_and_line_numbers = true
@@ -121,9 +122,13 @@ class Unroller
121
122
  options[:initial_depth] = options.delete(:depth) if options.has_key?(:depth)
122
123
  options[:initial_depth] = caller(0).size if options[:initial_depth] == :use_call_stack_depth
123
124
  if options.has_key?(:exclude_classes)
125
+ # Coerce it into an arry of Regexp's, if possible
124
126
  options[:exclude_classes] = [options[:exclude_classes]] if options[:exclude_classes].is_a?(Regexp)
125
127
  raise ArgumentError if !options[:exclude_classes].is_a?(Array)
126
128
  end
129
+ if options.has_key?(:include_classes)
130
+ # :todo:
131
+ end
127
132
  set_with(options)
128
133
 
129
134
  # Private
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: unroller
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.11
7
- date: 2007-04-23 00:00:00 -07:00
6
+ version: 0.0.12
7
+ date: 2007-04-24 00:00:00 -07:00
8
8
  summary: A tool for generating human-readable "execution traces"
9
9
  require_paths:
10
10
  - lib