trace_tree 0.2.23 → 0.3.0

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: bd5d8139275c2476c088b09d3206025594e2b90a19862fbfc547068104b1b35f
4
- data.tar.gz: 8a98934c3db1b3c889bd7ae37e694f0bc75d2ea5cc2e499b21927d761023881c
3
+ metadata.gz: 4b6b20be57ccf2e78b519c7168b1ce03539983ca90edee377df0ef46df1e6efb
4
+ data.tar.gz: 48f2555a86a10a878ec48dbd2eb9d5b5cdea614d9c8d64e1a96a750eaa9d0543
5
5
  SHA512:
6
- metadata.gz: 76792e80cfd88a73e3af890b6c1c8cb3de8ce2dde25e537914b9ffce13c15157692722f6618d4b99dfb5cddfb22230a5e78676ff41de25d4ea1d647b065229f5
7
- data.tar.gz: acbcb32253763eacaa73771a2b8bac61f4092d0525f3610437852ed19f56bc4113aeb6cd7728b21ff4b6d99dbeb7f8fc2ac58ccf1825b2888ee665f3ad7b9d16
6
+ metadata.gz: 66ab836be3474f70a2be81130dd1c502a6eb84b6eab030978c826358197a8b2bf31b28a88d3f4bbe60907dba775342eed4937c4cda14a3c08f5675fc2719fc7f
7
+ data.tar.gz: dfbec33b0177a877f11d3360e1bd5d94e62f3f967bd44217c3599025397ceadec68545dec21ac8c486d7cbd586886554a7130d5a8cf158b3cc9115b003da3234
data/README.md CHANGED
@@ -54,7 +54,6 @@ end
54
54
  * `:htmp => nil` by default. It is combination of `:html` and `:tmp`.
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
- * `: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
57
  * `:no_methods => nil` by default. Give it regexp(s) to hide stack under matching methods. Useful when you want to dump stack of a rack middleware but lower middlewares.
59
58
  * `:warm => nil` by default. Set it something unique to the code block so that the code block will be traced only when it's called second time, in case we dump lots of code loading and initialization.
60
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.
data/lib/trace_tree.rb CHANGED
@@ -18,7 +18,7 @@ class Binding
18
18
  return yield
19
19
  end
20
20
 
21
- TraceTree.new(self).generate *log, **opt, &to_do
21
+ TraceTree.new(self).generate(*log, **opt, &to_do)
22
22
  end
23
23
  end
24
24
 
@@ -41,19 +41,21 @@ class TraceTree
41
41
 
42
42
  def generate *log, **opt, &to_do
43
43
  @opt = opt
44
- @log = dump_location *log
44
+ @log = dump_location(*log)
45
45
  @debug = debug_location
46
46
  enhance_point
47
47
  @build_command = (opt[:html] || opt[:htmp]) ? :tree_html_full : :tree_graph
48
48
  make_filter
49
49
  @__file__, @__line__, there = bi.eval('[__FILE__, __LINE__, self]')
50
50
 
51
+ dry_run
52
+
51
53
  #start_trace
52
54
  timer[:trace]
53
- @tp = TracePoint.new *Events, &@deal
55
+ @tp = TracePoint.new(*Events, &@deal)
54
56
  @tp.enable
55
57
 
56
- there.instance_eval &to_do
58
+ there.instance_eval(&to_do)
57
59
  ensure
58
60
  #stop_trace
59
61
  return unless @tp
@@ -66,6 +68,13 @@ class TraceTree
66
68
 
67
69
  attr_reader :bi, :trace_points, :log, :build_command, :timer, :opt, :point_loader, :config
68
70
 
71
+ def dry_run
72
+ tp = TracePoint.new{}
73
+ tp.enable
74
+ ensure
75
+ tp.disable
76
+ end
77
+
69
78
  def debug_location
70
79
  loc = opt[:debug]
71
80
  return nil unless loc
@@ -89,7 +98,7 @@ class TraceTree
89
98
  enhancement << TraceTree::LuxuryReturnValue
90
99
  end
91
100
  enhancement << TraceTree::Args if opt[:args] == true
92
- @point_loader = Point::Loader.new *enhancement, config
101
+ @point_loader = Point::Loader.new(*enhancement, config)
93
102
  end
94
103
 
95
104
  def dump_trace_tree
@@ -115,14 +124,7 @@ class TraceTree
115
124
  'return false unless outside_hidden_stack?(point)'
116
125
  end
117
126
 
118
- path_filter =
119
- if opt.key?(:in) || opt.key?(:out)
120
- @in = Array(opt[:in] || //)
121
- @out = Array(opt[:out])
122
- 'return false unless @in.any?{ |pattern| pattern =~ point.path } && @out.all?{ |pattern| pattern !~ point.path }'
123
- else
124
- nil
125
- end
127
+ path_filter = nil
126
128
 
127
129
  if stack_filter.nil? && path_filter.nil?
128
130
  return @deal = -> point { trace_points << point_loader.create(point) }
@@ -207,7 +209,7 @@ class TraceTree
207
209
 
208
210
  stacks.keys.each{ |thread| thread[:trace_tree_no_methods_stack] = nil }
209
211
 
210
- #binding.pry
212
+ # binding.pry
211
213
 
212
214
  stacks[trace_points.first.thread][0].
213
215
  callees[0].
@@ -11,7 +11,7 @@ class TraceTree
11
11
  def self.load
12
12
  config = DEFAULT
13
13
  custom = File.join ENV['HOME'], '.trace_tree_config'
14
- if File.exists?(custom) && (hash = YAML.load File.read custom)
14
+ if File.exist?(custom) && (hash = YAML.load File.read custom)
15
15
  hash.select!{ |k, v| config.include? k }
16
16
  config = config.merge hash
17
17
  end
@@ -11,7 +11,7 @@ class TraceTree
11
11
  attr_accessor :terminal, :config
12
12
 
13
13
  Interfaces = [:event, :defined_class, :method_id, :path, :lineno]
14
- attr_reader *Interfaces
14
+ attr_reader(*Interfaces)
15
15
 
16
16
  class << self
17
17
  def inherited base
@@ -160,7 +160,7 @@ EOM
160
160
 
161
161
  def class_name
162
162
  c_call? ? defined_class : current.klass
163
- rescue => e
163
+ rescue
164
164
  puts event
165
165
  end
166
166
 
@@ -189,7 +189,7 @@ EOM
189
189
  def initialize *enhancement, config
190
190
  @config = config
191
191
  @bases = Point.bases
192
- @bases = @bases.map{ |b| b = b.clone; b.prepend *enhancement; b } unless enhancement.empty?
192
+ @bases = @bases.map{ |b| b = b.clone; b.prepend(*enhancement); b } unless enhancement.empty?
193
193
  sort_bases
194
194
  end
195
195
 
@@ -6,7 +6,7 @@ class TraceTree
6
6
  BLANK = ''.freeze
7
7
 
8
8
  NEED_PP = (
9
- if File.exists? (pp_config = File.join(ENV['HOME'], '.trace_tree_pp'))
9
+ if File.exist? (pp_config = File.join(ENV['HOME'], '.trace_tree_pp'))
10
10
  IO.readlines(pp_config).map &:strip
11
11
  else
12
12
  []
@@ -22,7 +22,7 @@ class TraceTree
22
22
  content = content.map{ |c| c.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') } if @transcode
23
23
 
24
24
  File.open @tmp, 'a' do |f|
25
- f.puts *content
25
+ f.puts(*content)
26
26
  end
27
27
  end
28
28
 
@@ -48,7 +48,7 @@ class TraceTree
48
48
  path[-1] = time + path[-1]
49
49
  path = [Dir.tmpdir] + path
50
50
  ensure_parent path
51
- File.join *path
51
+ File.join(*path)
52
52
  end
53
53
 
54
54
  def time
@@ -57,7 +57,7 @@ class TraceTree
57
57
 
58
58
  def ensure_parent path_arr
59
59
  dir = path_arr[0..-2]
60
- FileUtils.mkdir_p File.join *dir
60
+ FileUtils.mkdir_p File.join(*dir)
61
61
  end
62
62
  end
63
63
  end
@@ -1,3 +1,3 @@
1
1
  class TraceTree
2
- VERSION = "0.2.23"
2
+ VERSION = "0.3.0"
3
3
  end
data/trace_tree.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "minitest", "~> 5.0"
26
26
  spec.add_development_dependency "pry"
27
27
 
28
- spec.add_dependency "binding_of_callers", "~> 0.1.5"
28
+ spec.add_dependency "binding_of_callers", "~> 0.2.0"
29
29
  spec.add_dependency "tree_graph", "~> 0.2.0"
30
30
  spec.add_dependency "tree_html", "~> 0.1.7"
31
31
  spec.add_dependency "terminal-tableofhashes", "~> 0.1.0"
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.23
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-10 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.1.5
75
+ version: 0.2.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.1.5
82
+ version: 0.2.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: tree_graph
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -190,8 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubyforge_project:
194
- rubygems_version: 2.7.6
193
+ rubygems_version: 3.2.3
195
194
  signing_key:
196
195
  specification_version: 4
197
196
  summary: Print TracePoint(:b_call, :b_return, :c_call, :c_return, :call, :return,