trace_tree 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/trace_tree/tmp_file.rb +20 -3
- data/lib/trace_tree/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6a33c823c7c9a9edef43b4a0a9a6131cb5088cf
|
4
|
+
data.tar.gz: 8fc50067cb0975e582b1450f0f5b4056aae86b1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed48c6ec0f6b579f8e823c0d03bfb34c511b9f9c86d508f624ad313830313c24ffd9dbae30a52c4b0410453763a0d93224fbe47616d781d51c63f25bb2ffc3d
|
7
|
+
data.tar.gz: d54d68166144f9bbcc60498fe189ffbdb27d47516ddce71cf8ed5fd2bc77ac8ecb06153c9aa6f95f02b6204b9658a59c5fde30f4c5b025c829467f642cce0944
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ end
|
|
44
44
|
* `: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.
|
45
45
|
* `: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`.
|
46
46
|
* `:html => nil` by default. Set it true to generate a html in which a tree constructed with `<ul>`, `<li>`. (No need to set `color`).
|
47
|
-
* `: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)
|
47
|
+
* `:tmp => nil` by default. Set it true or a string or an array of string to specify a tmp file under the default tmp dir of your system. (No need to provide `file` argument. It makes parent directories as needed)
|
48
48
|
* `: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.
|
49
49
|
|
50
50
|
### Example
|
data/lib/trace_tree/tmp_file.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tmpdir'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
class TraceTree
|
4
5
|
class TmpFile
|
@@ -6,8 +7,7 @@ class TraceTree
|
|
6
7
|
DefaultName = 'trace_tree.html'
|
7
8
|
|
8
9
|
def initialize path
|
9
|
-
|
10
|
-
path = DefaultName if path == true
|
10
|
+
path = recognize_dir path
|
11
11
|
@tmp = custom path
|
12
12
|
end
|
13
13
|
|
@@ -23,15 +23,32 @@ class TraceTree
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
def recognize_dir path
|
27
|
+
case path
|
28
|
+
when true
|
29
|
+
DefaultName
|
30
|
+
when String
|
31
|
+
path.split '/'
|
32
|
+
else
|
33
|
+
path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
26
37
|
def custom path
|
27
38
|
path = Array(path).map(&:to_s)
|
28
39
|
path[-1] = time + path[-1]
|
29
|
-
path = [
|
40
|
+
path = [Dir.tmpdir] + path
|
41
|
+
ensure_parent path
|
30
42
|
File.join *path
|
31
43
|
end
|
32
44
|
|
33
45
|
def time
|
34
46
|
Time.now.strftime '%Y%m%d_%H%M%S_%L_'
|
35
47
|
end
|
48
|
+
|
49
|
+
def ensure_parent path_arr
|
50
|
+
dir = path_arr[0..-2]
|
51
|
+
FileUtils.mkdir_p File.join *dir
|
52
|
+
end
|
36
53
|
end
|
37
54
|
end
|
data/lib/trace_tree/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|