debug_me 1.0.6 → 1.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: 2f1a9993af0c276f8ee37bf6cef26f6ab11174bb1735a177c45112e6963ef2a3
4
- data.tar.gz: ad89e6defd63f3b981f98c048c427d7a4d2b62851b848d2f5536f6f60809fa49
3
+ metadata.gz: 03f8c0541fab13dc5ea656fdd5ef697075132bb00a4662345d4d27f3f935bc99
4
+ data.tar.gz: 0d1d53bbedf84a6d9e17fcccb1565eaecd25ff0fa58ce09daeafb7386482999b
5
5
  SHA512:
6
- metadata.gz: df0fda4a35106408648278a8e823b7e9c1666250cd7a0e7a8373166b7ab9bce0c7fff0db6c79a7f06b56d69247eb5317aea227fdc079dbf1c99d9c57d1fe6089
7
- data.tar.gz: 5a76a8d3e574f983a482498e620c8f9f4dba90ae9a5b815ab5a0133e56c766b112a89242b60b75a03b256a9fe5e597a0e171182e67dc8aec85fd2512faabcc28
6
+ metadata.gz: 6531b542b0b28d5dd0d5b0dee66b3e15d316a0ee05b54be0dedfb1a38f7a78e1cf9ba366404dd2a5d8867e5bb35af7add5254b1a58187a5be610b0f750b1ad24
7
+ data.tar.gz: 36df84f99c1ab56ea168a7e693904244cf2b5c46660da6326e0649c5cdf5685190eb01155f1cbee548914babbbe02e9726ef6418de67e490a9a9f75d387c30fd
data/README.md CHANGED
@@ -15,6 +15,7 @@ DebugMe::debug_me(){} works with local, instance and class variables.
15
15
 
16
16
  ## Recent Changes
17
17
 
18
+ * 1.1.0 Changes the output formatting w/r/t the use of levels option; add :backtrace option for full backtrace
18
19
  * 1.0.6 Added support for variable backtrack length via the :levels option
19
20
  * 1.0.5 Added support for an instance of a Logger class.
20
21
  * 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 +47,9 @@ debug_me # Prints only the header banner consisting of tag, method name, file na
46
47
  debug_me('INFO') # Also prints only the header but with a different tag
47
48
 
48
49
  debug_me(levels: 5) # Along with the header, show the call stack back this many levels
50
+ debug_me{:backtrace} # show the entire call stack
51
+ debug_me{[ :backtrace ]} will # show the entire call stack
52
+ debug_me(levels: 5){[ :backtrace ]} # will only show the first 5 levels of the backtrace - ie. the levels parameter supersedes :backtrace
49
53
 
50
54
  debug_me {} # prints the default header and __ALL__ variables
51
55
 
@@ -105,6 +109,8 @@ DebugMeDefaultOptions = {
105
109
  strftime: '%Y-%m-%d %H:%M:%S.%6N', # timestamp format
106
110
  header: true, # Print a header string before printing the variables
107
111
  levels: 0, # Number of additional backtrack entries to display
112
+ skip1: false, # skip 1 blank line in front of a new output block
113
+ skip2: false, # skip 2 blank lines in front of a new output block
108
114
  lvar: true, # Include local variables
109
115
  ivar: true, # Include instance variables in the output
110
116
  cvar: true, # Include class variables in the output
data/lib/debug_me.rb CHANGED
@@ -7,6 +7,8 @@ DebugMeDefaultOptions = {
7
7
  strftime: '%Y-%m-%d %H:%M:%S.%6N', # timestamp format
8
8
  header: true, # Print a header string before printing the variables
9
9
  levels: 0, # Number of additional backtrack entries to display
10
+ skip1: false, # skip 1 lines between different outputs
11
+ skip2: false, # skip 2 lines between different outputs
10
12
  lvar: true, # Include local variables
11
13
  ivar: true, # Include instance variables in the output
12
14
  cvar: true, # Include class variables in the output
@@ -25,7 +27,10 @@ module DebugMe
25
27
  options = DebugMeDefaultOptions.merge(tag: options)
26
28
  end
27
29
 
28
- out_string = ''
30
+ skip = ''
31
+ skip = "\n" if options[:skip1]
32
+ skip = "\n\n" if options[:skip2]
33
+ out_string = ''
29
34
 
30
35
  f = options[:file]
31
36
  l = options[:logger]
@@ -33,24 +38,29 @@ module DebugMe
33
38
  s += Time.now.strftime(options[:strftime])+' ' if options[:time]
34
39
  s += "#{options[:tag]}"
35
40
  bt = caller # where_from under 1.8.6 its a stack trace array under 1.8.7+ as a string
41
+ bt_out = []
36
42
 
37
43
  if options[:header]
38
44
  cf = bt.is_a?(Array) ? bt[0] : bt
39
- out_string = sprintf("%s Source: %s\n", s, cf)
45
+ out_string = sprintf("%s Source: %s\n", skip+s, cf)
40
46
  if options[:levels] > 0
41
47
  levels = options[:levels].to_i
42
- bt[1..levels].each_with_index do |cff, level|
43
- out_string += sprintf("%s Source: FROM (%02d) : %s\n", s, level, cff)
48
+ bt[1..levels].each_with_index do |cff, level |
49
+ bt_out << [level, cff]
44
50
  end
45
51
  end
46
52
  end
47
53
 
48
- if block_given?
49
-
50
- block_value = [block.call].flatten.compact
54
+ if block_given? || bt_out.size > 0
55
+ block_value = []
56
+ block_value << 'backtrace' if bt_out.size > 0
57
+ if block_given?
58
+ [block.call].flatten.compact.each do |v|
59
+ block_value << v
60
+ end
61
+ end
51
62
 
52
63
  if block_value.empty?
53
- block_value = []
54
64
  block_value += [eval('local_variables', block.binding)] if options[:lvar]
55
65
  block_value += [eval('instance_variables', block.binding)] if options[:ivar]
56
66
  block_value += [self.class.send('class_variables')] if options[:cvar]
@@ -61,7 +71,12 @@ module DebugMe
61
71
  block_value.map!(&:to_s)
62
72
 
63
73
  block_value.each do |v|
64
- ev = eval("defined?(#{v})",block.binding).nil? ? '<undefined>' : eval(v, block.binding)
74
+
75
+ ev = if 'backtrace' == v
76
+ bt_out.size > 0 ? bt_out : bt[1..10000]
77
+ else
78
+ eval("defined?(#{v})",block.binding).nil? ? '<undefined>' : eval(v, block.binding)
79
+ end
65
80
  out_string += sprintf( "%s %s -=> %s", s,v,ev.pretty_inspect)
66
81
  end
67
82
 
@@ -4,5 +4,5 @@ module DebugMe
4
4
  # to get direct access to the debug_me method without
5
5
  # poluting your code with an object name that is so
6
6
  # common.
7
- DEBUG_ME_VERSION = '1.0.6'
7
+ DEBUG_ME_VERSION = '1.1.0'
8
8
  end
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.0.6
4
+ version: 1.1.0
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: 2020-05-30 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -65,7 +65,7 @@ homepage: http://github.com/MadBomber/debug_me
65
65
  licenses:
66
66
  - You want it, its yours
67
67
  metadata: {}
68
- post_install_message:
68
+ post_install_message:
69
69
  rdoc_options: []
70
70
  require_paths:
71
71
  - lib
@@ -80,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
- rubygems_version: 3.1.3
84
- signing_key:
83
+ rubygems_version: 3.2.15
84
+ signing_key:
85
85
  specification_version: 4
86
86
  summary: A tool to print the labeled value of variables.
87
87
  test_files: []