dbg-rb 0.2.6 β 0.2.7
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/README.md +4 -4
- data/dbg_base.png +0 -0
- data/dbg_emoji.png +0 -0
- data/lib/dbg-rb.rb +24 -8
- data/lib/dbg_rb/version.rb +1 -1
- data/spec/smoke_spec.rb +25 -11
- metadata +4 -5
- data/dbg_base3.png +0 -0
- data/dbg_color.png +0 -0
- data/dbg_emoji2.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5770fbaace622a132343f1fbcc953b69e10c0fe851daae5bd581ac46e4305b92
|
4
|
+
data.tar.gz: b32fa55c69cb49e948492977537a52866b209bdca4ccedf788b864bff603a777
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f53b4203570a36a3e339be81521dc97827837b80f6b749e2ed6a91b217effd2f69d4b69cc462dc763d112f5b92e34cfe41ec44989a4570a30f8f985edea25ac0
|
7
|
+
data.tar.gz: b3c1cb8ee19a768fe74519140f5d209a40a1e17f5b474628567c25fe7d95cb50070a94f3926e212a8bb08adbfbcd9e1f4a86eccd5a7271981fdd9503d25ff396
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# dbg! [](https://badge.fury.io/rb/dbg-rb) [](https://github.com/pawurb/dbg-rb/actions)
|
2
2
|
|
3
|
-

|
4
4
|
|
5
5
|
Because I wrote:
|
6
6
|
|
@@ -77,7 +77,7 @@ DbgRb.color_code = 33
|
|
77
77
|
It's yellow by default. You can disable colors by running:
|
78
78
|
|
79
79
|
```ruby
|
80
|
-
DbgRb.color_code= nil
|
80
|
+
DbgRb.color_code = nil
|
81
81
|
```
|
82
82
|
|
83
83
|
```ruby
|
@@ -85,7 +85,7 @@ user = User.last.as_json.slice("id", "slack_id")
|
|
85
85
|
dbg("User last", :user)
|
86
86
|
```
|
87
87
|
|
88
|
-

|
89
89
|
|
90
90
|
If it does not stand out enough, you can enable `dbg` highlighting:
|
91
91
|
|
@@ -96,7 +96,7 @@ require "dbg-rb"
|
|
96
96
|
DbgRb.highlight!("πππ£πΊππ§¨ππ€―π₯³ππ¦")
|
97
97
|
```
|
98
98
|
|
99
|
-

|
100
100
|
|
101
101
|
You can also use `DbgRb.dbg!(*msgs)` directly or wrap it to rename the helper method:
|
102
102
|
|
data/dbg_base.png
ADDED
Binary file
|
data/dbg_emoji.png
ADDED
Binary file
|
data/lib/dbg-rb.rb
CHANGED
@@ -51,7 +51,7 @@ module DbgRb
|
|
51
51
|
|
52
52
|
"#{obj} = #{val}"
|
53
53
|
rescue NameError
|
54
|
-
|
54
|
+
obj.inspect
|
55
55
|
end
|
56
56
|
else
|
57
57
|
format_val(obj)
|
@@ -79,19 +79,35 @@ module DbgRb
|
|
79
79
|
nil
|
80
80
|
end
|
81
81
|
|
82
|
+
private
|
83
|
+
|
82
84
|
def colorize(str, color_code)
|
83
85
|
"\e[#{color_code}m#{str}\e[0m"
|
84
86
|
end
|
85
87
|
|
86
88
|
def format_val(val)
|
87
|
-
if val.
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
if val.is_a?(Hash)
|
90
|
+
res = val.map { |k, v| [k, dbg_inspect(v, quote_str: false)] }.to_h
|
91
|
+
JSON.pretty_generate(res)
|
92
|
+
elsif val.is_a?(Array)
|
93
|
+
JSON.pretty_generate(val.map do |v|
|
94
|
+
dbg_inspect(v, quote_str: false)
|
95
|
+
end)
|
96
|
+
else
|
97
|
+
dbg_inspect(val, quote_str: true)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def dbg_inspect(obj, quote_str:)
|
102
|
+
if quote_str && obj.is_a?(String)
|
103
|
+
return obj.inspect
|
104
|
+
end
|
105
|
+
|
106
|
+
case obj
|
107
|
+
when Numeric, String
|
108
|
+
obj
|
93
109
|
else
|
94
|
-
|
110
|
+
obj.inspect
|
95
111
|
end
|
96
112
|
end
|
97
113
|
end
|
data/lib/dbg_rb/version.rb
CHANGED
data/spec/smoke_spec.rb
CHANGED
@@ -5,47 +5,51 @@ require "dbg-rb"
|
|
5
5
|
require "ostruct"
|
6
6
|
|
7
7
|
describe DbgRb do
|
8
|
+
before do
|
9
|
+
DbgRb.color_code = nil
|
10
|
+
end
|
11
|
+
|
8
12
|
it "variable values" do
|
9
|
-
expect { dbg("123") }.to output("[spec/smoke_spec.rb:
|
13
|
+
expect { dbg("123") }.to output("[spec/smoke_spec.rb:13] \"123\"\n").to_stdout
|
10
14
|
end
|
11
15
|
|
12
16
|
it "binded variables" do
|
13
17
|
b = 123
|
14
|
-
expect { dbg(:b) }.to output("[spec/smoke_spec.rb:
|
18
|
+
expect { dbg(:b) }.to output("[spec/smoke_spec.rb:18] b = 123\n").to_stdout
|
15
19
|
end
|
16
20
|
|
17
21
|
it "missing binded variables" do
|
18
22
|
b = 123
|
19
|
-
expect { dbg(:c) }.to output("[spec/smoke_spec.rb:
|
23
|
+
expect { dbg(:c) }.to output("[spec/smoke_spec.rb:23] :c\n").to_stdout
|
20
24
|
end
|
21
25
|
|
22
26
|
it "complex objects" do
|
23
27
|
s = OpenStruct.new(a: 1, b: 2)
|
24
|
-
expect { dbg!(s) }.to output("[spec/smoke_spec.rb:
|
28
|
+
expect { dbg!(s) }.to output("[spec/smoke_spec.rb:28] #<OpenStruct a=1, b=2>\n").to_stdout
|
25
29
|
end
|
26
30
|
|
27
31
|
it "binded complex objects" do
|
28
32
|
s = OpenStruct.new(a: 1, b: 2)
|
29
|
-
expect { dbg!(:s) }.to output("[spec/smoke_spec.rb:
|
33
|
+
expect { dbg!(:s) }.to output("[spec/smoke_spec.rb:33] s = #<OpenStruct a=1, b=2>\n").to_stdout
|
30
34
|
end
|
31
35
|
|
32
36
|
it "multiple msg" do
|
33
37
|
s = OpenStruct.new(a: 1, b: 2)
|
34
|
-
expect { dbg!(:s, "other msg") }.to output("[spec/smoke_spec.rb:
|
38
|
+
expect { dbg!(:s, "other msg") }.to output("[spec/smoke_spec.rb:38] s = #<OpenStruct a=1, b=2>\n[spec/smoke_spec.rb:38] \"other msg\"\n").to_stdout
|
35
39
|
end
|
36
40
|
|
37
41
|
it "nil" do
|
38
|
-
expect { dbg!(nil) }.to output("[spec/smoke_spec.rb:
|
42
|
+
expect { dbg!(nil) }.to output("[spec/smoke_spec.rb:42] nil\n").to_stdout
|
39
43
|
end
|
40
44
|
|
41
45
|
it "higlight" do
|
42
46
|
DbgRb.highlight!
|
43
|
-
expect { dbg!("123") }.to output("!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/smoke_spec.rb:
|
47
|
+
expect { dbg!("123") }.to output("!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/smoke_spec.rb:47] \"123\"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n").to_stdout
|
44
48
|
end
|
45
49
|
|
46
50
|
it "color_code" do
|
47
51
|
DbgRb.color_code = 31
|
48
|
-
expect { dbg!(123) }.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/smoke_spec.rb:
|
52
|
+
expect { dbg!(123) }.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/smoke_spec.rb:52] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
|
49
53
|
end
|
50
54
|
|
51
55
|
it "alias" do
|
@@ -54,11 +58,21 @@ describe DbgRb do
|
|
54
58
|
|
55
59
|
expect {
|
56
60
|
dbg(123)
|
57
|
-
}.to output("[spec/smoke_spec.rb:
|
61
|
+
}.to output("[spec/smoke_spec.rb:60] 123\n").to_stdout
|
58
62
|
end
|
59
63
|
|
60
64
|
it "binded nil variables" do
|
61
65
|
b = nil
|
62
|
-
expect { dbg(:b) }.to output("[spec/smoke_spec.rb:
|
66
|
+
expect { dbg(:b) }.to output("[spec/smoke_spec.rb:66] b = nil\n").to_stdout
|
67
|
+
end
|
68
|
+
|
69
|
+
it "hashes" do
|
70
|
+
h = { a: 1, b: "2" }
|
71
|
+
expect { dbg!(h) }.to output("[spec/smoke_spec.rb:71] {\n \"a\": 1,\n \"b\": \"2\"\n}\n").to_stdout
|
72
|
+
end
|
73
|
+
|
74
|
+
it "arrays" do
|
75
|
+
a = [1, "str"]
|
76
|
+
expect { dbg!(a) }.to output("[spec/smoke_spec.rb:76] [\n 1,\n \"str\"\n]\n").to_stdout
|
63
77
|
end
|
64
78
|
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.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -95,9 +95,8 @@ files:
|
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
97
|
- dbg-rb.gemspec
|
98
|
-
-
|
99
|
-
-
|
100
|
-
- dbg_emoji2.png
|
98
|
+
- dbg_base.png
|
99
|
+
- dbg_emoji.png
|
101
100
|
- lib/dbg-rb.rb
|
102
101
|
- lib/dbg_rb/version.rb
|
103
102
|
- spec/smoke_spec.rb
|
data/dbg_base3.png
DELETED
Binary file
|
data/dbg_color.png
DELETED
Binary file
|
data/dbg_emoji2.png
DELETED
Binary file
|