trace_tree 0.3.0 → 0.3.3

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: 4b6b20be57ccf2e78b519c7168b1ce03539983ca90edee377df0ef46df1e6efb
4
- data.tar.gz: 48f2555a86a10a878ec48dbd2eb9d5b5cdea614d9c8d64e1a96a750eaa9d0543
3
+ metadata.gz: 8b4565cbbc8a5df459e5642434e57630d1b46272f47ae299f7160b58c0620043
4
+ data.tar.gz: 6fac4d967befe782304102938c64ca93d7f1401fd37c97fbc64bf843aeae1646
5
5
  SHA512:
6
- metadata.gz: 66ab836be3474f70a2be81130dd1c502a6eb84b6eab030978c826358197a8b2bf31b28a88d3f4bbe60907dba775342eed4937c4cda14a3c08f5675fc2719fc7f
7
- data.tar.gz: dfbec33b0177a877f11d3360e1bd5d94e62f3f967bd44217c3599025397ceadec68545dec21ac8c486d7cbd586886554a7130d5a8cf158b3cc9115b003da3234
6
+ metadata.gz: 39599ff7ef3c18d530c70429143426ddd93f84bccaecb7fd6fbc0083c44f00721423830c15a896f0a9cbc75dd9ce8c362602aca07b583f06bcf5a95350afad92
7
+ data.tar.gz: 28ac1cd344dfd20ca7df7258c091a954538322ca03019f46de2a2bbbd858ac8f8f3537972f768f5eeac6f473dfa24ebbed522ff61abc17652a4f0fcc7beeaa7e
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  *.swp
11
11
  *.gem
12
+ .tool-versions
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
+ # source 'https://gems.ruby-china.com'
2
3
 
3
4
  # Specify your gem's dependencies in trace_tree.gemspec
4
5
  gemspec
data/README.md CHANGED
@@ -60,6 +60,14 @@ end
60
60
  * `:debug => nil` by default. Give it `STDOUT`/`STDERR` or anything responds to `:puts` to output a whole list of TracePoints. Or give it a file name in the default tmp dir of your system.
61
61
  * `transcode => false` by default. Set it true to convert unknown character into `"?"` when you see `Encoding::UndefinedConversionError`.
62
62
 
63
+ ### Methods' return values
64
+
65
+ By default it stores return values of functions in generated html. If there is any kind of value can not be stringified, you can do something like this to avoid exception:
66
+
67
+ ```ruby
68
+ TraceTree::ReturnValue.formatted(Mongo::Protocol::Message) { |_| "Mongo::Protocol::Message" }
69
+ ```
70
+
63
71
  ### Example 1: Output to HTML
64
72
 
65
73
  Try to remove a non-existing index:
@@ -3,10 +3,5 @@ require 'yaml'
3
3
  class TraceTree
4
4
  GemPaths = {}
5
5
 
6
- ::YAML.load(`gem env`.gsub(/=>/, ':'))["RubyGems Environment"].
7
- select{|h| h.has_key?("GEM PATHS")}[0].
8
- values[0].
9
- each_with_index do |path, i|
10
- GemPaths["GemPath#{i}"] = path
11
- end
6
+ ::Gem.path.each_with_index { |path, i| GemPaths["GemPath#{i}"] = path }
12
7
  end
@@ -12,6 +12,7 @@ class TraceTree
12
12
 
13
13
  Interfaces = [:event, :defined_class, :method_id, :path, :lineno]
14
14
  attr_reader(*Interfaces)
15
+ class_eval 'def assign_trace_point_values(tp);' + Interfaces.map{ |i| "@#{i} = tp.#{i}" }.join(';') + ';end'
15
16
 
16
17
  class << self
17
18
  def inherited base
@@ -68,9 +69,7 @@ EOM
68
69
  end
69
70
 
70
71
  def initialize trace_point
71
- Interfaces.each do |i|
72
- instance_variable_set "@#{i}", trace_point.send(i)
73
- end
72
+ assign_trace_point_values(trace_point)
74
73
 
75
74
  @return_value = trace_point.return_value if x_return?
76
75
  @thread = Thread.current
@@ -1,3 +1,3 @@
1
1
  class TraceTree
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.3"
3
3
  end
data/lib/trace_tree.rb CHANGED
@@ -46,7 +46,8 @@ class TraceTree
46
46
  enhance_point
47
47
  @build_command = (opt[:html] || opt[:htmp]) ? :tree_html_full : :tree_graph
48
48
  make_filter
49
- @__file__, @__line__, there = bi.eval('[__FILE__, __LINE__, self]')
49
+ @__file__, @__line__ = bi.source_location
50
+ there = bi.eval('self')
50
51
 
51
52
  dry_run
52
53
 
@@ -109,11 +110,14 @@ class TraceTree
109
110
  log.puts tree
110
111
  log.puts timer.to_s if opt[:timer]
111
112
  rescue => e
112
- log.puts timer.to_s, e.inspect, e.backtrace, table_of_points
113
+ log.puts timer.to_s, e.inspect, e.backtrace
114
+ log.puts table_of_points
113
115
  end
114
116
 
115
117
  def table_of_points
116
118
  Terminal::Table.from_hashes trace_points_array.map(&:to_h)
119
+ rescue => e
120
+ log.puts "#{__method__}", e.inspect, e.backtrace
117
121
  end
118
122
 
119
123
  def make_filter
data/trace_tree.gemspec CHANGED
@@ -21,13 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_development_dependency "bundler", "> 1.14"
24
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake", ">= 12.3.3"
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.2.0"
29
- spec.add_dependency "tree_graph", "~> 0.2.0"
30
- spec.add_dependency "tree_html", "~> 0.1.7"
28
+ spec.add_dependency "binding_of_callers", "~> 0.2.3"
29
+ spec.add_dependency "tree_graph", "~> 0.2.4"
30
+ spec.add_dependency "tree_html", "~> 0.1.9"
31
31
  spec.add_dependency "terminal-tableofhashes", "~> 0.1.0"
32
32
 
33
33
  end
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.3.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-16 00:00:00.000000000 Z
11
+ date: 2022-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,42 +72,42 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.0
75
+ version: 0.2.3
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.2.0
82
+ version: 0.2.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: tree_graph
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.2.0
89
+ version: 0.2.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.2.0
96
+ version: 0.2.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: tree_html
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.1.7
103
+ version: 0.1.9
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.7
110
+ version: 0.1.9
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: terminal-tableofhashes
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 3.2.3
193
+ rubygems_version: 3.1.6
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Print TracePoint(:b_call, :b_return, :c_call, :c_return, :call, :return,