dbg-rb 0.2.2 → 0.2.4

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: 32d1a708880ea34d5100e660696d864bb1aa5176612b9684152921348ffd0269
4
- data.tar.gz: 1b0647a7409f8c4ac564b0ae69ac33ea0a591ed2de8dff2e5ca3967dc3037c6f
3
+ metadata.gz: 06ece8262bca3c3a9d03add835a5fe4eeaffa8e361b1e5326d0b4a065cfa6a0c
4
+ data.tar.gz: 9f7dec1e66d87d71926eea65bb077083b4daafde9055c4f9e611ac6ba710b93a
5
5
  SHA512:
6
- metadata.gz: 86c169bffb8ddafe0f382803b841ac0e5cbf02e86deab1b28c43b0d734e2aaac2d1df32619e5c5b8a4c384276612e059c45e60600bb18dc861354f675f4ba20f
7
- data.tar.gz: 609749a0c676334dfe8d9bea10f4d57080dc9b38d442211134c20df37831ad13e03588b044ccdc077a3d4db70c36b95a4e66dfb9da8b729e17463c9787cf89f3
6
+ metadata.gz: 4afe7542dbad65fc2564b33d7f5db219546eaa40cd7e365a14f0f80904e587566f63bb488d6f619da5e9104480147e4db51cf8eec29c35201e0b2fe17b2292c3
7
+ data.tar.gz: 611c0e692fd8c1300f46c073eda4ed09155d0221d9068fc70dcd8ecd0b2669f13f39ce1df9fb0125ce7255e9c395046b631ea1b6d32d066d4ab2e7d548db6255
@@ -27,4 +27,4 @@ jobs:
27
27
  bundle install
28
28
  - name: Run tests
29
29
  run: |
30
- bundle exec rake test
30
+ bundle exec rspec spec
data/README.md CHANGED
@@ -12,7 +12,7 @@ p '!!!!!!!!!!!!!!!'
12
12
 
13
13
  too many times already.
14
14
 
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.
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!` and `dbg` methods that you can use for puts debugging:
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!(:a, :b)
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!(:user)
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!("User last", :user)
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!` highlighting:
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
@@ -1,9 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
-
4
3
  Rake::TestTask.new do |t|
5
4
  t.libs << "test"
6
5
  end
7
-
8
6
  desc "Run tests"
9
7
  task :default => :test
8
+
9
+ task :test do
10
+ system("bundle exec rspec spec")
11
+ end
@@ -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
- if (val = binding.of_caller(4).local_variable_get(obj))
49
- val = format_val(val)
48
+ val = binding.of_caller(4).local_variable_get(obj)
49
+ val = format_val(val)
50
50
 
51
- "#{obj} = #{val}"
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 dgb dbg!
103
+ alias dbg dbg!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DbgRb
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.4"
5
5
  end
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!("123") }.to output("[spec/smoke_spec.rb:9] \"123\"\n").to_stdout
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!(:b) }.to output("[spec/smoke_spec.rb:14] b = 123\n").to_stdout
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!(:c) }.to output("[spec/smoke_spec.rb:19] :c\n").to_stdout
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
- dgb(123)
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.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-12 00:00:00.000000000 Z
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