ruby-dbg 0.0.1 β†’ 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33f3c6c9714873133b2a1ef2c27cf3082c2fc7d3f21da8bea618b736c5ec9c08
4
- data.tar.gz: dd6538c2ccbece1f6cb2075fc40f3945e42a01169e760b303cb60cc1600a488f
3
+ metadata.gz: f49c49046c1082711b730c0a0b1460d36672d1936c9a8419f41c5965fabf17b8
4
+ data.tar.gz: 0fe0b76b354e9244c2ac4c04f4baa9cfcf0263dc5680ae50355e1f7f3e7e7fff
5
5
  SHA512:
6
- metadata.gz: 6064bc5754ea293363bddc8206945e118ffff14aa6de73131667c7f1484b1793e30a0b8861aa30447a66badd3d1666c0ec6fb4ac2e5970672bc28a4720c9d21e
7
- data.tar.gz: a4f49fb90164b6ae5402eeedf5874751365b10a39506195706b2c349adb4be7bb26d9507a59d7e84cfa35a3737a487e3f18fc41abc4bdf941d3c7043e19001b5
6
+ metadata.gz: 3f5892da2808610e1977a1fd53a247dc122a2626aac43719c2cd89604f452b080a26b68525299f4842fb72f2aa4688163897deba7a6f2b47519949e37ca0e2b7
7
+ data.tar.gz: a934c3c861b8cfe800722d659b3eccbbbc332d9941ec06a5d5540e43f1e362eece335a293241da70de31c94f7590f90c1cd83d27d26fe8dedaaf40d2aff5e175
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # Ruby dbg!
2
-
1
+ # Ruby dbg! [![Gem Version](https://badge.fury.io/rb/ruby-dbg.svg)](https://badge.fury.io/rb/ruby-dbg) [![GH Actions](https://github.com/pawurb/ruby-dbg/actions/workflows/ci.yml/badge.svg)](https://github.com/pawurb/ruby-dbg/actions)
2
+
3
3
  Because I wrote:
4
4
 
5
5
  ```ruby
@@ -19,7 +19,9 @@ too many times already.
19
19
  gem "ruby-dbg"
20
20
  ```
21
21
 
22
- It adds a global `dbg!` method. You can use it for puts debugging:
22
+ ## Usage
23
+
24
+ Gem adds a global `dbg!` method that you can use for puts debugging:
23
25
 
24
26
  ```ruby
25
27
  require "ruby-dbg"
@@ -29,7 +31,7 @@ dbg!(User.last.id)
29
31
 
30
32
  ```
31
33
 
32
- It appends relevant caller file and line info to the debug output.
34
+ It appends a caller file and line info to the debug output.
33
35
 
34
36
  You can use symbols to output local variable names together with their values:
35
37
 
@@ -45,7 +47,6 @@ dbg!(:a, :b)
45
47
  Hash values are pretty printed:
46
48
 
47
49
  ```ruby
48
-
49
50
  dbg!(User.last.as_json)
50
51
  # [web/users_controller.rb:10 {
51
52
  # "id": 160111,
@@ -55,7 +56,7 @@ dbg!(User.last.as_json)
55
56
  # }
56
57
  ```
57
58
 
58
- You can enable coloring the output:
59
+ You can color the output:
59
60
 
60
61
  `config/initializers/ruby_dbg.rb`
61
62
  ```ruby
@@ -69,10 +70,15 @@ RubyDBG.color_code = 36 # light blue
69
70
  # 35 pink
70
71
  ```
71
72
 
73
+ ```ruby
74
+ dbg!("User last", User.last.as_json.slice("id", "slack_id"))
75
+ ```
76
+
72
77
  ![Diagnose report](https://github.com/pawurb/ruby-dbg/raw/main/dbg_color.png)
73
78
 
74
79
  If it does not stand out enough, you can enable `dbg!` highlighting:
75
80
 
81
+ `config/initializers/ruby_dbg.rb`
76
82
  ```ruby
77
83
  require "ruby-dbg"
78
84
 
@@ -81,6 +87,14 @@ RubyDBG.highlight!("πŸŽ‰πŸ’”πŸ’£πŸ•ΊπŸš€πŸ§¨πŸ™ˆπŸ€―πŸ₯³πŸŒˆπŸ¦„")
81
87
 
82
88
  ![Diagnose report](https://github.com/pawurb/ruby-dbg/raw/main/dbg_emoji.png)
83
89
 
90
+ You can also use `RubyDBG.dbg!(*msgs)` directly or wrap it to rename the helper method:
91
+
92
+ ```ruby
93
+ def dd(*msgs)
94
+ RubyDBG.dbg!(*msgs)
95
+ end
96
+ ```
97
+
84
98
  ## Status
85
99
 
86
100
  Contributions & ideas very welcome!
data/lib/ruby-dbg.rb CHANGED
@@ -18,7 +18,7 @@ module RubyDBG
18
18
  "\e[#{color_code}m#{str}\e[0m"
19
19
  end
20
20
 
21
- def self.dbg(*objs)
21
+ def self.dbg!(*msgs)
22
22
  loc = caller_locations.first(2).last.to_s
23
23
  matching_loc = loc.match(/.+(rb)\:\d+\:(in)\s/)
24
24
  src = if !matching_loc.nil?
@@ -30,9 +30,9 @@ module RubyDBG
30
30
  file = file.split("/").last(2).join("/")
31
31
  src = "[#{file}:#{line}]"
32
32
 
33
- objs.each_with_index do |obj, i|
33
+ msgs.each_with_index do |obj, i|
34
34
  first = i == 0
35
- last = i == (objs.size - 1)
35
+ last = i == (msgs.size - 1)
36
36
 
37
37
  val = if obj.is_a?(Symbol)
38
38
  begin
@@ -67,6 +67,8 @@ module RubyDBG
67
67
 
68
68
  puts output
69
69
  end
70
+
71
+ nil
70
72
  end
71
73
 
72
74
  def self.format_val(val)
@@ -80,7 +82,6 @@ module RubyDBG
80
82
  end
81
83
  end
82
84
 
83
- def dbg!(*objs)
84
- RubyDBG.dbg(*objs)
85
- nil
85
+ def dbg!(*msgs)
86
+ RubyDBG.dbg!(*msgs)
86
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyDBG
4
- VERSION = "0.0.1"
4
+ VERSION = "0.1.0"
5
5
  end
data/ruby-dbg.gemspec CHANGED
@@ -8,11 +8,10 @@ Gem::Specification.new do |s|
8
8
  s.version = RubyDBG::VERSION
9
9
  s.authors = ["pawurb"]
10
10
  s.email = ["contact@pawelurbanek.com"]
11
- s.summary = %q{ Simple debug helper }
12
- s.description = %q{ Puts debugging helper, adding file context info and optional coloring. }
11
+ s.summary = "Simple debuging helper"
12
+ s.description = "Rust-inspired, puts debugging helper, adding caller info and optional coloring."
13
13
  s.homepage = "http://github.com/pawurb/ruby-dbg"
14
14
  s.files = `git ls-files`.split("\n").reject { |f| f.match?(/\.db$/) }
15
- s.test_files = s.files.grep(%r{^(spec)/})
16
15
  s.require_paths = ["lib"]
17
16
  s.license = "MIT"
18
17
  s.add_dependency "binding_of_caller"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-dbg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
@@ -66,7 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: " Puts debugging helper, adding file context info and optional coloring. "
69
+ description: Rust-inspired, puts debugging helper, adding caller info and optional
70
+ coloring.
70
71
  email:
71
72
  - contact@pawelurbanek.com
72
73
  executables: []
@@ -109,7 +110,5 @@ requirements: []
109
110
  rubygems_version: 3.5.23
110
111
  signing_key:
111
112
  specification_version: 4
112
- summary: Simple debug helper
113
- test_files:
114
- - spec/smoke_spec.rb
115
- - spec/spec_helper.rb
113
+ summary: Simple debuging helper
114
+ test_files: []