trace_tree 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/trace_tree/tmp_file.rb +37 -0
- data/lib/trace_tree/version.rb +1 -1
- data/lib/trace_tree.rb +7 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3387337a1f93ab9355cc6813b288acfd9272a62
|
4
|
+
data.tar.gz: 8f9398c42e22c9e156689665f08999e25fcf07e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2d35a39fcfb8333ebc8c505ff6a518071c092e8e29fe451ec9935024b5bc12001d726c98231b1387157ebdbb3b5fdd6c8193d6a754f8eaae85eaa626a74cbbb
|
7
|
+
data.tar.gz: 3b2f25e2b6e3d49788ecba875a18bbf1c70dc4c5b92822d2b57c9c979f96facb494b435f618a22db251229d7fccc686a86f9e6630f21439ce354d3cc7ba0a2bf
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TraceTree
|
2
2
|
|
3
|
-
Print TracePoint(normal ruby call, block call, raise call, throw call) in tree
|
3
|
+
Print TracePoint(normal ruby call, block call, raise call, throw call) in tree view, to console or html.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
|
31
31
|
### Parameters
|
32
32
|
|
33
|
-
You may pass optional parameters while invoking `binding.trace_tree
|
33
|
+
You may pass optional parameters while invoking `binding.trace_tree`, for example:
|
34
34
|
|
35
35
|
```ruby
|
36
36
|
binding.trace_tree(file, color: false, gem: false) do
|
@@ -41,7 +41,8 @@ end
|
|
41
41
|
* `file == STDOUT` by default. You can give it a File object or anything responds to `puts`.
|
42
42
|
* `:color => true` by default. It makes method names have different color than source_location in output. When you print the output to file, you may want to set it false to discard those color ANSI escape sequences.
|
43
43
|
* `:gem => true` by default. Replace the gem paths in source_location with $GemPathN, can make the lines shorter. To see what are replaced, inspect `TraceTree::GemPaths`.
|
44
|
-
* `:html => nil` by default. Set it true to generate a html in which a tree constructed with `<ul>`, `<li>`.
|
44
|
+
* `:html => nil` by default. Set it true to generate a html in which a tree constructed with `<ul>`, `<li>`. (No need to set `color`).
|
45
|
+
* `:tmp => nil` by default. Set it true or an array of string to specify a tmp file under the default tmp dir of your system. (No need to provide `file` argument)
|
45
46
|
|
46
47
|
### Example
|
47
48
|
|
@@ -52,7 +53,7 @@ require 'sinatra'
|
|
52
53
|
require 'trace_tree'
|
53
54
|
|
54
55
|
get '/' do
|
55
|
-
'
|
56
|
+
'welcome'
|
56
57
|
end
|
57
58
|
|
58
59
|
class Sinatra::Base
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
|
3
|
+
class TraceTree
|
4
|
+
class TmpFile
|
5
|
+
|
6
|
+
DefaultName = 'trace_tree.html'
|
7
|
+
|
8
|
+
def initialize path
|
9
|
+
@tmp = Dir.tmpdir
|
10
|
+
path = DefaultName if path == true
|
11
|
+
@tmp = custom path
|
12
|
+
end
|
13
|
+
|
14
|
+
def puts *content
|
15
|
+
File.open @tmp, 'w' do |f|
|
16
|
+
f.puts *content
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def path
|
21
|
+
@tmp
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def custom path
|
27
|
+
path = Array(path).map(&:to_s)
|
28
|
+
path[-1] = time + path[-1]
|
29
|
+
path = [@tmp] + path
|
30
|
+
File.join *path
|
31
|
+
end
|
32
|
+
|
33
|
+
def time
|
34
|
+
Time.now.strftime '%Y%m%d_%H%M%S_%L_'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/trace_tree/version.rb
CHANGED
data/lib/trace_tree.rb
CHANGED
@@ -3,6 +3,7 @@ require 'binding_of_callers/pry'
|
|
3
3
|
require 'trace_tree/node'
|
4
4
|
require 'trace_tree/short_gem_path'
|
5
5
|
require 'trace_tree/color'
|
6
|
+
require 'trace_tree/tmp_file'
|
6
7
|
|
7
8
|
class Binding
|
8
9
|
def trace_tree *log, **opt, &to_do
|
@@ -18,7 +19,7 @@ class TraceTree
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def generate *log, **opt, &to_do
|
21
|
-
@log = log
|
22
|
+
@log = dump_location *log, **opt
|
22
23
|
node_class = optional_node opt
|
23
24
|
@build_command = opt[:html] ? :tree_html_full : :tree_graph
|
24
25
|
|
@@ -36,6 +37,11 @@ class TraceTree
|
|
36
37
|
|
37
38
|
attr_reader :bi, :trace_points, :log, :build_command
|
38
39
|
|
40
|
+
def dump_location *log, **opt
|
41
|
+
return TmpFile.new opt[:tmp] if opt[:tmp]
|
42
|
+
log.empty? ? STDOUT : log[0]
|
43
|
+
end
|
44
|
+
|
39
45
|
def optional_node opt
|
40
46
|
Class.new TraceTree::Node do
|
41
47
|
prepend TraceTree::ShortGemPath unless opt[:gem] == false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trace_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/trace_tree/gem_paths.rb
|
116
116
|
- lib/trace_tree/node.rb
|
117
117
|
- lib/trace_tree/short_gem_path.rb
|
118
|
+
- lib/trace_tree/tmp_file.rb
|
118
119
|
- lib/trace_tree/tree_graphable.rb
|
119
120
|
- lib/trace_tree/tree_htmlable.rb
|
120
121
|
- lib/trace_tree/version.rb
|
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
142
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.6.8
|
143
144
|
signing_key:
|
144
145
|
specification_version: 4
|
145
146
|
summary: Print TracePoint(normal ruby call, block call, raise call, throw call) in
|