trace_tree 0.2.21 → 0.2.22

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: 0be4af3563495464f3f18a8f3071777eaff9d29fbd90c99e79338dcd6ed97818
4
- data.tar.gz: 82691f1633c340f8fcdc602564367db4d63769fa1d9a076d3a1ecba8f65d57dc
3
+ metadata.gz: dd1207a48ba8e3bef86a5aca61f42f614a5351f0251107de1eb840752a20c197
4
+ data.tar.gz: fd0b345cd448977d34255da75e7c8fc8556a305d58a4b3e32d7e6e6014273dcd
5
5
  SHA512:
6
- metadata.gz: 67e6c97a69c109f44ae2f5527628caabb02e1c1aaff1ae05160b836f360b98432fc68d37a992664497c0089dcd7b02af2a9eb3999f27acf57134239129fd01fe
7
- data.tar.gz: e24c3bab4d4a09883a450d91b0a3f8f10f517a9da35acb37b66f51e5435902fe4e6970cf4cc97c03c4e06d580fe262e96a7464339bbee99ae4669825b163812c
6
+ metadata.gz: 2b2ee0e51cb157b4345616a7b8f68ed8e38bea77d03672b295794017dad8c77591af0e5e7abc3075fc2abb8250a8217c9a4c55371a9ea98b34bed86c24567923
7
+ data.tar.gz: 8bad826fd1efcb5e33eef42b701845be40bffb54c43196d0e3878f4362509177c6122ce6f28cdaf46373531942e7180813cff7cfe1c7e3d913c76538ca838ca2
data/README.md CHANGED
@@ -59,6 +59,7 @@ end
59
59
  * `: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
60
  * `: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.
61
61
  * `: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.
62
+ * `transcode => false` by default. Set it true to convert unknown character into `"?"` when you see `Encoding::UndefinedConversionError`.
62
63
 
63
64
  ### Example 1: Output to HTML
64
65
 
@@ -70,12 +70,12 @@ class TraceTree
70
70
  loc = opt[:debug]
71
71
  return nil unless loc
72
72
  return loc if loc.respond_to? :puts
73
- TmpFile.new loc
73
+ TmpFile.new loc, transcode: opt[:transcode]
74
74
  end
75
75
 
76
76
  def dump_location *log
77
- return TmpFile.new opt[:tmp] if opt[:tmp]
78
- return TmpFile.new(opt[:htmp] + '.html') if opt[:htmp]
77
+ return TmpFile.new(opt[:tmp], transcode: opt[:transcode]) if opt[:tmp]
78
+ return TmpFile.new((opt[:htmp] + '.html'), transcode: opt[:transcode]) if opt[:htmp]
79
79
  log.empty? ? STDOUT : log[0]
80
80
  end
81
81
 
@@ -12,12 +12,15 @@ class TraceTree
12
12
 
13
13
  DefaultName = 'trace_tree.html'
14
14
 
15
- def initialize path
15
+ def initialize path, transcode: false
16
16
  path = recognize_dir path
17
17
  @tmp = custom path
18
+ @transcode = transcode
18
19
  end
19
20
 
20
21
  def puts *content
22
+ content = content.map{ |c| c.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') } if @transcode
23
+
21
24
  File.open @tmp, 'a' do |f|
22
25
  f.puts *content
23
26
  end
@@ -1,3 +1,3 @@
1
1
  class TraceTree
2
- VERSION = "0.2.21"
2
+ VERSION = "0.2.22"
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.21
4
+ version: 0.2.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-27 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler