debugtrace 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/CHANGELOG_ja.md +7 -0
- data/README.md +27 -27
- data/README_ja.md +27 -27
- data/examples/enumerable-example.rb +27 -0
- data/lib/debugtrace/location.rb +4 -0
- data/lib/debugtrace/version.rb +1 -1
- data/lib/debugtrace.rb +11 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f351de13b8fc8844e234a3725e9af20f9dcba4ecbcf73490a24ebbdeb698eb7f
|
4
|
+
data.tar.gz: 305ee479e282fa2ade876ef77e6208b5f01d2e71746a8107847901d052c43a77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22936ed6dcd7efd2933b83ed5b3d4081a0aa934c314dae86878933bcb86230d1c5be77921a5cce1ebc941a9696845534552f570e148a4ad1e185b4f6461eb62e
|
7
|
+
data.tar.gz: 69f25a8bf99c9e788192cb9c743ab55a2ac984ca1f67f6ab3da9164b8186eb48650ceda79bd939d9cb274082f4bd64911f323644648ec782f8765247361b94e0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.3.2 - September 19, 2025
|
2
|
+
* When running from RubyMine, the source file path is now output as a relative path from the current directory, rather than as an absolute path.
|
3
|
+
|
4
|
+
## 1.3.1 - July 15, 2025
|
5
|
+
* Even if `string_as_bytes: true` is specified in the `print` method, if the string encoding is not `ASCII_8BIT`, it will be output as a normal string.
|
6
|
+
* If an exception is thrown when trying to output as a normal string, it will be output in hexadecimal.
|
7
|
+
|
1
8
|
## 1.3.0 - July 12, 2025
|
2
9
|
|
3
10
|
* Added optional argument `string_as_bytes` (default: `false`) to the `print` method. The string will be output in hexadecimal if it is `true`.
|
data/CHANGELOG_ja.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.3.2 - 2025/9/19
|
2
|
+
* RubyMineから実行した場合に、ソースファイルが絶対パスで出力されるのをカレントディレクトリからの相対パスに変更しました。
|
3
|
+
|
4
|
+
## 1.3.1 - 2025/7/15
|
5
|
+
* `print`メソッドで`string_as_bytes: true`が指定されていても文字列のエンコードが`ASCII_8BIT`ではない場合は、通常の文字列として出力するようにしました。
|
6
|
+
* 通常の文字列として出力しようとして例外がスローされた場合は、16進数で出力するようにしました。
|
7
|
+
|
1
8
|
## 1.3.0 - 2025/7/12
|
2
9
|
|
3
10
|
* `print`メソッドにオプション引数`string_as_bytes`(デフォルト: `false`)を追加しました。`true`を指定した場合は、文字列を16進数で出力します。
|
data/README.md
CHANGED
@@ -77,32 +77,32 @@ func1
|
|
77
77
|
```
|
78
78
|
|
79
79
|
```log
|
80
|
-
2025-
|
81
|
-
2025-
|
82
|
-
2025-
|
83
|
-
2025-
|
84
|
-
2025-
|
85
|
-
2025-
|
86
|
-
2025-
|
87
|
-
2025-
|
88
|
-
2025-
|
89
|
-
2025-
|
90
|
-
2025-
|
91
|
-
2025-
|
92
|
-
2025-
|
93
|
-
2025-
|
94
|
-
2025-
|
95
|
-
2025-
|
96
|
-
2025-
|
97
|
-
2025-
|
98
|
-
2025-
|
99
|
-
2025-
|
100
|
-
2025-
|
101
|
-
2025-
|
102
|
-
2025-
|
103
|
-
2025-
|
104
|
-
2025-
|
105
|
-
2025-
|
80
|
+
2025-09-23 09:40:54.733+09:00 DebugTrace-rb 1.3.2 on Ruby 3.4.6 / x86_64-linux
|
81
|
+
2025-09-23 09:40:54.733+09:00 config file: ./debugtrace.yml
|
82
|
+
2025-09-23 09:40:54.733+09:00 logger: StdErrLogger
|
83
|
+
2025-09-23 09:40:54.733+09:00
|
84
|
+
2025-09-23 09:40:54.733+09:00 ______________________________ #72 ______________________________
|
85
|
+
2025-09-23 09:40:54.733+09:00
|
86
|
+
2025-09-23 09:40:54.733+09:00 Enter func1 (examples/readme-example.rb:29) <- <main> (examples/readme-example.rb:35)
|
87
|
+
2025-09-23 09:40:54.733+09:00 | Hello, World! (examples/readme-example.rb:30)
|
88
|
+
2025-09-23 09:40:54.733+09:00 | Enter func2 (examples/readme-example.rb:20) <- func1 (examples/readme-example.rb:31)
|
89
|
+
2025-09-23 09:40:54.734+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:22)
|
90
|
+
2025-09-23 09:40:54.734+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.014 ms
|
91
|
+
2025-09-23 09:40:54.734+09:00 | |
|
92
|
+
2025-09-23 09:40:54.734+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:23)
|
93
|
+
2025-09-23 09:40:54.734+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.007 ms
|
94
|
+
2025-09-23 09:40:54.734+09:00 | Leave func2 (examples/readme-example.rb:25) duration: 0.206 ms
|
95
|
+
2025-09-23 09:40:54.734+09:00 Leave func1 (examples/readme-example.rb:32) duration: 0.332 ms
|
96
|
+
2025-09-23 09:40:54.734+09:00
|
97
|
+
2025-09-23 09:40:54.734+09:00 contacts = [
|
98
|
+
2025-09-23 09:40:54.734+09:00 Contact{
|
99
|
+
2025-09-23 09:40:54.734+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
|
100
|
+
2025-09-23 09:40:54.734+09:00 },
|
101
|
+
2025-09-23 09:40:54.734+09:00 Contact{
|
102
|
+
2025-09-23 09:40:54.734+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
|
103
|
+
2025-09-23 09:40:54.734+09:00 @birthday: 1992-03-04
|
104
|
+
2025-09-23 09:40:54.734+09:00 }
|
105
|
+
2025-09-23 09:40:54.734+09:00 ] (examples/readme-example.rb:36)
|
106
106
|
```
|
107
107
|
|
108
108
|
### 4. List of methods
|
@@ -136,7 +136,7 @@ DebugTrace module has the following methods.
|
|
136
136
|
<p><code>value</code>: the value <small>(Optional)</small></p>
|
137
137
|
<small><i>The following arguments are keyword arguments and optional</i></small></p>
|
138
138
|
<p><code>reflection</code>: reflection is used aggressively if <code>true</code>, used passively if <code>false</code> (Default: <code>false</code>)</p>
|
139
|
-
<p><code>string_as_bytes</code>: Output strings in hexadecimal if <code>true</code> <small>(Default: <code>false</code>)</small></p>
|
139
|
+
<p><code>string_as_bytes</code>: Output strings which encoding is <code>ASCII_8BIT</code> in hexadecimal if <code>true</code> <small>(Default: <code>false</code>)</small></p>
|
140
140
|
<small><i>The following arguments can be specified in debugtrace.yml (argument specification takes precedence)</i></small></p>
|
141
141
|
<p><code>minimum_output_size</code>: The minimum number of elements to print for <code>Array</code>, <code>Hash</code> and <code>Set</code></p>
|
142
142
|
<p><code>minimum_output_length</code>: The minimum length to print the length of the string<br>
|
data/README_ja.md
CHANGED
@@ -77,32 +77,32 @@ DebugTrace.print('contacts', contacts)
|
|
77
77
|
```
|
78
78
|
|
79
79
|
```log
|
80
|
-
2025-
|
81
|
-
2025-
|
82
|
-
2025-
|
83
|
-
2025-
|
84
|
-
2025-
|
85
|
-
2025-
|
86
|
-
2025-
|
87
|
-
2025-
|
88
|
-
2025-
|
89
|
-
2025-
|
90
|
-
2025-
|
91
|
-
2025-
|
92
|
-
2025-
|
93
|
-
2025-
|
94
|
-
2025-
|
95
|
-
2025-
|
96
|
-
2025-
|
97
|
-
2025-
|
98
|
-
2025-
|
99
|
-
2025-
|
100
|
-
2025-
|
101
|
-
2025-
|
102
|
-
2025-
|
103
|
-
2025-
|
104
|
-
2025-
|
105
|
-
2025-
|
80
|
+
2025-09-23 09:40:54.733+09:00 DebugTrace-rb 1.3.2 on Ruby 3.4.6 / x86_64-linux
|
81
|
+
2025-09-23 09:40:54.733+09:00 config file: ./debugtrace.yml
|
82
|
+
2025-09-23 09:40:54.733+09:00 logger: StdErrLogger
|
83
|
+
2025-09-23 09:40:54.733+09:00
|
84
|
+
2025-09-23 09:40:54.733+09:00 ______________________________ #72 ______________________________
|
85
|
+
2025-09-23 09:40:54.733+09:00
|
86
|
+
2025-09-23 09:40:54.733+09:00 Enter func1 (examples/readme-example.rb:29) <- <main> (examples/readme-example.rb:35)
|
87
|
+
2025-09-23 09:40:54.733+09:00 | Hello, World! (examples/readme-example.rb:30)
|
88
|
+
2025-09-23 09:40:54.733+09:00 | Enter func2 (examples/readme-example.rb:20) <- func1 (examples/readme-example.rb:31)
|
89
|
+
2025-09-23 09:40:54.734+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:22)
|
90
|
+
2025-09-23 09:40:54.734+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.014 ms
|
91
|
+
2025-09-23 09:40:54.734+09:00 | |
|
92
|
+
2025-09-23 09:40:54.734+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:23)
|
93
|
+
2025-09-23 09:40:54.734+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.007 ms
|
94
|
+
2025-09-23 09:40:54.734+09:00 | Leave func2 (examples/readme-example.rb:25) duration: 0.206 ms
|
95
|
+
2025-09-23 09:40:54.734+09:00 Leave func1 (examples/readme-example.rb:32) duration: 0.332 ms
|
96
|
+
2025-09-23 09:40:54.734+09:00
|
97
|
+
2025-09-23 09:40:54.734+09:00 contacts = [
|
98
|
+
2025-09-23 09:40:54.734+09:00 Contact{
|
99
|
+
2025-09-23 09:40:54.734+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
|
100
|
+
2025-09-23 09:40:54.734+09:00 },
|
101
|
+
2025-09-23 09:40:54.734+09:00 Contact{
|
102
|
+
2025-09-23 09:40:54.734+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
|
103
|
+
2025-09-23 09:40:54.734+09:00 @birthday: 1992-03-04
|
104
|
+
2025-09-23 09:40:54.734+09:00 }
|
105
|
+
2025-09-23 09:40:54.734+09:00 ] (examples/readme-example.rb:36)
|
106
106
|
```
|
107
107
|
|
108
108
|
### 4. メソッド一覧
|
@@ -136,7 +136,7 @@ DebugTraceモジュールには以下のメソッドがあります。
|
|
136
136
|
<p><code>value</code>: 値 <small>(省略可)</small></p>
|
137
137
|
<small><i>以降の引数は、キーワード引数で省略可</i></small>
|
138
138
|
<code>reflection</code>: <code>true</code>ならリフレクションを積極的に使用、<code>false</code>なら消極的に使用 <small>(デフォルト: <code>false</code>)</small></p>
|
139
|
-
<p><code>string_as_bytes</code>: <code>true</code
|
139
|
+
<p><code>string_as_bytes</code>: <code>true</code>ならエンコードが<code>ASCII_8BIT</code>の文字列を16進数で出力する<small>(デフォルト: <code>false</code>)</small></p>
|
140
140
|
<small><i>以降の引数は、debugtrace.ymlで指定可能 (引数指定が優先)</i></small><br>
|
141
141
|
<p><code>minimum_output_size</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code>の要素数を出力する最小要素数</p>
|
142
142
|
<p><code>minimum_output_length</code>: 文字列の長さを出力する最小の長さ<br>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# enumerable-example.rb
|
3
|
+
#require 'debugtrace'
|
4
|
+
require_relative '../lib/debugtrace'
|
5
|
+
|
6
|
+
# Array
|
7
|
+
array1 = [1, 2, 3, 4]
|
8
|
+
DebugTrace.print('array1', array1)
|
9
|
+
DebugTrace.print('array1.to_s', array1.to_s)
|
10
|
+
|
11
|
+
array2 = [:a, 'B', "C\n", 4]
|
12
|
+
DebugTrace.print('array2', array2)
|
13
|
+
DebugTrace.print('array2.to_s', array2.to_s)
|
14
|
+
|
15
|
+
# Hash
|
16
|
+
hash1 = {'a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => "D\n"}
|
17
|
+
DebugTrace.print('hash1', hash1)
|
18
|
+
DebugTrace.print('hash1.to_s', hash1.to_s)
|
19
|
+
|
20
|
+
hash2 = {a: 'A', b: 'B', c: 'C', d: "D\n"}
|
21
|
+
DebugTrace.print('hash2', hash2)
|
22
|
+
DebugTrace.print('hash2.to_s', hash2.to_s)
|
23
|
+
|
24
|
+
# Set
|
25
|
+
set1 = Set.new([1, 2, 3, 4])
|
26
|
+
DebugTrace.print('set1', set1)
|
27
|
+
DebugTrace.print('set1.to_s', set1.to_s)
|
data/lib/debugtrace/location.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
# Contains source location information.
|
6
6
|
class Location
|
7
|
+
@@current_dir = Dir.pwd + '/'
|
7
8
|
attr_reader :name
|
8
9
|
attr_reader :path
|
9
10
|
attr_reader :lineno
|
@@ -22,6 +23,9 @@ class Location
|
|
22
23
|
@name = caller_location.base_label
|
23
24
|
end
|
24
25
|
@path = caller_location.path || 'unknown'
|
26
|
+
if @path.start_with?(@@current_dir)
|
27
|
+
@path = @path[@@current_dir.length..-1]
|
28
|
+
end
|
25
29
|
@lineno = caller_location.lineno
|
26
30
|
end
|
27
31
|
end
|
data/lib/debugtrace/version.rb
CHANGED
data/lib/debugtrace.rb
CHANGED
@@ -78,7 +78,7 @@ module DebugTrace
|
|
78
78
|
|
79
79
|
return unless @@config.enabled?
|
80
80
|
|
81
|
-
@@logger.print("DebugTrace-rb #{DebugTrace::VERSION} on Ruby #{RUBY_VERSION}")
|
81
|
+
@@logger.print("DebugTrace-rb #{DebugTrace::VERSION} on Ruby #{RUBY_VERSION} / #{RUBY_PLATFORM}")
|
82
82
|
@@logger.print(" config file: #{config_path}")
|
83
83
|
@@logger.print(" logger: #{@@logger}")
|
84
84
|
end
|
@@ -168,8 +168,16 @@ module DebugTrace
|
|
168
168
|
when Module
|
169
169
|
buff.append(value.name).no_break_append(' module')
|
170
170
|
when String
|
171
|
-
value_buff =
|
172
|
-
|
171
|
+
value_buff = nil
|
172
|
+
if print_options.string_as_bytes && value.encoding == Encoding::ASCII_8BIT
|
173
|
+
value_buff = to_string_bytes(value, print_options)
|
174
|
+
else
|
175
|
+
begin
|
176
|
+
value_buff = to_string_str(value, print_options)
|
177
|
+
rescue
|
178
|
+
value_buff = to_string_bytes(value, print_options)
|
179
|
+
end
|
180
|
+
end
|
173
181
|
buff.append_buffer(value_buff)
|
174
182
|
when DateTime, Time
|
175
183
|
buff.append(value.strftime('%Y-%m-%d %H:%M:%S.%L%:z'))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debugtrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masato Kokubo
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- README_ja.md
|
27
27
|
- Rakefile
|
28
28
|
- examples/debugtrace.yml
|
29
|
+
- examples/enumerable-example.rb
|
29
30
|
- examples/readme-example.rb
|
30
31
|
- lib/debugtrace.rb
|
31
32
|
- lib/debugtrace/common.rb
|
@@ -57,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
58
|
- !ruby/object:Gem::Version
|
58
59
|
version: '0'
|
59
60
|
requirements: []
|
60
|
-
rubygems_version: 3.
|
61
|
+
rubygems_version: 3.7.2
|
61
62
|
specification_version: 4
|
62
63
|
summary: DebugTrace-rb is a library that helps debug ruby programs.
|
63
64
|
test_files: []
|