debuga_helper 0.1.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 +7 -0
- data/README.md +35 -0
- data/lib/debuga_helper/railtie.rb +18 -0
- data/lib/debuga_helper/version.rb +4 -0
- data/lib/debuga_helper.rb +62 -0
- metadata +78 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0f706cf1fcf05a868c9a42909b0942c280d3676a747237e351626e0fc8db5c4b
|
|
4
|
+
data.tar.gz: 3ca976ba6a0a766cf9e1e253541649e37527d1db42a740183408e1b412637990
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: af5eeb7d6f0e36edb0b9551750eafe189d24e70af7e81eaf242ffc1c1a8f058cd845c4a5b357118153c088b36450e11abe46c6f2d9cbfe48d0e04595f1c35c49
|
|
7
|
+
data.tar.gz: e7b10e9d53ddabc0d128d682d0e63bf440d99d50c4de35fe94f0cfa0e6d815833be4a7d2eaf02a234280c182a3b1530ccce6a4b9f022f2298ca174bee80df461
|
data/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# DebugaHelper
|
|
2
|
+
|
|
3
|
+
A Ruby gem providing debugging helpers for Rails applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'debuga_helper'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle install
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Once installed, the helpers are automatically available in your controllers and views.
|
|
20
|
+
|
|
21
|
+
### debuga(msg, title = nil, level = 'debug')
|
|
22
|
+
|
|
23
|
+
Prints a debug message with caller information.
|
|
24
|
+
|
|
25
|
+
- `msg`: The message to print.
|
|
26
|
+
- `title`: Optional title.
|
|
27
|
+
- `level`: Logging level ('debug', 'warning', 'notice', 'all').
|
|
28
|
+
|
|
29
|
+
### debuga_shinny(title = nil, level = 'debug')
|
|
30
|
+
|
|
31
|
+
Prints a shiny title for debugging.
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'debuga_helper'
|
|
2
|
+
require 'rails'
|
|
3
|
+
|
|
4
|
+
module DebugaHelper
|
|
5
|
+
class Railtie < Rails::Railtie
|
|
6
|
+
initializer "debuga_helper.action_controller" do
|
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
|
8
|
+
include DebugHelper
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
initializer "debuga_helper.action_view" do
|
|
13
|
+
ActiveSupport.on_load(:action_view) do
|
|
14
|
+
include DebugHelper
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'debuga_helper/version'
|
|
2
|
+
require 'debuga_helper/railtie' if defined?(Rails)
|
|
3
|
+
|
|
4
|
+
# A helper module for debugging purposes in Rails applications.
|
|
5
|
+
module DebugHelper
|
|
6
|
+
# Prints a debug message with caller information.
|
|
7
|
+
# @param msg [String] The message to print.
|
|
8
|
+
# @param title [String, nil] Optional title for the debug output.
|
|
9
|
+
# @param level [String] The logging level. One of 'debug', 'warning', 'notice', or 'all'. Defaults to 'debug'.
|
|
10
|
+
# @return [void]
|
|
11
|
+
def debuga(msg, title = nil, level = 'debug')
|
|
12
|
+
if(title)
|
|
13
|
+
title = "T: #{"#{title}".bold}"
|
|
14
|
+
else
|
|
15
|
+
title = ''
|
|
16
|
+
end
|
|
17
|
+
caller_msg = "\nš½š½š½\n> Caller: #{caller_locations(1,1)[0].label} :::"
|
|
18
|
+
if title.present?
|
|
19
|
+
caller_msg += "\n#{title}"
|
|
20
|
+
end
|
|
21
|
+
print_it(caller_msg, level)
|
|
22
|
+
print_it("#{msg}\nš¼š¼š¼\n", level)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Prints a shiny title for debugging.
|
|
26
|
+
# @param title [String, nil] The title to display.
|
|
27
|
+
# @param level [String] The logging level. One of 'debug', 'warning', 'notice', or 'all'. Defaults to 'debug'.
|
|
28
|
+
# @return [void]
|
|
29
|
+
def debuga_shinny(title = nil, level = 'debug')
|
|
30
|
+
print_it("*****************************************************", level)
|
|
31
|
+
print_it("*****************************************************", level)
|
|
32
|
+
print_it("********************* #{"#{title}".bold}", level)
|
|
33
|
+
print_it("*****************************************************", level)
|
|
34
|
+
print_it("*****************************************************", level)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
# Private method to handle printing based on level with colorization.
|
|
40
|
+
# @param msg [String] The message to print.
|
|
41
|
+
# @param level [String] The level ('debug', 'warning', 'notice', or 'all').
|
|
42
|
+
# @return [void]
|
|
43
|
+
def print_it(msg, level = 'debug')
|
|
44
|
+
color = case level
|
|
45
|
+
when 'debug' then :blue
|
|
46
|
+
when 'warning' then :yellow
|
|
47
|
+
when 'notice' then :green
|
|
48
|
+
else :white
|
|
49
|
+
end
|
|
50
|
+
colored_msg = msg.colorize(color)
|
|
51
|
+
levels_map = {
|
|
52
|
+
'debug' => :debug,
|
|
53
|
+
'warning' => :warn,
|
|
54
|
+
'notice' => :info
|
|
55
|
+
}
|
|
56
|
+
if levels_map[level]
|
|
57
|
+
Rails.logger.send(levels_map[level], colored_msg)
|
|
58
|
+
elsif level == 'all'
|
|
59
|
+
puts(colored_msg)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: debuga_helper
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- David Lyons Garcia
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-01-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '5.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '5.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: colorize
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0.8'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0.8'
|
|
41
|
+
description: Provides debuga and debuga_shinny methods for logging debug messages
|
|
42
|
+
with caller info and shiny titles.
|
|
43
|
+
email:
|
|
44
|
+
- davidlyonsgarcia@gmail.com
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- README.md
|
|
50
|
+
- lib/debuga_helper.rb
|
|
51
|
+
- lib/debuga_helper/railtie.rb
|
|
52
|
+
- lib/debuga_helper/version.rb
|
|
53
|
+
homepage: https://github.com/EhtuCom/debuga_helper
|
|
54
|
+
licenses:
|
|
55
|
+
- MIT
|
|
56
|
+
metadata:
|
|
57
|
+
homepage_uri: https://github.com/EhtuCom/debuga_helper
|
|
58
|
+
source_code_uri: https://github.com/EhtuCom/debuga_helper
|
|
59
|
+
post_install_message:
|
|
60
|
+
rdoc_options: []
|
|
61
|
+
require_paths:
|
|
62
|
+
- lib
|
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '0'
|
|
73
|
+
requirements: []
|
|
74
|
+
rubygems_version: 3.5.11
|
|
75
|
+
signing_key:
|
|
76
|
+
specification_version: 4
|
|
77
|
+
summary: A helper module for debugging purposes in Rails applications.
|
|
78
|
+
test_files: []
|