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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e889be174516183164f5509726803585c3340330
4
- data.tar.gz: 24733d196130df20d67d36431dc13cac602579a3
3
+ metadata.gz: e6a33c823c7c9a9edef43b4a0a9a6131cb5088cf
4
+ data.tar.gz: 8fc50067cb0975e582b1450f0f5b4056aae86b1b
5
5
  SHA512:
6
- metadata.gz: c8b2a669139e8d3988cda3cfd874cf5f6c28321f6411ed0056bea8e92d3fd0cc1368a285c71dada57283447f99cc4d90acf6f650696a68dbe0537d1b42395bbe
7
- data.tar.gz: f377fa3a417f3f0eacfe62440c483270bbfc1e79578a5b5934690ed446b4b6400bb55a0e24588b82ad6aa54d1d4d0adb16dbcfa18da574a7cd66058a4b33d567
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
@@ -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
- @tmp = Dir.tmpdir
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 = [@tmp] + 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
@@ -1,3 +1,3 @@
1
1
  class TraceTree
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  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.2.7
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-05-20 00:00:00.000000000 Z
11
+ date: 2017-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler