dbg-rb 0.3.0 → 0.3.1
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/Rakefile +1 -1
- data/inline/dbg_rb.rb +22 -12
- data/inline/sync.rb +37 -0
- data/lib/dbg-rb.rb +21 -11
- data/lib/dbg_rb/version.rb +1 -1
- data/spec/inline_spec.rb +28 -17
- data/spec/main_spec.rb +119 -0
- metadata +4 -3
- data/spec/gem_spec.rb +0 -108
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc71d393c746d79980c413057430f8f9e473d2746a343dc64ec3289dc6ea278e
|
4
|
+
data.tar.gz: 6de928faad269dfa03dedc2e0f0606444cd3df2f8ce1f8660dbbdcf580b4a6ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6c4ccb43238e5c47639339588589cdc4b175acf9cfb5ed62e332f03d9a738824891ce980f2ec8d3582ba66b7f9cc63fdb2b15868e2108f79b7dc3456810fa28
|
7
|
+
data.tar.gz: 6098cf547b0efce0ef4f0751e3ae4d067b0e19864315de0de515f644da367d86b520370778eb016d9b0722a6e312e948692b6006fd2d2cfafa6bfc80c08e65cc
|
data/Rakefile
CHANGED
data/inline/dbg_rb.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Source https://github.com/pawurb/dbg-rb
|
3
|
+
# Source https://github.com/pawurb/dbg-rb
|
4
4
|
# The MIT License (MIT)
|
5
5
|
|
6
6
|
# Copyright © Paweł Urbanek 2024
|
@@ -59,28 +59,38 @@ module DbgRb
|
|
59
59
|
loc.label
|
60
60
|
end
|
61
61
|
|
62
|
-
file = loc.absolute_path
|
62
|
+
file = if (path = loc.absolute_path)
|
63
|
+
path.split(":").first
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
63
67
|
|
64
68
|
input = nil
|
65
69
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
if file
|
71
|
+
File.open(file) do |f|
|
72
|
+
f.each_line.with_index do |line, i|
|
73
|
+
if i == loc.lineno - 1
|
74
|
+
splitby, remove_parantheses = if line.include?("dbg(")
|
75
|
+
["dbg(", true]
|
76
|
+
else
|
77
|
+
["dbg ", false]
|
78
|
+
end
|
79
|
+
input = line.split(splitby).last.chomp.strip
|
80
|
+
input = input.sub(/\)[^)]*\z/, "") if remove_parantheses
|
81
|
+
input
|
82
|
+
end
|
71
83
|
end
|
72
84
|
end
|
73
|
-
|
74
|
-
|
75
|
-
if input.nil?
|
76
|
-
raise "It should never happen!"
|
85
|
+
else
|
86
|
+
input = nil
|
77
87
|
end
|
78
88
|
|
79
89
|
line = loc.lineno
|
80
90
|
src = "[#{source_file}:#{line}]"
|
81
91
|
value = format_val(value)
|
82
92
|
|
83
|
-
val = if input.to_s == value.to_s
|
93
|
+
val = if input.to_s == value.to_s || input.nil?
|
84
94
|
"#{value}"
|
85
95
|
else
|
86
96
|
"#{input} = #{value}"
|
data/inline/sync.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
FileUtils.cp("lib/dbg-rb.rb", "inline/dbg_rb.rb")
|
6
|
+
|
7
|
+
license = <<~LICENSE
|
8
|
+
# Source https://github.com/pawurb/dbg-rb
|
9
|
+
# The MIT License (MIT)
|
10
|
+
|
11
|
+
# Copyright © Paweł Urbanek 2024
|
12
|
+
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
# a copy of this software and associated documentation files (the
|
15
|
+
# "Software"), to deal in the Software without restriction, including
|
16
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
# the following conditions:
|
20
|
+
|
21
|
+
# The above copyright notice and this permission notice shall be
|
22
|
+
# included in all copies or substantial portions of the Software.
|
23
|
+
|
24
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
LICENSE
|
32
|
+
|
33
|
+
File.write("inline/dbg_rb.rb", File.read("inline/dbg_rb.rb").sub(/\A# frozen_string_literal: true\n/, "# frozen_string_literal: true\n\n#{license}"))
|
34
|
+
|
35
|
+
FileUtils.cp("spec/main_spec.rb", "spec/inline_spec.rb")
|
36
|
+
|
37
|
+
File.write("spec/inline_spec.rb", File.read("spec/inline_spec.rb").gsub(/main_spec/, "inline_spec").gsub("require \"dbg-rb\"", "require_relative '../inline/dbg_rb'"))
|
data/lib/dbg-rb.rb
CHANGED
@@ -35,28 +35,38 @@ module DbgRb
|
|
35
35
|
loc.label
|
36
36
|
end
|
37
37
|
|
38
|
-
file = loc.absolute_path
|
38
|
+
file = if (path = loc.absolute_path)
|
39
|
+
path.split(":").first
|
40
|
+
else
|
41
|
+
nil
|
42
|
+
end
|
39
43
|
|
40
44
|
input = nil
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
if file
|
47
|
+
File.open(file) do |f|
|
48
|
+
f.each_line.with_index do |line, i|
|
49
|
+
if i == loc.lineno - 1
|
50
|
+
splitby, remove_parantheses = if line.include?("dbg(")
|
51
|
+
["dbg(", true]
|
52
|
+
else
|
53
|
+
["dbg ", false]
|
54
|
+
end
|
55
|
+
input = line.split(splitby).last.chomp.strip
|
56
|
+
input = input.sub(/\)[^)]*\z/, "") if remove_parantheses
|
57
|
+
input
|
58
|
+
end
|
47
59
|
end
|
48
60
|
end
|
49
|
-
|
50
|
-
|
51
|
-
if input.nil?
|
52
|
-
raise "It should never happen!"
|
61
|
+
else
|
62
|
+
input = nil
|
53
63
|
end
|
54
64
|
|
55
65
|
line = loc.lineno
|
56
66
|
src = "[#{source_file}:#{line}]"
|
57
67
|
value = format_val(value)
|
58
68
|
|
59
|
-
val = if input.to_s == value.to_s
|
69
|
+
val = if input.to_s == value.to_s || input.nil?
|
60
70
|
"#{value}"
|
61
71
|
else
|
62
72
|
"#{input} = #{value}"
|
data/lib/dbg_rb/version.rb
CHANGED
data/spec/inline_spec.rb
CHANGED
@@ -1,38 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
|
-
|
4
|
+
require_relative '../inline/dbg_rb'
|
5
5
|
require "ostruct"
|
6
6
|
|
7
7
|
describe DbgRb do
|
8
8
|
before do
|
9
9
|
DbgRb.color_code = nil
|
10
|
+
DbgRb.highlight!(false)
|
10
11
|
end
|
11
12
|
|
12
13
|
it "constant values" do
|
13
14
|
expect do
|
14
15
|
dbg("123")
|
15
|
-
end.to output("[spec/inline_spec.rb:
|
16
|
+
end.to output("[spec/inline_spec.rb:15] \"123\"\n").to_stdout
|
16
17
|
|
17
18
|
expect do
|
18
19
|
dbg(123)
|
19
|
-
end.to output("[spec/inline_spec.rb:
|
20
|
+
end.to output("[spec/inline_spec.rb:19] 123\n").to_stdout
|
20
21
|
|
21
22
|
expect do
|
22
23
|
dbg(nil)
|
23
|
-
end.to output("[spec/inline_spec.rb:
|
24
|
+
end.to output("[spec/inline_spec.rb:23] nil\n").to_stdout
|
24
25
|
|
25
26
|
expect do
|
26
27
|
dbg "123"
|
27
|
-
end.to output("[spec/inline_spec.rb:
|
28
|
+
end.to output("[spec/inline_spec.rb:27] \"123\"\n").to_stdout
|
28
29
|
|
29
30
|
expect do
|
30
31
|
dbg 123
|
31
|
-
end.to output("[spec/inline_spec.rb:
|
32
|
+
end.to output("[spec/inline_spec.rb:31] 123\n").to_stdout
|
32
33
|
|
33
34
|
expect do
|
34
35
|
dbg nil
|
35
|
-
end.to output("[spec/inline_spec.rb:
|
36
|
+
end.to output("[spec/inline_spec.rb:35] nil\n").to_stdout
|
36
37
|
end
|
37
38
|
|
38
39
|
it "variables" do
|
@@ -40,19 +41,19 @@ describe DbgRb do
|
|
40
41
|
|
41
42
|
expect do
|
42
43
|
dbg(a)
|
43
|
-
end.to output("[spec/inline_spec.rb:
|
44
|
+
end.to output("[spec/inline_spec.rb:43] a = 123\n").to_stdout
|
44
45
|
|
45
46
|
b = "123"
|
46
47
|
|
47
48
|
expect do
|
48
49
|
dbg(b)
|
49
|
-
end.to output("[spec/inline_spec.rb:
|
50
|
+
end.to output("[spec/inline_spec.rb:49] b = \"123\"\n").to_stdout
|
50
51
|
|
51
52
|
c = nil
|
52
53
|
|
53
54
|
expect do
|
54
55
|
dbg(c)
|
55
|
-
end.to output("[spec/inline_spec.rb:
|
56
|
+
end.to output("[spec/inline_spec.rb:55] c = nil\n").to_stdout
|
56
57
|
end
|
57
58
|
|
58
59
|
it "complex objects" do
|
@@ -60,42 +61,42 @@ describe DbgRb do
|
|
60
61
|
|
61
62
|
expect do
|
62
63
|
dbg(s)
|
63
|
-
end.to output("[spec/inline_spec.rb:
|
64
|
+
end.to output("[spec/inline_spec.rb:63] s = #<OpenStruct a=1, b=2>\n").to_stdout
|
64
65
|
end
|
65
66
|
|
66
67
|
it "hashes" do
|
67
68
|
h = { a: 1, b: "2" }
|
68
69
|
expect do
|
69
70
|
dbg(h)
|
70
|
-
end.to output("[spec/inline_spec.rb:
|
71
|
+
end.to output("[spec/inline_spec.rb:70] h = {\n \"a\": 1,\n \"b\": \"2\"\n}\n").to_stdout
|
71
72
|
end
|
72
73
|
|
73
74
|
it "arrays" do
|
74
75
|
a = [1, "str"]
|
75
76
|
expect do
|
76
77
|
dbg(a)
|
77
|
-
end.to output("[spec/inline_spec.rb:
|
78
|
+
end.to output("[spec/inline_spec.rb:77] a = [\n 1,\n \"str\"\n]\n").to_stdout
|
78
79
|
end
|
79
80
|
|
80
81
|
it "hash formatting" do
|
81
82
|
h = { a: 1, b: "2", c: nil }
|
82
83
|
expect do
|
83
84
|
dbg(h)
|
84
|
-
end.to output("[spec/inline_spec.rb:
|
85
|
+
end.to output("[spec/inline_spec.rb:84] h = {\n \"a\": 1,\n \"b\": \"2\",\n \"c\": nil\n}\n").to_stdout
|
85
86
|
end
|
86
87
|
|
87
88
|
it "highlight" do
|
88
89
|
DbgRb.highlight!
|
89
90
|
expect do
|
90
91
|
dbg("123")
|
91
|
-
end.to output("!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/inline_spec.rb:
|
92
|
+
end.to output("!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/inline_spec.rb:91] \"123\"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n").to_stdout
|
92
93
|
end
|
93
94
|
|
94
95
|
it "color_code" do
|
95
96
|
DbgRb.color_code = 31
|
96
97
|
expect do
|
97
98
|
dbg(123)
|
98
|
-
end.to output("\e[31m
|
99
|
+
end.to output("\e[31m[spec/inline_spec.rb:98] 123\e[0m\n").to_stdout
|
99
100
|
end
|
100
101
|
|
101
102
|
it "highlight and color_code" do
|
@@ -103,6 +104,16 @@ describe DbgRb do
|
|
103
104
|
DbgRb.color_code = 31
|
104
105
|
expect do
|
105
106
|
dbg(123)
|
106
|
-
end.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/inline_spec.rb:
|
107
|
+
end.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/inline_spec.rb:106] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
|
108
|
+
end
|
109
|
+
|
110
|
+
it "complex expression" do
|
111
|
+
expect do
|
112
|
+
dbg([1, 2, 3].reduce(0) { |i, agg| agg + i })
|
113
|
+
end.to output("[spec/inline_spec.rb:112] [1, 2, 3].reduce(0) { |i, agg| agg + i } = 6\n").to_stdout
|
114
|
+
|
115
|
+
expect do
|
116
|
+
dbg [1, 2, 3].reduce(0) { |i, agg| agg + i }
|
117
|
+
end.to output("[spec/inline_spec.rb:116] [1, 2, 3].reduce(0) { |i, agg| agg + i } = 6\n").to_stdout
|
107
118
|
end
|
108
119
|
end
|
data/spec/main_spec.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "dbg-rb"
|
5
|
+
require "ostruct"
|
6
|
+
|
7
|
+
describe DbgRb do
|
8
|
+
before do
|
9
|
+
DbgRb.color_code = nil
|
10
|
+
DbgRb.highlight!(false)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "constant values" do
|
14
|
+
expect do
|
15
|
+
dbg("123")
|
16
|
+
end.to output("[spec/main_spec.rb:15] \"123\"\n").to_stdout
|
17
|
+
|
18
|
+
expect do
|
19
|
+
dbg(123)
|
20
|
+
end.to output("[spec/main_spec.rb:19] 123\n").to_stdout
|
21
|
+
|
22
|
+
expect do
|
23
|
+
dbg(nil)
|
24
|
+
end.to output("[spec/main_spec.rb:23] nil\n").to_stdout
|
25
|
+
|
26
|
+
expect do
|
27
|
+
dbg "123"
|
28
|
+
end.to output("[spec/main_spec.rb:27] \"123\"\n").to_stdout
|
29
|
+
|
30
|
+
expect do
|
31
|
+
dbg 123
|
32
|
+
end.to output("[spec/main_spec.rb:31] 123\n").to_stdout
|
33
|
+
|
34
|
+
expect do
|
35
|
+
dbg nil
|
36
|
+
end.to output("[spec/main_spec.rb:35] nil\n").to_stdout
|
37
|
+
end
|
38
|
+
|
39
|
+
it "variables" do
|
40
|
+
a = 123
|
41
|
+
|
42
|
+
expect do
|
43
|
+
dbg(a)
|
44
|
+
end.to output("[spec/main_spec.rb:43] a = 123\n").to_stdout
|
45
|
+
|
46
|
+
b = "123"
|
47
|
+
|
48
|
+
expect do
|
49
|
+
dbg(b)
|
50
|
+
end.to output("[spec/main_spec.rb:49] b = \"123\"\n").to_stdout
|
51
|
+
|
52
|
+
c = nil
|
53
|
+
|
54
|
+
expect do
|
55
|
+
dbg(c)
|
56
|
+
end.to output("[spec/main_spec.rb:55] c = nil\n").to_stdout
|
57
|
+
end
|
58
|
+
|
59
|
+
it "complex objects" do
|
60
|
+
s = OpenStruct.new(a: 1, b: 2)
|
61
|
+
|
62
|
+
expect do
|
63
|
+
dbg(s)
|
64
|
+
end.to output("[spec/main_spec.rb:63] s = #<OpenStruct a=1, b=2>\n").to_stdout
|
65
|
+
end
|
66
|
+
|
67
|
+
it "hashes" do
|
68
|
+
h = { a: 1, b: "2" }
|
69
|
+
expect do
|
70
|
+
dbg(h)
|
71
|
+
end.to output("[spec/main_spec.rb:70] h = {\n \"a\": 1,\n \"b\": \"2\"\n}\n").to_stdout
|
72
|
+
end
|
73
|
+
|
74
|
+
it "arrays" do
|
75
|
+
a = [1, "str"]
|
76
|
+
expect do
|
77
|
+
dbg(a)
|
78
|
+
end.to output("[spec/main_spec.rb:77] a = [\n 1,\n \"str\"\n]\n").to_stdout
|
79
|
+
end
|
80
|
+
|
81
|
+
it "hash formatting" do
|
82
|
+
h = { a: 1, b: "2", c: nil }
|
83
|
+
expect do
|
84
|
+
dbg(h)
|
85
|
+
end.to output("[spec/main_spec.rb:84] h = {\n \"a\": 1,\n \"b\": \"2\",\n \"c\": nil\n}\n").to_stdout
|
86
|
+
end
|
87
|
+
|
88
|
+
it "highlight" do
|
89
|
+
DbgRb.highlight!
|
90
|
+
expect do
|
91
|
+
dbg("123")
|
92
|
+
end.to output("!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/main_spec.rb:91] \"123\"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n").to_stdout
|
93
|
+
end
|
94
|
+
|
95
|
+
it "color_code" do
|
96
|
+
DbgRb.color_code = 31
|
97
|
+
expect do
|
98
|
+
dbg(123)
|
99
|
+
end.to output("\e[31m[spec/main_spec.rb:98] 123\e[0m\n").to_stdout
|
100
|
+
end
|
101
|
+
|
102
|
+
it "highlight and color_code" do
|
103
|
+
DbgRb.highlight!
|
104
|
+
DbgRb.color_code = 31
|
105
|
+
expect do
|
106
|
+
dbg(123)
|
107
|
+
end.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/main_spec.rb:106] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
|
108
|
+
end
|
109
|
+
|
110
|
+
it "complex expression" do
|
111
|
+
expect do
|
112
|
+
dbg([1, 2, 3].reduce(0) { |i, agg| agg + i })
|
113
|
+
end.to output("[spec/main_spec.rb:112] [1, 2, 3].reduce(0) { |i, agg| agg + i } = 6\n").to_stdout
|
114
|
+
|
115
|
+
expect do
|
116
|
+
dbg [1, 2, 3].reduce(0) { |i, agg| agg + i }
|
117
|
+
end.to output("[spec/main_spec.rb:116] [1, 2, 3].reduce(0) { |i, agg| agg + i } = 6\n").to_stdout
|
118
|
+
end
|
119
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbg-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
11
|
+
date: 2025-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -98,10 +98,11 @@ files:
|
|
98
98
|
- dbg_base.png
|
99
99
|
- dbg_emoji.png
|
100
100
|
- inline/dbg_rb.rb
|
101
|
+
- inline/sync.rb
|
101
102
|
- lib/dbg-rb.rb
|
102
103
|
- lib/dbg_rb/version.rb
|
103
|
-
- spec/gem_spec.rb
|
104
104
|
- spec/inline_spec.rb
|
105
|
+
- spec/main_spec.rb
|
105
106
|
- spec/spec_helper.rb
|
106
107
|
homepage: http://github.com/pawurb/dbg-rb
|
107
108
|
licenses:
|
data/spec/gem_spec.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "dbg-rb"
|
5
|
-
require "ostruct"
|
6
|
-
|
7
|
-
describe DbgRb do
|
8
|
-
before do
|
9
|
-
DbgRb.color_code = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it "constant values" do
|
13
|
-
expect do
|
14
|
-
dbg("123")
|
15
|
-
end.to output("[spec/gem_spec.rb:14] \"123\"\n").to_stdout
|
16
|
-
|
17
|
-
expect do
|
18
|
-
dbg(123)
|
19
|
-
end.to output("[spec/gem_spec.rb:18] 123\n").to_stdout
|
20
|
-
|
21
|
-
expect do
|
22
|
-
dbg(nil)
|
23
|
-
end.to output("[spec/gem_spec.rb:22] nil\n").to_stdout
|
24
|
-
|
25
|
-
expect do
|
26
|
-
dbg "123"
|
27
|
-
end.to output("[spec/gem_spec.rb:26] \"123\"\n").to_stdout
|
28
|
-
|
29
|
-
expect do
|
30
|
-
dbg 123
|
31
|
-
end.to output("[spec/gem_spec.rb:30] 123\n").to_stdout
|
32
|
-
|
33
|
-
expect do
|
34
|
-
dbg nil
|
35
|
-
end.to output("[spec/gem_spec.rb:34] nil\n").to_stdout
|
36
|
-
end
|
37
|
-
|
38
|
-
it "variables" do
|
39
|
-
a = 123
|
40
|
-
|
41
|
-
expect do
|
42
|
-
dbg(a)
|
43
|
-
end.to output("[spec/gem_spec.rb:42] a = 123\n").to_stdout
|
44
|
-
|
45
|
-
b = "123"
|
46
|
-
|
47
|
-
expect do
|
48
|
-
dbg(b)
|
49
|
-
end.to output("[spec/gem_spec.rb:48] b = \"123\"\n").to_stdout
|
50
|
-
|
51
|
-
c = nil
|
52
|
-
|
53
|
-
expect do
|
54
|
-
dbg(c)
|
55
|
-
end.to output("[spec/gem_spec.rb:54] c = nil\n").to_stdout
|
56
|
-
end
|
57
|
-
|
58
|
-
it "complex objects" do
|
59
|
-
s = OpenStruct.new(a: 1, b: 2)
|
60
|
-
|
61
|
-
expect do
|
62
|
-
dbg(s)
|
63
|
-
end.to output("[spec/gem_spec.rb:62] s = #<OpenStruct a=1, b=2>\n").to_stdout
|
64
|
-
end
|
65
|
-
|
66
|
-
it "hashes" do
|
67
|
-
h = { a: 1, b: "2" }
|
68
|
-
expect do
|
69
|
-
dbg(h)
|
70
|
-
end.to output("[spec/gem_spec.rb:69] h = {\n \"a\": 1,\n \"b\": \"2\"\n}\n").to_stdout
|
71
|
-
end
|
72
|
-
|
73
|
-
it "arrays" do
|
74
|
-
a = [1, "str"]
|
75
|
-
expect do
|
76
|
-
dbg(a)
|
77
|
-
end.to output("[spec/gem_spec.rb:76] a = [\n 1,\n \"str\"\n]\n").to_stdout
|
78
|
-
end
|
79
|
-
|
80
|
-
it "hash formatting" do
|
81
|
-
h = { a: 1, b: "2", c: nil }
|
82
|
-
expect do
|
83
|
-
dbg(h)
|
84
|
-
end.to output("[spec/gem_spec.rb:83] h = {\n \"a\": 1,\n \"b\": \"2\",\n \"c\": nil\n}\n").to_stdout
|
85
|
-
end
|
86
|
-
|
87
|
-
it "highlight" do
|
88
|
-
DbgRb.highlight!
|
89
|
-
expect do
|
90
|
-
dbg("123")
|
91
|
-
end.to output("!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/gem_spec.rb:90] \"123\"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n").to_stdout
|
92
|
-
end
|
93
|
-
|
94
|
-
it "color_code" do
|
95
|
-
DbgRb.color_code = 31
|
96
|
-
expect do
|
97
|
-
dbg(123)
|
98
|
-
end.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/gem_spec.rb:97] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
|
99
|
-
end
|
100
|
-
|
101
|
-
it "highlight and color_code" do
|
102
|
-
DbgRb.highlight!
|
103
|
-
DbgRb.color_code = 31
|
104
|
-
expect do
|
105
|
-
dbg(123)
|
106
|
-
end.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/gem_spec.rb:105] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
|
107
|
-
end
|
108
|
-
end
|