debug_me 1.0.5 → 1.0.6

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: b12a0c426af49f51958f84424b8bd2160f1b3a139d75b7c83a8b7021adb8788d
4
- data.tar.gz: 4c7b31bbddfa1a029410413c3847ec31ac678fe004a0e53d263457f4c822c1de
3
+ metadata.gz: 2f1a9993af0c276f8ee37bf6cef26f6ab11174bb1735a177c45112e6963ef2a3
4
+ data.tar.gz: ad89e6defd63f3b981f98c048c427d7a4d2b62851b848d2f5536f6f60809fa49
5
5
  SHA512:
6
- metadata.gz: ac86537e986b53194dce7d08605aaef788d5a48849f205e80b82ca27cb6af01793952b93b305dad2e0a8ea7f37b75d153de2cba7630d0d41ce6424e1e9d08133
7
- data.tar.gz: 3dbcce464705ce68215d50e9e28b6c56a38e94b869edb7340b7ce648c3acced7db2ccf40b50ad83df8d75812e0c6d046725cdecd0537f8e64ad78651c4e6047e
6
+ metadata.gz: df0fda4a35106408648278a8e823b7e9c1666250cd7a0e7a8373166b7ab9bce0c7fff0db6c79a7f06b56d69247eb5317aea227fdc079dbf1c99d9c57d1fe6089
7
+ data.tar.gz: 5a76a8d3e574f983a482498e620c8f9f4dba90ae9a5b815ab5a0133e56c766b112a89242b60b75a03b256a9fe5e597a0e171182e67dc8aec85fd2512faabcc28
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.0.6 Added support for variable backtrack length via the :levels option
18
19
  * 1.0.5 Added support for an instance of a Logger class.
19
20
  * 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.
20
21
 
@@ -44,6 +45,8 @@ debug_me # Prints only the header banner consisting of tag, method name, file na
44
45
 
45
46
  debug_me('INFO') # Also prints only the header but with a different tag
46
47
 
48
+ debug_me(levels: 5) # Along with the header, show the call stack back this many levels
49
+
47
50
  debug_me {} # prints the default header and __ALL__ variables
48
51
 
49
52
  debug_me {:just_this_variable} # prints the default header and the value of only one specific variable
@@ -101,6 +104,7 @@ DebugMeDefaultOptions = {
101
104
  time: true, # Include a time-stamp in front of the tag
102
105
  strftime: '%Y-%m-%d %H:%M:%S.%6N', # timestamp format
103
106
  header: true, # Print a header string before printing the variables
107
+ levels: 0, # Number of additional backtrack entries to display
104
108
  lvar: true, # Include local variables
105
109
  ivar: true, # Include instance variables in the output
106
110
  cvar: true, # Include class variables in the output
@@ -5,7 +5,7 @@ require 'debug_me/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'debug_me'
8
- spec.version = DebugMe::VERSION
8
+ spec.version = DebugMe::DEBUG_ME_VERSION
9
9
  spec.authors = ['Dewayne VanHoozer']
10
10
  spec.email = ['dvanhoozer@gmail.com']
11
11
  spec.summary = 'A tool to print the labeled value of variables.'
@@ -6,6 +6,7 @@ DebugMeDefaultOptions = {
6
6
  time: true, # Include a time-stamp in front of the tag
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
+ levels: 0, # Number of additional backtrack entries to display
9
10
  lvar: true, # Include local variables
10
11
  ivar: true, # Include instance variables in the output
11
12
  cvar: true, # Include class variables in the output
@@ -31,10 +32,18 @@ module DebugMe
31
32
  s = ''
32
33
  s += Time.now.strftime(options[:strftime])+' ' if options[:time]
33
34
  s += "#{options[:tag]}"
34
- wf = caller # where_from under 1.8.6 its a stack trace array under 1.8.7 is a string
35
- wf = wf[0] if 'Array' == wf.class.to_s
36
-
37
- out_string = sprintf("%s Source: %s\n",s,wf) if options[:header]
35
+ bt = caller # where_from under 1.8.6 its a stack trace array under 1.8.7+ as a string
36
+
37
+ if options[:header]
38
+ cf = bt.is_a?(Array) ? bt[0] : bt
39
+ out_string = sprintf("%s Source: %s\n", s, cf)
40
+ if options[:levels] > 0
41
+ 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)
44
+ end
45
+ end
46
+ end
38
47
 
39
48
  if block_given?
40
49
 
@@ -1,3 +1,8 @@
1
1
  module DebugMe
2
- VERSION = '1.0.5'
2
+ # I know. Its weird to duplicate the name space; but,
3
+ # doing this allows you to include DebugMe in your code
4
+ # to get direct access to the debug_me method without
5
+ # poluting your code with an object name that is so
6
+ # common.
7
+ DEBUG_ME_VERSION = '1.0.6'
3
8
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'awesome_print'
3
+ require 'amazing_print'
4
4
  require 'logger'
5
5
  require 'pathname'
6
6
 
@@ -38,6 +38,27 @@ describe DebugMe do
38
38
 
39
39
  end # describe "source header included" do
40
40
 
41
+
42
+
43
+ describe "Add more from the call stack" do
44
+
45
+ before do
46
+ @my_world_view = WorldView.new
47
+ end
48
+
49
+ it 'supports multiple levels from the call stack' do
50
+ result = @my_world_view.one
51
+ # debug_me returns everything as one big long string
52
+ # with embedded new lines. In the WorldView class
53
+ # method six is called from five, which is called from four, three, two, one.
54
+ # The ":levels" options is set to 5 so expect the
55
+ # normal source header followed by 5 additional
56
+ # entries from the call stack.
57
+ assert_equal(result.split("\n").size, 6)
58
+ end
59
+ end
60
+
61
+
41
62
  describe "source header excluded" do
42
63
 
43
64
  before do
@@ -30,4 +30,14 @@ class WorldView
30
30
  cconst: true
31
31
  ){}
32
32
  end
33
+
34
+ def one; two; end
35
+ def two; three; end
36
+ def three; four; end
37
+ def four; five; end
38
+ def five; six; end
39
+
40
+ def six
41
+ debug_me(tag:'How did I get here?', levels: 5)
42
+ end
33
43
  end # class WorldView
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.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,7 @@ 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.2
83
+ rubygems_version: 3.1.3
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: A tool to print the labeled value of variables.