trace_tree 0.2.14 → 0.2.15

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
  SHA256:
3
- metadata.gz: 607689c629cc47b59c4e62fb9f8db0d6a72bc11224458836fd07a2a246426ab2
4
- data.tar.gz: 9720a640c561948681a9da247560aa29a692cbbfb19fb4f8b1b66bebc05826db
3
+ metadata.gz: '049be0b5875c06742a76fbc283f9a124f20fd574d5bdc529e5f5094181997ebe'
4
+ data.tar.gz: 7e98c2c3cffc65244f69873d41a1925af401e5c02aee917046eef611f87b4aba
5
5
  SHA512:
6
- metadata.gz: c8189fb314365b9e7a104dbae9795163299ac071ec79b443f2a75d682b68be7603067b3e26bc44d42051c22c2490926bf376e05e8018d36b53ebf3ecc10d81ee
7
- data.tar.gz: a984bc9beda68c2014afb5473bcb76134c69569b53ff3c42778a3b173d6f49943aa1447ff60c8446d56a8416fbf01ded4553969b1e057448f57e0bf57f1cc5e3
6
+ metadata.gz: 6c297f28ffe610ddbf6e920350f9ba76f86ff1561b600775d59921d26e83abf1332a65d084be21252e7e93d71c58284738373b2051698404379951ee19916573
7
+ data.tar.gz: a35991a7ebd980020a5c82b42d2c0da53b9b4d25b6617d77979d148fff3d7257fed9b2fd3f264bf7fc19b3e5863b243960c3006878a198bbbaa933481d90d98b
data/README.md CHANGED
@@ -55,6 +55,7 @@ end
55
55
  * `:return => true` by default. It stores return values of functions in generated html. Hover function call and press `r` to print return value in console.
56
56
  * `:args => false` by default. Set it true to puts arguments of `:call` functions into html. Since arguments are always return values of other functions, so this option is not necessary.
57
57
  * `:in => //, :out => nil` by default. Give them regexp(s) to include/exclude methods defined in files match that regexp(s). Notice thread-calls and methods defined by `define_method` are always included. Also, once you set any of these two options, the code to trace should not be in same line with `binding.trace_tree() do`.
58
+ * `:no_methods => nil` by defalut. Give it regexp(s) to hide stack under matching methods. Useful when you want to dump stack of a rack middleware but lower middlewares.
58
59
  * `:timer => nil` by default. Set it true if you want to know how much time spent in tracing and drawing tree. Notice the `file` should be appendable, otherwise the time will overwrite the tree.
59
60
  * `:debug => nil` by default. Give it somthing like what for `:tmp` to output a whole list of TracePoints in file for debug.
60
61
 
@@ -0,0 +1,22 @@
1
+ class TraceTree
2
+ class Point
3
+ class Omitted < Point
4
+
5
+ def initialize
6
+ end
7
+
8
+ def class_and_method
9
+ ' - -'
10
+ end
11
+
12
+ def source_location
13
+ '-'
14
+ end
15
+
16
+ def self.event_class_method
17
+ :omitted
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  class TraceTree
2
- VERSION = "0.2.14"
2
+ VERSION = "0.2.15"
3
3
  end
data/lib/trace_tree.rb CHANGED
@@ -96,21 +96,56 @@ class TraceTree
96
96
  end
97
97
 
98
98
  def make_filter
99
- if !opt.key?(:in) && !opt.key?(:out)
99
+ filters = []
100
+
101
+ if opt.key?(:in)
102
+ @in = Array(opt[:in] || //)
103
+ filters << '@in.any?{ |pattern| pattern =~ point.path }'
104
+ end
105
+
106
+ if opt.key?(:out)
107
+ @out = Array(opt[:out])
108
+ filters << '@out.all?{ |pattern| pattern !~ point.path }'
109
+ end
110
+
111
+ if opt.key?(:no_methods)
112
+ @no_methods = Array(opt[:no_methods])
113
+ filters << 'outside_hidden_stack?(point)'
114
+ end
115
+
116
+ if filters.empty?
100
117
  return @deal = -> point { trace_points << point_loader.create(point) }
101
118
  end
102
- @in, @out = Array(opt[:in] || //), Array(opt[:out])
119
+
120
+ self.singleton_class.class_eval <<-EOM
121
+ def wanted? point
122
+ return false if point.end_of_trace?
123
+ return true if native?(point) || point.thread_relative? || point.method_defined_by_define_method?
124
+ #{filters.join(' && ')}
125
+ end
126
+ EOM
127
+
103
128
  @deal = -> point do
104
129
  po = point_loader.create(point)
105
130
  trace_points << po if wanted? po
106
131
  end
107
132
  end
108
133
 
109
- def wanted? point
110
- return false if point.end_of_trace?
111
- return true if native?(point) || point.thread_relative? || point.method_defined_by_define_method?
112
- @in.any?{ |pattern| pattern =~ point.path } &&
113
- @out.all?{ |pattern| pattern !~ point.path }
134
+ def outside_hidden_stack? point
135
+ stack = (point.thread[:trace_tree_no_methods_stack] ||= [])
136
+ empty = stack.empty?
137
+
138
+ if @no_methods.any?{ |pattern| pattern =~ point.method_name }
139
+ if !empty && point.terminate?(stack.last)
140
+ stack.pop
141
+ else
142
+ stack << point
143
+ point << Point::Omitted.new
144
+ end
145
+ return true
146
+ end
147
+
148
+ empty
114
149
  end
115
150
 
116
151
  def native? point
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trace_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-13 00:00:00.000000000 Z
11
+ date: 2019-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -167,6 +167,7 @@ files:
167
167
  - lib/trace_tree/point/creturn_module_extendobject.rb
168
168
  - lib/trace_tree/point/creturn_module_prependfeatures.rb
169
169
  - lib/trace_tree/point/creturn_thread_initialize.rb
170
+ - lib/trace_tree/point/omit.rb
170
171
  - lib/trace_tree/point/threadbegin.rb
171
172
  - lib/trace_tree/point/threadend.rb
172
173
  - lib/trace_tree/return_value.rb