dbg-rb 0.2.7 β†’ 0.3.0

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: 5770fbaace622a132343f1fbcc953b69e10c0fe851daae5bd581ac46e4305b92
4
- data.tar.gz: b32fa55c69cb49e948492977537a52866b209bdca4ccedf788b864bff603a777
3
+ metadata.gz: fd12005e78ffa686afda779eabb3adf25011f8c2c53a8aeba8b34115f6fc481a
4
+ data.tar.gz: 4854bb2a74440292fb681b949dcbb44af0c25fb8fba074de45df923827c6f9dc
5
5
  SHA512:
6
- metadata.gz: f53b4203570a36a3e339be81521dc97827837b80f6b749e2ed6a91b217effd2f69d4b69cc462dc763d112f5b92e34cfe41ec44989a4570a30f8f985edea25ac0
7
- data.tar.gz: b3c1cb8ee19a768fe74519140f5d209a40a1e17f5b474628567c25fe7d95cb50070a94f3926e212a8bb08adbfbcd9e1f4a86eccd5a7271981fdd9503d25ff396
6
+ metadata.gz: 2cf2c64ce51787a3613c57a37c090166e22d26b23cf832e00ac1a087469f8eb77beb18a60f85665cd1b50222161a860b7de89383a8ac349667f833f0968922a0
7
+ data.tar.gz: 6be32da1ee94b9c02ad0be8156daceda13a775482d8f51a30150652b6e2b41d70cc4cb88169e00da3a519efd75fb25c342713b7a43376cd210d907beaaec310e
@@ -12,7 +12,7 @@ jobs:
12
12
  strategy:
13
13
  fail-fast: false
14
14
  matrix:
15
- ruby-version: ['3.3', '3.2', '3.1', '3.0', '2.7', '2.6']
15
+ ruby-version: ['3.4', '3.3', '3.2', '3.1', '3.0', '2.7', '2.6']
16
16
  steps:
17
17
  - uses: actions/checkout@v3
18
18
  - name: Set up Ruby ${{ matrix.ruby-version }}
@@ -27,4 +27,4 @@ jobs:
27
27
  bundle install
28
28
  - name: Run tests
29
29
  run: |
30
- bundle exec rspec spec
30
+ bundle exec rake test
data/README.md CHANGED
@@ -1,4 +1,4 @@
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)
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
3
  ![Dbg base](https://github.com/pawurb/dbg-rb/raw/main/dbg_base.png)
4
4
 
@@ -16,10 +16,9 @@ too many times already.
16
16
 
17
17
  ## Installation
18
18
 
19
- `Gemfile`
20
- ```ruby
21
- gem "dbg-rb"
22
- ```
19
+ `bundle add dbg-rb`
20
+
21
+ Alternatively, you can use an inline version of `dbg-rb` without adding it to the Gemfile. Check out [this post](https://pawelurbanek.com/rails-puts-debug#inline-setup) for info on how to do it.
23
22
 
24
23
  ## Usage
25
24
 
@@ -98,14 +97,6 @@ DbgRb.highlight!("πŸŽ‰πŸ’”πŸ’£πŸ•ΊπŸš€πŸ§¨πŸ™ˆπŸ€―πŸ₯³πŸŒˆπŸ¦„")
98
97
 
99
98
  ![Dbg emoji](https://github.com/pawurb/dbg-rb/raw/main/dbg_emoji.png)
100
99
 
101
- You can also use `DbgRb.dbg!(*msgs)` directly or wrap it to rename the helper method:
102
-
103
- ```ruby
104
- def dd(*msgs)
105
- DbgRb.dbg!(*msgs)
106
- end
107
- ```
108
-
109
100
  ## Status
110
101
 
111
102
  Contributions & ideas very welcome!
data/Rakefile CHANGED
@@ -7,5 +7,6 @@ desc "Run tests"
7
7
  task :default => :test
8
8
 
9
9
  task :test do
10
- system("bundle exec rspec spec")
10
+ system("bundle exec rspec spec/gem_spec.rb")
11
+ system("bundle exec rspec spec/inline_spec.rb")
11
12
  end
data/dbg-rb.gemspec CHANGED
@@ -8,14 +8,14 @@ Gem::Specification.new do |s|
8
8
  s.version = DbgRb::VERSION
9
9
  s.authors = ["pawurb"]
10
10
  s.email = ["contact@pawelurbanek.com"]
11
- s.summary = "Simple debuging helper"
11
+ s.summary = "Simple debugging helper"
12
12
  s.description = "Rust-inspired, puts debugging helper, adding caller info and optional coloring."
13
13
  s.homepage = "http://github.com/pawurb/dbg-rb"
14
14
  s.files = `git ls-files`.split("\n").reject { |f| f.match?(/\.db$/) }
15
15
  s.require_paths = ["lib"]
16
16
  s.license = "MIT"
17
- s.add_dependency "binding_of_caller"
18
17
  s.add_dependency "json"
18
+ s.add_development_dependency "ostruct"
19
19
  s.add_development_dependency "rake"
20
20
  s.add_development_dependency "rspec"
21
21
  s.add_development_dependency "rufo"
data/inline/dbg_rb.rb ADDED
@@ -0,0 +1,145 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Source https://github.com/pawurb/dbg-rb
4
+ # The MIT License (MIT)
5
+
6
+ # Copyright Β© PaweΕ‚ Urbanek 2024
7
+
8
+ # Permission is hereby granted, free of charge, to any person obtaining
9
+ # a copy of this software and associated documentation files (the
10
+ # "Software"), to deal in the Software without restriction, including
11
+ # without limitation the rights to use, copy, modify, merge, publish,
12
+ # distribute, sublicense, and/or sell copies of the Software, and to
13
+ # permit persons to whom the Software is furnished to do so, subject to
14
+ # the following conditions:
15
+
16
+ # The above copyright notice and this permission notice shall be
17
+ # included in all copies or substantial portions of the Software.
18
+
19
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ require "json"
28
+
29
+ module DbgRb
30
+ def self.color_code=(val)
31
+ Impl.color_code = val
32
+ end
33
+
34
+ def self.highlight!(wrapper = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
35
+ Impl.highlight!(wrapper)
36
+ end
37
+
38
+ def self.dbg(*msgs)
39
+ Impl.new.dbg(*msgs)
40
+ end
41
+
42
+ class Impl
43
+ @@color_code = nil
44
+ @@highlight = false
45
+
46
+ def self.color_code=(val)
47
+ @@color_code = val
48
+ end
49
+
50
+ def self.highlight!(wrapper)
51
+ @@highlight = wrapper
52
+ end
53
+
54
+ def dbg(value)
55
+ loc = caller_locations.first(3).last
56
+ source_file = if (path = loc.absolute_path)
57
+ path.split("/").last(2).join("/")
58
+ else
59
+ loc.label
60
+ end
61
+
62
+ file = loc.absolute_path.split(":").first
63
+
64
+ input = nil
65
+
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
71
+ end
72
+ end
73
+ end
74
+
75
+ if input.nil?
76
+ raise "It should never happen!"
77
+ end
78
+
79
+ line = loc.lineno
80
+ src = "[#{source_file}:#{line}]"
81
+ value = format_val(value)
82
+
83
+ val = if input.to_s == value.to_s
84
+ "#{value}"
85
+ else
86
+ "#{input} = #{value}"
87
+ end
88
+ output = "#{src} #{val}"
89
+
90
+ if @@highlight
91
+ output = "#{@@highlight}\n#{output}\n#{@@highlight}"
92
+ end
93
+
94
+ if @@color_code != nil
95
+ output = colorize(output, @@color_code)
96
+ end
97
+
98
+ puts output
99
+ end
100
+
101
+ private
102
+
103
+ def colorize(str, color_code)
104
+ "\e[#{color_code}m#{str}\e[0m"
105
+ end
106
+
107
+ def format_val(val)
108
+ if val.is_a?(Hash)
109
+ res = val.map { |k, v| [k, dbg_inspect(v, quote_str: false)] }.to_h
110
+ JSON.pretty_generate(res)
111
+ elsif val.is_a?(Array)
112
+ JSON.pretty_generate(val.map do |v|
113
+ dbg_inspect(v, quote_str: false)
114
+ end)
115
+ else
116
+ dbg_inspect(val, quote_str: true)
117
+ end.then do |value|
118
+ if value.is_a?(String)
119
+ value.gsub("\"nil\"", "nil")
120
+ else
121
+ value
122
+ end
123
+ end
124
+ end
125
+
126
+ def dbg_inspect(obj, quote_str:)
127
+ if quote_str && obj.is_a?(String)
128
+ return obj.inspect
129
+ end
130
+
131
+ case obj
132
+ when Numeric, String
133
+ obj
134
+ else
135
+ obj.inspect
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ def dbg(value)
142
+ DbgRb.dbg(value)
143
+ end
144
+
145
+ DbgRb.color_code = 33 # yellow
data/lib/dbg-rb.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "binding_of_caller"
4
3
  require "json"
5
4
 
6
5
  module DbgRb
@@ -12,8 +11,8 @@ module DbgRb
12
11
  Impl.highlight!(wrapper)
13
12
  end
14
13
 
15
- def self.dbg!(*msgs)
16
- Impl.new.dbg!(*msgs)
14
+ def self.dbg(*msgs)
15
+ Impl.new.dbg(*msgs)
17
16
  end
18
17
 
19
18
  class Impl
@@ -28,55 +27,51 @@ module DbgRb
28
27
  @@highlight = wrapper
29
28
  end
30
29
 
31
- def dbg!(*msgs)
32
- loc = caller_locations.first(3).last.to_s
33
- matching_loc = loc.match(/.+(rb)\:\d+\:(in)\s/)
34
- src = if !matching_loc.nil?
35
- matching_loc[0][0..-5]
30
+ def dbg(value)
31
+ loc = caller_locations.first(3).last
32
+ source_file = if (path = loc.absolute_path)
33
+ path.split("/").last(2).join("/")
36
34
  else
37
- loc
35
+ loc.label
38
36
  end
39
- file, line = src.split(":")
40
- file = file.split("/").last(2).join("/")
41
- src = "[#{file}:#{line}]"
42
-
43
- msgs.each_with_index do |obj, i|
44
- first = i == 0
45
- last = i == (msgs.size - 1)
46
-
47
- val = if obj.is_a?(Symbol)
48
- begin
49
- val = binding.of_caller(4).local_variable_get(obj)
50
- val = format_val(val)
51
-
52
- "#{obj} = #{val}"
53
- rescue NameError
54
- obj.inspect
55
- end
56
- else
57
- format_val(obj)
58
- end
59
37
 
60
- output = "#{src} #{val}"
38
+ file = loc.absolute_path.split(":").first
61
39
 
62
- if @@highlight
63
- if first
64
- output = "#{@@highlight}\n#{output}"
65
- end
40
+ input = nil
66
41
 
67
- if last
68
- output = "#{output}\n#{@@highlight}"
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
69
47
  end
70
48
  end
49
+ end
50
+
51
+ if input.nil?
52
+ raise "It should never happen!"
53
+ end
54
+
55
+ line = loc.lineno
56
+ src = "[#{source_file}:#{line}]"
57
+ value = format_val(value)
71
58
 
72
- if @@color_code != nil
73
- output = colorize(output, @@color_code)
59
+ val = if input.to_s == value.to_s
60
+ "#{value}"
61
+ else
62
+ "#{input} = #{value}"
74
63
  end
64
+ output = "#{src} #{val}"
65
+
66
+ if @@highlight
67
+ output = "#{@@highlight}\n#{output}\n#{@@highlight}"
68
+ end
75
69
 
76
- puts output
70
+ if @@color_code != nil
71
+ output = colorize(output, @@color_code)
77
72
  end
78
73
 
79
- nil
74
+ puts output
80
75
  end
81
76
 
82
77
  private
@@ -95,6 +90,12 @@ module DbgRb
95
90
  end)
96
91
  else
97
92
  dbg_inspect(val, quote_str: true)
93
+ end.then do |value|
94
+ if value.is_a?(String)
95
+ value.gsub("\"nil\"", "nil")
96
+ else
97
+ value
98
+ end
98
99
  end
99
100
  end
100
101
 
@@ -113,10 +114,8 @@ module DbgRb
113
114
  end
114
115
  end
115
116
 
116
- def dbg!(*msgs)
117
- DbgRb.dbg!(*msgs)
117
+ def dbg(value)
118
+ DbgRb.dbg(value)
118
119
  end
119
120
 
120
121
  DbgRb.color_code = 33 # yellow
121
-
122
- alias dbg dbg!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DbgRb
4
- VERSION = "0.2.7"
4
+ VERSION = "0.3.0"
5
5
  end
data/spec/gem_spec.rb ADDED
@@ -0,0 +1,108 @@
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
@@ -0,0 +1,108 @@
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/inline_spec.rb:14] \"123\"\n").to_stdout
16
+
17
+ expect do
18
+ dbg(123)
19
+ end.to output("[spec/inline_spec.rb:18] 123\n").to_stdout
20
+
21
+ expect do
22
+ dbg(nil)
23
+ end.to output("[spec/inline_spec.rb:22] nil\n").to_stdout
24
+
25
+ expect do
26
+ dbg "123"
27
+ end.to output("[spec/inline_spec.rb:26] \"123\"\n").to_stdout
28
+
29
+ expect do
30
+ dbg 123
31
+ end.to output("[spec/inline_spec.rb:30] 123\n").to_stdout
32
+
33
+ expect do
34
+ dbg nil
35
+ end.to output("[spec/inline_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/inline_spec.rb:42] a = 123\n").to_stdout
44
+
45
+ b = "123"
46
+
47
+ expect do
48
+ dbg(b)
49
+ end.to output("[spec/inline_spec.rb:48] b = \"123\"\n").to_stdout
50
+
51
+ c = nil
52
+
53
+ expect do
54
+ dbg(c)
55
+ end.to output("[spec/inline_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/inline_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/inline_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/inline_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/inline_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/inline_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/inline_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/inline_spec.rb:105] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
107
+ end
108
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbg-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.3.0
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-27 00:00:00.000000000 Z
11
+ date: 2025-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: binding_of_caller
14
+ name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,13 +25,13 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: ostruct
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :runtime
34
+ type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -97,9 +97,11 @@ files:
97
97
  - dbg-rb.gemspec
98
98
  - dbg_base.png
99
99
  - dbg_emoji.png
100
+ - inline/dbg_rb.rb
100
101
  - lib/dbg-rb.rb
101
102
  - lib/dbg_rb/version.rb
102
- - spec/smoke_spec.rb
103
+ - spec/gem_spec.rb
104
+ - spec/inline_spec.rb
103
105
  - spec/spec_helper.rb
104
106
  homepage: http://github.com/pawurb/dbg-rb
105
107
  licenses:
@@ -121,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  - !ruby/object:Gem::Version
122
124
  version: '0'
123
125
  requirements: []
124
- rubygems_version: 3.5.23
126
+ rubygems_version: 3.5.16
125
127
  signing_key:
126
128
  specification_version: 4
127
- summary: Simple debuging helper
129
+ summary: Simple debugging helper
128
130
  test_files: []
data/spec/smoke_spec.rb DELETED
@@ -1,78 +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 "variable values" do
13
- expect { dbg("123") }.to output("[spec/smoke_spec.rb:13] \"123\"\n").to_stdout
14
- end
15
-
16
- it "binded variables" do
17
- b = 123
18
- expect { dbg(:b) }.to output("[spec/smoke_spec.rb:18] b = 123\n").to_stdout
19
- end
20
-
21
- it "missing binded variables" do
22
- b = 123
23
- expect { dbg(:c) }.to output("[spec/smoke_spec.rb:23] :c\n").to_stdout
24
- end
25
-
26
- it "complex objects" do
27
- s = OpenStruct.new(a: 1, b: 2)
28
- expect { dbg!(s) }.to output("[spec/smoke_spec.rb:28] #<OpenStruct a=1, b=2>\n").to_stdout
29
- end
30
-
31
- it "binded complex objects" do
32
- s = OpenStruct.new(a: 1, b: 2)
33
- expect { dbg!(:s) }.to output("[spec/smoke_spec.rb:33] s = #<OpenStruct a=1, b=2>\n").to_stdout
34
- end
35
-
36
- it "multiple msg" do
37
- s = OpenStruct.new(a: 1, b: 2)
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
39
- end
40
-
41
- it "nil" do
42
- expect { dbg!(nil) }.to output("[spec/smoke_spec.rb:42] nil\n").to_stdout
43
- end
44
-
45
- it "higlight" do
46
- DbgRb.highlight!
47
- expect { dbg!("123") }.to output("!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/smoke_spec.rb:47] \"123\"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n").to_stdout
48
- end
49
-
50
- it "color_code" do
51
- DbgRb.color_code = 31
52
- expect { dbg!(123) }.to output("\e[31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n[spec/smoke_spec.rb:52] 123\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m\n").to_stdout
53
- end
54
-
55
- it "alias" do
56
- DbgRb.highlight!(false)
57
- DbgRb.color_code = nil
58
-
59
- expect {
60
- dbg(123)
61
- }.to output("[spec/smoke_spec.rb:60] 123\n").to_stdout
62
- end
63
-
64
- it "binded nil variables" do
65
- b = nil
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
77
- end
78
- end