debug_me 1.0.6 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.envrc +9 -0
- data/README.md +7 -0
- data/lib/debug_me/version.rb +2 -2
- data/lib/debug_me.rb +27 -9
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 406de0bd607687bab5c7a46e6dfde187353c24dfaf0800e2b5c0cd9223a8faf8
|
4
|
+
data.tar.gz: f3f85a306a6455e2e699558a41e7d78b7eded223f862ce34c8ee02e3f487a268
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ae3bf7696135d7d42ee5c0894a0d8d57b1ee2e93ce1236622b17f882ceaa67b9b0ac8769a2be01dd3291947363d5323c04138e2c5fdf141d0f1efcc20aa3b4c
|
7
|
+
data.tar.gz: 3d756257d84c6e72edaf7debfb6d7100fa8a7f43a81254cbcdbdf204cf8ff118c163a7136a92be076b017b2cd411fc1075f596e140a361036c41f0ed88e2e505
|
data/.envrc
ADDED
data/README.md
CHANGED
@@ -15,6 +15,8 @@ DebugMe::debug_me(){} works with local, instance and class variables.
|
|
15
15
|
|
16
16
|
## Recent Changes
|
17
17
|
|
18
|
+
* 1.1.1 Added global constant $DEBUG_ME as a boolean; default is true. when false the debug_me method does nothing.
|
19
|
+
* 1.1.0 Changes the output formatting w/r/t the use of levels option; add :backtrace option for full backtrace
|
18
20
|
* 1.0.6 Added support for variable backtrack length via the :levels option
|
19
21
|
* 1.0.5 Added support for an instance of a Logger class.
|
20
22
|
* 1.0.4 Added :strftime to the options; changed the default format from decimal seconds since epic to something that is more easy comprehend on a clock.
|
@@ -46,6 +48,9 @@ debug_me # Prints only the header banner consisting of tag, method name, file na
|
|
46
48
|
debug_me('INFO') # Also prints only the header but with a different tag
|
47
49
|
|
48
50
|
debug_me(levels: 5) # Along with the header, show the call stack back this many levels
|
51
|
+
debug_me{:backtrace} # show the entire call stack
|
52
|
+
debug_me{[ :backtrace ]} will # show the entire call stack
|
53
|
+
debug_me(levels: 5){[ :backtrace ]} # will only show the first 5 levels of the backtrace - ie. the levels parameter supersedes :backtrace
|
49
54
|
|
50
55
|
debug_me {} # prints the default header and __ALL__ variables
|
51
56
|
|
@@ -105,6 +110,8 @@ DebugMeDefaultOptions = {
|
|
105
110
|
strftime: '%Y-%m-%d %H:%M:%S.%6N', # timestamp format
|
106
111
|
header: true, # Print a header string before printing the variables
|
107
112
|
levels: 0, # Number of additional backtrack entries to display
|
113
|
+
skip1: false, # skip 1 blank line in front of a new output block
|
114
|
+
skip2: false, # skip 2 blank lines in front of a new output block
|
108
115
|
lvar: true, # Include local variables
|
109
116
|
ivar: true, # Include instance variables in the output
|
110
117
|
cvar: true, # Include class variables in the output
|
data/lib/debug_me/version.rb
CHANGED
@@ -2,7 +2,7 @@ module DebugMe
|
|
2
2
|
# I know. Its weird to duplicate the name space; but,
|
3
3
|
# doing this allows you to include DebugMe in your code
|
4
4
|
# to get direct access to the debug_me method without
|
5
|
-
#
|
5
|
+
# polluting your code with an object name that is so
|
6
6
|
# common.
|
7
|
-
DEBUG_ME_VERSION = '1.
|
7
|
+
DEBUG_ME_VERSION = '1.1.1'
|
8
8
|
end
|
data/lib/debug_me.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'pp'
|
2
2
|
require_relative 'debug_me/version'
|
3
3
|
|
4
|
+
$DEBUG_ME = true
|
5
|
+
|
4
6
|
DebugMeDefaultOptions = {
|
5
7
|
tag: 'DEBUG', # A tag to prepend to each output line
|
6
8
|
time: true, # Include a time-stamp in front of the tag
|
7
9
|
strftime: '%Y-%m-%d %H:%M:%S.%6N', # timestamp format
|
8
10
|
header: true, # Print a header string before printing the variables
|
9
11
|
levels: 0, # Number of additional backtrack entries to display
|
12
|
+
skip1: false, # skip 1 lines between different outputs
|
13
|
+
skip2: false, # skip 2 lines between different outputs
|
10
14
|
lvar: true, # Include local variables
|
11
15
|
ivar: true, # Include instance variables in the output
|
12
16
|
cvar: true, # Include class variables in the output
|
@@ -18,6 +22,7 @@ DebugMeDefaultOptions = {
|
|
18
22
|
|
19
23
|
module DebugMe
|
20
24
|
def debug_me(options = {}, &block)
|
25
|
+
return unless $DEBUG_ME
|
21
26
|
|
22
27
|
if 'Hash' == options.class.to_s
|
23
28
|
options = DebugMeDefaultOptions.merge(options)
|
@@ -25,7 +30,10 @@ module DebugMe
|
|
25
30
|
options = DebugMeDefaultOptions.merge(tag: options)
|
26
31
|
end
|
27
32
|
|
28
|
-
|
33
|
+
skip = ''
|
34
|
+
skip = "\n" if options[:skip1]
|
35
|
+
skip = "\n\n" if options[:skip2]
|
36
|
+
out_string = ''
|
29
37
|
|
30
38
|
f = options[:file]
|
31
39
|
l = options[:logger]
|
@@ -33,24 +41,29 @@ module DebugMe
|
|
33
41
|
s += Time.now.strftime(options[:strftime])+' ' if options[:time]
|
34
42
|
s += "#{options[:tag]}"
|
35
43
|
bt = caller # where_from under 1.8.6 its a stack trace array under 1.8.7+ as a string
|
44
|
+
bt_out = []
|
36
45
|
|
37
46
|
if options[:header]
|
38
47
|
cf = bt.is_a?(Array) ? bt[0] : bt
|
39
|
-
out_string = sprintf("%s Source: %s\n", s, cf)
|
48
|
+
out_string = sprintf("%s Source: %s\n", skip+s, cf)
|
40
49
|
if options[:levels] > 0
|
41
50
|
levels = options[:levels].to_i
|
42
|
-
bt[1..levels].each_with_index do |cff, level|
|
43
|
-
|
51
|
+
bt[1..levels].each_with_index do |cff, level |
|
52
|
+
bt_out << [level, cff]
|
44
53
|
end
|
45
54
|
end
|
46
55
|
end
|
47
56
|
|
48
|
-
if block_given?
|
49
|
-
|
50
|
-
block_value
|
57
|
+
if block_given? || bt_out.size > 0
|
58
|
+
block_value = []
|
59
|
+
block_value << 'backtrace' if bt_out.size > 0
|
60
|
+
if block_given?
|
61
|
+
[block.call].flatten.compact.each do |v|
|
62
|
+
block_value << v
|
63
|
+
end
|
64
|
+
end
|
51
65
|
|
52
66
|
if block_value.empty?
|
53
|
-
block_value = []
|
54
67
|
block_value += [eval('local_variables', block.binding)] if options[:lvar]
|
55
68
|
block_value += [eval('instance_variables', block.binding)] if options[:ivar]
|
56
69
|
block_value += [self.class.send('class_variables')] if options[:cvar]
|
@@ -61,7 +74,12 @@ module DebugMe
|
|
61
74
|
block_value.map!(&:to_s)
|
62
75
|
|
63
76
|
block_value.each do |v|
|
64
|
-
|
77
|
+
|
78
|
+
ev = if 'backtrace' == v
|
79
|
+
bt_out.size > 0 ? bt_out : bt[1..10000]
|
80
|
+
else
|
81
|
+
eval("defined?(#{v})",block.binding).nil? ? '<undefined>' : eval(v, block.binding)
|
82
|
+
end
|
65
83
|
out_string += sprintf( "%s %s -=> %s", s,v,ev.pretty_inspect)
|
66
84
|
end
|
67
85
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dewayne VanHoozer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -49,6 +49,7 @@ executables: []
|
|
49
49
|
extensions: []
|
50
50
|
extra_rdoc_files: []
|
51
51
|
files:
|
52
|
+
- ".envrc"
|
52
53
|
- ".gitignore"
|
53
54
|
- ".rultor.yml"
|
54
55
|
- Gemfile
|
@@ -65,7 +66,7 @@ homepage: http://github.com/MadBomber/debug_me
|
|
65
66
|
licenses:
|
66
67
|
- You want it, its yours
|
67
68
|
metadata: {}
|
68
|
-
post_install_message:
|
69
|
+
post_install_message:
|
69
70
|
rdoc_options: []
|
70
71
|
require_paths:
|
71
72
|
- lib
|
@@ -80,8 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
- !ruby/object:Gem::Version
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
84
|
-
signing_key:
|
84
|
+
rubygems_version: 3.4.21
|
85
|
+
signing_key:
|
85
86
|
specification_version: 4
|
86
87
|
summary: A tool to print the labeled value of variables.
|
87
88
|
test_files: []
|