dbg-rb 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/README.md +6 -6
- data/Rakefile +4 -2
- data/{ruby-dbg.gemspec → dbg-rb.gemspec} +1 -0
- data/lib/dbg-rb.rb +4 -5
- data/lib/dbg_rb/version.rb +1 -1
- data/spec/smoke_spec.rb +9 -4
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06ece8262bca3c3a9d03add835a5fe4eeaffa8e361b1e5326d0b4a065cfa6a0c
|
4
|
+
data.tar.gz: 9f7dec1e66d87d71926eea65bb077083b4daafde9055c4f9e611ac6ba710b93a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4afe7542dbad65fc2564b33d7f5db219546eaa40cd7e365a14f0f80904e587566f63bb488d6f619da5e9104480147e4db51cf8eec29c35201e0b2fe17b2292c3
|
7
|
+
data.tar.gz: 611c0e692fd8c1300f46c073eda4ed09155d0221d9068fc70dcd8ecd0b2669f13f39ce1df9fb0125ce7255e9c395046b631ea1b6d32d066d4ab2e7d548db6255
|
data/.github/workflows/ci.yml
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ p '!!!!!!!!!!!!!!!'
|
|
12
12
|
|
13
13
|
too many times already.
|
14
14
|
|
15
|
-
`dbg
|
15
|
+
`dbg` is a minimal, [Rust inspired](https://doc.rust-lang.org/std/macro.dbg.html), *puts debugging* command for Ruby. It provides caller context and formatting helpful in everyday debugging tasks.
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
@@ -23,7 +23,7 @@ gem "dbg-rb"
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
Gem adds global `dbg
|
26
|
+
Gem adds a global `dbg` method that you can use for puts debugging:
|
27
27
|
|
28
28
|
```ruby
|
29
29
|
require "dbg-rb"
|
@@ -41,7 +41,7 @@ You can use symbols to output local variable names together with their values:
|
|
41
41
|
a = 1
|
42
42
|
b = 2
|
43
43
|
|
44
|
-
dbg
|
44
|
+
dbg(:a, :b)
|
45
45
|
# [models/user.rb:22] a = 1
|
46
46
|
# [models/user.rb:22] b = 2
|
47
47
|
```
|
@@ -50,7 +50,7 @@ Hash values are pretty printed:
|
|
50
50
|
|
51
51
|
```ruby
|
52
52
|
user = User.last.as_json
|
53
|
-
dbg
|
53
|
+
dbg(:user)
|
54
54
|
# [web/users_controller.rb:10 user = {
|
55
55
|
# "id": 160111,
|
56
56
|
# "team_id": 1,
|
@@ -76,12 +76,12 @@ DbgRb.color_code = 35
|
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
user = User.last.as_json.slice("id", "slack_id")
|
79
|
-
dbg
|
79
|
+
dbg("User last", :user)
|
80
80
|
```
|
81
81
|
|
82
82
|
![Dbg color](https://github.com/pawurb/dbg-rb/raw/main/dbg_base3.png)
|
83
83
|
|
84
|
-
If it does not stand out enough, you can enable `dbg
|
84
|
+
If it does not stand out enough, you can enable `dbg` highlighting:
|
85
85
|
|
86
86
|
`config/initializers/dbg_rb.rb`
|
87
87
|
```ruby
|
data/Rakefile
CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.require_paths = ["lib"]
|
16
16
|
s.license = "MIT"
|
17
17
|
s.add_dependency "binding_of_caller"
|
18
|
+
s.add_dependency "json"
|
18
19
|
s.add_development_dependency "rake"
|
19
20
|
s.add_development_dependency "rspec"
|
20
21
|
s.add_development_dependency "rufo"
|
data/lib/dbg-rb.rb
CHANGED
@@ -45,11 +45,10 @@ module DbgRb
|
|
45
45
|
|
46
46
|
val = if obj.is_a?(Symbol)
|
47
47
|
begin
|
48
|
-
|
49
|
-
|
48
|
+
val = binding.of_caller(4).local_variable_get(obj)
|
49
|
+
val = format_val(val)
|
50
50
|
|
51
|
-
|
52
|
-
end
|
51
|
+
"#{obj} = #{val}"
|
53
52
|
rescue NameError
|
54
53
|
":#{obj}"
|
55
54
|
end
|
@@ -101,4 +100,4 @@ def dbg!(*msgs)
|
|
101
100
|
DbgRb.dbg!(*msgs)
|
102
101
|
end
|
103
102
|
|
104
|
-
alias
|
103
|
+
alias dbg dbg!
|
data/lib/dbg_rb/version.rb
CHANGED
data/spec/smoke_spec.rb
CHANGED
@@ -6,17 +6,17 @@ require "ostruct"
|
|
6
6
|
|
7
7
|
describe DbgRb do
|
8
8
|
it "variable values" do
|
9
|
-
expect { dbg
|
9
|
+
expect { dbg("123") }.to output("[spec/smoke_spec.rb:9] \"123\"\n").to_stdout
|
10
10
|
end
|
11
11
|
|
12
12
|
it "binded variables" do
|
13
13
|
b = 123
|
14
|
-
expect { dbg
|
14
|
+
expect { dbg(:b) }.to output("[spec/smoke_spec.rb:14] b = 123\n").to_stdout
|
15
15
|
end
|
16
16
|
|
17
17
|
it "missing binded variables" do
|
18
18
|
b = 123
|
19
|
-
expect { dbg
|
19
|
+
expect { dbg(:c) }.to output("[spec/smoke_spec.rb:19] :c\n").to_stdout
|
20
20
|
end
|
21
21
|
|
22
22
|
it "complex objects" do
|
@@ -53,7 +53,12 @@ describe DbgRb do
|
|
53
53
|
DbgRb.color_code = nil
|
54
54
|
|
55
55
|
expect {
|
56
|
-
|
56
|
+
dbg(123)
|
57
57
|
}.to output("[spec/smoke_spec.rb:56] 123\n").to_stdout
|
58
58
|
end
|
59
|
+
|
60
|
+
it "binded nil variables" do
|
61
|
+
b = nil
|
62
|
+
expect { dbg(:b) }.to output("[spec/smoke_spec.rb:62] b = nil\n").to_stdout
|
63
|
+
end
|
59
64
|
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.4
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,12 +94,12 @@ files:
|
|
80
94
|
- LICENSE.txt
|
81
95
|
- README.md
|
82
96
|
- Rakefile
|
97
|
+
- dbg-rb.gemspec
|
83
98
|
- dbg_base3.png
|
84
99
|
- dbg_color.png
|
85
100
|
- dbg_emoji2.png
|
86
101
|
- lib/dbg-rb.rb
|
87
102
|
- lib/dbg_rb/version.rb
|
88
|
-
- ruby-dbg.gemspec
|
89
103
|
- spec/smoke_spec.rb
|
90
104
|
- spec/spec_helper.rb
|
91
105
|
homepage: http://github.com/pawurb/dbg-rb
|