dbg-rb 0.3.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd12005e78ffa686afda779eabb3adf25011f8c2c53a8aeba8b34115f6fc481a
4
- data.tar.gz: 4854bb2a74440292fb681b949dcbb44af0c25fb8fba074de45df923827c6f9dc
3
+ metadata.gz: 0d82a9c04865692653212313f996cf4fb9a6830527bbe4ed5558d66399b35aeb
4
+ data.tar.gz: 6ad01658fc39a212899f8d77855a4511b752c1b3da424a783f122b9223f22408
5
5
  SHA512:
6
- metadata.gz: 2cf2c64ce51787a3613c57a37c090166e22d26b23cf832e00ac1a087469f8eb77beb18a60f85665cd1b50222161a860b7de89383a8ac349667f833f0968922a0
7
- data.tar.gz: 6be32da1ee94b9c02ad0be8156daceda13a775482d8f51a30150652b6e2b41d70cc4cb88169e00da3a519efd75fb25c342713b7a43376cd210d907beaaec310e
6
+ metadata.gz: 246eb6ddd67d12911245d1423cfec870dd72dfc5b8e513aee1c2d4b47d2d9d19398a046f6847f0d8359716c772cbe11aaaf9c71e0d5ff4934152605710d4c7e5
7
+ data.tar.gz: 312ae9d10b0c13979a18337ab645eec926a385f65307d2850a061852bf6de52ef3892fad546c32ab82c4f3cfd41a9e85e71c16b46ff144ef1dbaec6d1f5c8be0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dbg [![Gem Version](https://badge.fury.io/rb/dbg-rb.svg)](https://badge.fury.io/rb/dbg-rb) [![GH Actions](https://github.com/pawurb/dbg-rb/actions/workflows/ci.yml/badge.svg)](https://github.com/pawurb/dbg-rb/actions)
2
2
 
3
- ![Dbg base](https://github.com/pawurb/dbg-rb/raw/main/dbg_base.png)
3
+ ![Dbg base](https://github.com/pawurb/dbg-rb/raw/main/dbg_base2.png)
4
4
 
5
5
  Because I wrote:
6
6
 
@@ -28,29 +28,18 @@ Gem adds a global `dbg` method that you can use for puts debugging:
28
28
  require "dbg-rb"
29
29
 
30
30
  dbg(User.last.id)
31
- # [web/user_sessions_controller.rb:37] 1972
31
+ # [web/user_sessions_controller.rb:37] User.last.id = 1972
32
32
 
33
33
  ```
34
34
 
35
- It appends a caller file and line info to the debug output.
36
-
37
- You can use symbols to output local variable names together with their values:
38
-
39
- ```ruby
40
- a = 1
41
- b = 2
42
-
43
- dbg(:a, :b)
44
- # [models/user.rb:22] a = 1
45
- # [models/user.rb:22] b = 2
46
- ```
35
+ It appends a caller file, line info and source expression to the debug output.
47
36
 
48
37
  Hash values are pretty printed:
49
38
 
50
39
  ```ruby
51
- user = User.last.as_json
52
- dbg(:user)
53
- # [web/users_controller.rb:10 user = {
40
+
41
+ dbg(User.last.as_json)
42
+ # [web/users_controller.rb:10] User.last.as_json = {
54
43
  # "id": 160111,
55
44
  # "team_id": 1,
56
45
  # "pseudonym": "Anonymous-CBWE",
@@ -80,11 +69,10 @@ DbgRb.color_code = nil
80
69
  ```
81
70
 
82
71
  ```ruby
83
- user = User.last.as_json.slice("id", "slack_id")
84
- dbg("User last", :user)
72
+ dbg(User.last(2).map(&:as_json))
85
73
  ```
86
74
 
87
- ![Dbg color](https://github.com/pawurb/dbg-rb/raw/main/dbg_base.png)
75
+ ![Dbg color](https://github.com/pawurb/dbg-rb/raw/main/dbg_base2.png)
88
76
 
89
77
  If it does not stand out enough, you can enable `dbg` highlighting:
90
78
 
data/Rakefile CHANGED
@@ -7,6 +7,6 @@ desc "Run tests"
7
7
  task :default => :test
8
8
 
9
9
  task :test do
10
- system("bundle exec rspec spec/gem_spec.rb")
10
+ system("bundle exec rspec spec/main_spec.rb")
11
11
  system("bundle exec rspec spec/inline_spec.rb")
12
12
  end
data/dbg_base2.png ADDED
Binary file
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.split(":").first
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
- File.open(file) do |f|
67
- f.each_line.with_index do |line, i|
68
- if i == loc.lineno - 1
69
- input = line.split("dbg").last.chomp.strip
70
- input = input.gsub(/[()]/, "").strip
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
- end
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}"
@@ -116,7 +126,7 @@ module DbgRb
116
126
  dbg_inspect(val, quote_str: true)
117
127
  end.then do |value|
118
128
  if value.is_a?(String)
119
- value.gsub("\"nil\"", "nil")
129
+ value.gsub("\"nil\"", "nil").gsub("\\", "")
120
130
  else
121
131
  value
122
132
  end
@@ -129,8 +139,15 @@ module DbgRb
129
139
  end
130
140
 
131
141
  case obj
132
- when Numeric, String
142
+ when Numeric
133
143
  obj
144
+ when String
145
+ # Handle binary strings by showing their hex representation
146
+ if obj.encoding == Encoding::ASCII_8BIT
147
+ obj.bytes.map { |b| "\\x#{b.to_s(16).rjust(2, '0')}" }.join
148
+ else
149
+ obj
150
+ end
134
151
  else
135
152
  obj.inspect
136
153
  end
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.split(":").first
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
- File.open(file) do |f|
43
- f.each_line.with_index do |line, i|
44
- if i == loc.lineno - 1
45
- input = line.split("dbg").last.chomp.strip
46
- input = input.gsub(/[()]/, "").strip
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
- end
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}"
@@ -92,7 +102,7 @@ module DbgRb
92
102
  dbg_inspect(val, quote_str: true)
93
103
  end.then do |value|
94
104
  if value.is_a?(String)
95
- value.gsub("\"nil\"", "nil")
105
+ value.gsub("\"nil\"", "nil").gsub("\\", "")
96
106
  else
97
107
  value
98
108
  end
@@ -105,8 +115,15 @@ module DbgRb
105
115
  end
106
116
 
107
117
  case obj
108
- when Numeric, String
118
+ when Numeric
109
119
  obj
120
+ when String
121
+ # Handle binary strings by showing their hex representation
122
+ if obj.encoding == Encoding::ASCII_8BIT
123
+ obj.bytes.map { |b| "\\x#{b.to_s(16).rjust(2, '0')}" }.join
124
+ else
125
+ obj
126
+ end
110
127
  else
111
128
  obj.inspect
112
129
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DbgRb
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2"
5
5
  end
data/spec/inline_spec.rb CHANGED
@@ -1,38 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "spec_helper"
4
- require "dbg-rb"
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:14] \"123\"\n").to_stdout
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:18] 123\n").to_stdout
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:22] nil\n").to_stdout
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:26] \"123\"\n").to_stdout
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:30] 123\n").to_stdout
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:34] nil\n").to_stdout
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:42] a = 123\n").to_stdout
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:48] b = \"123\"\n").to_stdout
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:54] c = nil\n").to_stdout
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:62] s = #<OpenStruct a=1, b=2>\n").to_stdout
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:69] h = {\n \"a\": 1,\n \"b\": \"2\"\n}\n").to_stdout
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:76] a = [\n 1,\n \"str\"\n]\n").to_stdout
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:83] h = {\n \"a\": 1,\n \"b\": \"2\",\n \"c\": nil\n}\n").to_stdout
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:90] \"123\"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n").to_stdout
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!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/inline_spec.rb:97] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
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,24 @@ 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:105] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
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
118
+ end
119
+
120
+ it "binary input" do
121
+ random_bytes = Random.new.bytes(8)
122
+
123
+ expect do
124
+ dbg(random_bytes)
125
+ end.not_to raise_error
107
126
  end
108
127
  end
data/spec/main_spec.rb ADDED
@@ -0,0 +1,127 @@
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
+
120
+ it "binary input" do
121
+ random_bytes = Random.new.bytes(8)
122
+
123
+ expect do
124
+ dbg(random_bytes)
125
+ end.not_to raise_error
126
+ end
127
+ 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.0
4
+ version: 0.3.2
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-19 00:00:00.000000000 Z
11
+ date: 2025-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -95,13 +95,14 @@ files:
95
95
  - README.md
96
96
  - Rakefile
97
97
  - dbg-rb.gemspec
98
- - dbg_base.png
98
+ - dbg_base2.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/dbg_base.png DELETED
Binary file
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