debug_me 1.0.1 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2f1a9993af0c276f8ee37bf6cef26f6ab11174bb1735a177c45112e6963ef2a3
4
+ data.tar.gz: ad89e6defd63f3b981f98c048c427d7a4d2b62851b848d2f5536f6f60809fa49
5
+ SHA512:
6
+ metadata.gz: df0fda4a35106408648278a8e823b7e9c1666250cd7a0e7a8373166b7ab9bce0c7fff0db6c79a7f06b56d69247eb5317aea227fdc079dbf1c99d9c57d1fe6089
7
+ data.tar.gz: 5a76a8d3e574f983a482498e620c8f9f4dba90ae9a5b815ab5a0133e56c766b112a89242b60b75a03b256a9fe5e597a0e171182e67dc8aec85fd2512faabcc28
data/README.md CHANGED
@@ -1,13 +1,23 @@
1
1
  # DebugMe
2
2
 
3
- This thing is pretty old. There are much better
3
+ A tool to print the labeled value of variables.
4
+
5
+ This thing is pretty old; but, so am I. Even with the gray
6
+ in our hair we still do the job.
7
+
8
+ There are much more complex/comprehensive
4
9
  ways of debugging in a complex application. But,
5
10
  you know, I keep returning to this little method
6
11
  time after time. I guess that marks me as a geezer.
7
12
 
8
- A tool to print the labeled value of variables.
9
13
 
10
- Works with local, instance and class variables.
14
+ DebugMe::debug_me(){} works with local, instance and class variables.
15
+
16
+ ## Recent Changes
17
+
18
+ * 1.0.6 Added support for variable backtrack length via the :levels option
19
+ * 1.0.5 Added support for an instance of a Logger class.
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.
11
21
 
12
22
  ## Installation
13
23
 
@@ -35,6 +45,8 @@ debug_me # Prints only the header banner consisting of tag, method name, file na
35
45
 
36
46
  debug_me('INFO') # Also prints only the header but with a different tag
37
47
 
48
+ debug_me(levels: 5) # Along with the header, show the call stack back this many levels
49
+
38
50
  debug_me {} # prints the default header and __ALL__ variables
39
51
 
40
52
  debug_me {:just_this_variable} # prints the default header and the value of only one specific variable
@@ -45,9 +57,9 @@ debug_me { [:this_one, :that_one, :that_other_one] } # prints default header and
45
57
  # Each element of the array is 'eval'ed with the context binding of the caller
46
58
  debug_me(){[ :my_var, 'my_complex_var_or_method[my_var]' ]}
47
59
 
48
- debug_me(:header => false) {} # disables the printing of the header; prints all variables
60
+ debug_me(header: false) {} # disables the printing of the header; prints all variables
49
61
 
50
- debug_me(:tag => 'MyTag', :header => false) {} # disables header, sets different tag, prints all variables
62
+ debug_me(tag: 'MyTag', :header => false) {} # disables header, sets different tag, prints all variables
51
63
 
52
64
  debug_me('=== LOOK ===') {} # changes the tag and prints all variables with a header line
53
65
 
@@ -55,8 +67,138 @@ debug_me('=== LOOK ===') {:@foo} # changes the tag, prints a header line and a s
55
67
 
56
68
  debug_me('=== LOOK ===') {:@@foo} # changes the tag, prints a header line and a specific class variable
57
69
 
58
- debug_me(:ivar => false, :cvar => false) {} # print only the local variables with the default tag and a header line
70
+ debug_me(ivar: false, cvar: false) {} # print only the local variables with the default tag and a header line
71
+
72
+ ```
73
+
74
+ Most of the examples above use symbols to designate the variables that you want
75
+ to be shown with their name as a label. You can also use strings. With strings
76
+ you are not limited to just variables. Consider these examples:
77
+
78
+ ```ruby
79
+ debug_me {[ 'some_array.size', 'SomeDatabaseModel.count' ]}
80
+
81
+ # What a backtrace with your variables?
82
+
83
+ debug_me {[
84
+ :my_variable,
85
+ 'some_hash.keys.reject{|k| k.to_s.start_with?('A')}',
86
+ 'caller' ]} # yes, caller is a kernel method that will give a backtrace
87
+
88
+ # You can also get into trouble so be careful. The symbols and strings
89
+ # are evaluated in the context of the caller. Within the string any
90
+ # command or line of code can be given. SO DO NOT try to use
91
+ # something silly like debug_me{ 'system("rm -fr /")'}
92
+
93
+ ```
94
+
95
+ ## Default Options
96
+
97
+ The default options is a global constant `DebugMeDefaultOptions` that is outside of the `DebugMe` name space. I did that so that if you do `include DebugMe` to make access to the method easier you could still have the constant with a function specific name that would be outside of anything that you may have already coded in you program.
98
+
99
+ Notice that this constant is outside of the DebugMe's module namespace.
59
100
 
101
+ ```ruby
102
+ DebugMeDefaultOptions = {
103
+ tag: 'DEBUG', # A tag to prepend to each output line
104
+ time: true, # Include a time-stamp in front of the tag
105
+ strftime: '%Y-%m-%d %H:%M:%S.%6N', # timestamp format
106
+ header: true, # Print a header string before printing the variables
107
+ levels: 0, # Number of additional backtrack entries to display
108
+ lvar: true, # Include local variables
109
+ ivar: true, # Include instance variables in the output
110
+ cvar: true, # Include class variables in the output
111
+ cconst: true, # Include class constants
112
+ logger: nil, # Pass in a logger class instance like Rails.logger
113
+ file: $stdout # The output file
114
+ }
115
+ ```
116
+
117
+ If you want the output of the method to always go to STDERR then do this:
118
+
119
+ ```ruby
120
+ require 'debug_me'
121
+ DebugMeDefaultOptions[:file] = $stderr # or STDERR
122
+ ```
123
+ If you want the `debug_me` output to go to a real file:
124
+
125
+ ```ruby
126
+ DebugMeDefaultOptions[:file] = File.open('debug_me.log', 'w')
127
+
128
+ ```
129
+
130
+ ## Using a Logger class instance
131
+
132
+ If you are working in Rails and want all the `debug_me` output to go to the Rails.logger its as easy as:
133
+ ```ruby
134
+ DebugMeDefaultOptions[:logger] = Rails.logger
135
+
136
+ ```
137
+
138
+ Or while working in rails you only want to add a marker to the Rails.logger do this:
139
+ ```ruby
140
+ debug_me(logger: Rails.logger, tag: 'Hello World')
141
+ ```
142
+
143
+ If you are working in Rails and want to use both the standard `debug_me` functions and occassionally put stuff into the Rails.logger but do not want to always remember the option settings then do something line this in a `config/initializers/aaaaa_debug_me.rb` file:
144
+
145
+ ```ruby
146
+ # config/initializers/aaaaa_debug_me.rb
147
+
148
+ require 'debug_me'
149
+
150
+ module DebugMe
151
+ def log_me(message, options={}, &block)
152
+ options = {logger: Rails.logger, time: false, header: false, tag: message}
153
+ block_given? ? debug_me(options, block) : debug_me(options)
154
+ end
155
+ end
156
+
157
+ include DebugMe
158
+
159
+ # Just setup the base name. The parent path will be added below ...
160
+ debug_me_file_name = 'debug_me'
161
+
162
+ # NOTE: you could add a timestamp to the filename
163
+ # debug_me_file_name += '_' + Time.now.strftime('%Y%m%d%H%M%S')
164
+
165
+ debug_me_file_name += '_' + Process.argv0.gsub('/',' ').split(' ').last
166
+ # NOTE: by using the Process.argv0 ... you get multiple log files for
167
+ # rails, rake, sidekiq etc.
168
+
169
+ debug_me_file_name += '.log'
170
+
171
+ debug_me_filepath = Rails.root + 'log' + debug_me_file_name
172
+
173
+ debug_me_file = File.open(debug_me_filepath, 'w')
174
+
175
+ debug_me_file.puts <<~RULER
176
+
177
+ ==================== Starting New Test Run --------->>>>>>
178
+
179
+ RULER
180
+
181
+ # Set application wide options in the DebugMeDefaultOptions hash
182
+ DebugMeDefaultOptions[:file] = debug_me_file
183
+
184
+ debug_me{['ENV']}
185
+
186
+ ```
187
+
188
+ What that does for your Rails application is dump all of your system environment variables and their values to a debug_me log file in the log directory of the application.
189
+
190
+ It also adds a new method `log_me` which you can use to send stuff to the `Rails.logger` instance. The method used by `debug_me` for the `logger` instance is always the `debug` method.
191
+
192
+ ## Conclusion
193
+
194
+ The rest of the default options are obvious.
195
+
196
+ You can always over-ride the default options on a case by case basis like this:
197
+
198
+ ```
199
+ debug_me {...}
200
+ ...
201
+ debug_me(header: false){...}
60
202
  ```
61
203
 
62
204
  ## Contributing
@@ -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.'
@@ -21,6 +21,6 @@ time after time. I guess that marks me as a geezer.'
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.7'
25
- spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'rake'
26
26
  end
@@ -1,56 +1,85 @@
1
1
  require 'pp'
2
2
  require_relative 'debug_me/version'
3
3
 
4
+ DebugMeDefaultOptions = {
5
+ tag: 'DEBUG', # A tag to prepend to each output line
6
+ time: true, # Include a time-stamp in front of the tag
7
+ strftime: '%Y-%m-%d %H:%M:%S.%6N', # timestamp format
8
+ header: true, # Print a header string before printing the variables
9
+ levels: 0, # Number of additional backtrack entries to display
10
+ lvar: true, # Include local variables
11
+ ivar: true, # Include instance variables in the output
12
+ cvar: true, # Include class variables in the output
13
+ cconst: true, # Include class constants
14
+ logger: nil, # Pass in an instance of logger class like Rails.logger
15
+ # must respond_to? :debug
16
+ file: $stdout # The output file
17
+ }
18
+
4
19
  module DebugMe
5
20
  def debug_me(options = {}, &block)
6
- default_options = {
7
- tag: 'DEBUG:', # A tag to prepend to each output line
8
- time: true, # Include a time-stamp in front of the tag
9
- header: true, # Print a header string before printing the variables
10
- ivar: true, # Include instance variables in the output
11
- cvar: true, # Include class variables in the output
12
- file: $stdout # The output file
13
- }
14
21
 
15
22
  if 'Hash' == options.class.to_s
16
- options = default_options.merge(options)
23
+ options = DebugMeDefaultOptions.merge(options)
17
24
  else
18
- options = default_options.merge(tag: options)
25
+ options = DebugMeDefaultOptions.merge(tag: options)
19
26
  end
20
27
 
28
+ out_string = ''
29
+
21
30
  f = options[:file]
31
+ l = options[:logger]
22
32
  s = ''
23
- s += "#{sprintf('%010.6f', Time.now.to_f)} " if options[:time]
24
- s += " #{options[:tag]}"
25
- wf = caller # where_from under 1.8.6 its a stack trace array under 1.8.7 is a string
26
- wf = wf[0] if 'Array' == wf.class.to_s
33
+ s += Time.now.strftime(options[:strftime])+' ' if options[:time]
34
+ s += "#{options[:tag]}"
35
+ bt = caller # where_from under 1.8.6 its a stack trace array under 1.8.7+ as a string
27
36
 
28
- f.puts "#{s} Source: #{wf}" if options[:header]
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
29
47
 
30
48
  if block_given?
31
49
 
32
50
  block_value = [block.call].flatten.compact
33
51
 
34
52
  if block_value.empty?
35
- block_value = eval('local_variables', block.binding)
53
+ block_value = []
54
+ block_value += [eval('local_variables', block.binding)] if options[:lvar]
36
55
  block_value += [eval('instance_variables', block.binding)] if options[:ivar]
37
56
  block_value += [self.class.send('class_variables')] if options[:cvar]
57
+ block_value += [self.class.constants] if options[:cconst]
38
58
  block_value = block_value.flatten.compact
39
- else
40
- block_value.map!(&:to_s)
41
59
  end
42
60
 
61
+ block_value.map!(&:to_s)
62
+
43
63
  block_value.each do |v|
44
- ev = eval(v, block.binding)
45
- f.puts "#{s} #{v} -=> #{ev.pretty_inspect}"
64
+ ev = eval("defined?(#{v})",block.binding).nil? ? '<undefined>' : eval(v, block.binding)
65
+ out_string += sprintf( "%s %s -=> %s", s,v,ev.pretty_inspect)
46
66
  end
47
67
 
48
68
  end ## if block_given?
49
69
 
50
- f.flush
70
+ unless f.nil?
71
+ f.puts out_string
72
+ f.flush
73
+ end
74
+
75
+ unless l.nil?
76
+ l.debug(out_string) if l.respond_to? :debug
77
+ end
78
+
79
+ return out_string
51
80
  end ## def debug_me( options={}, &block )
52
81
 
53
82
  # def log_me(msg, opts={})
54
- # debug_me({:tag => msg, :header => false}.merge(opts))
83
+ # debug_me({tag: msg, header: false}.merge(opts))
55
84
  # end
56
85
  end # module DebugMe
@@ -1,3 +1,8 @@
1
1
  module DebugMe
2
- VERSION = '1.0.1'
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
@@ -0,0 +1,293 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'amazing_print'
4
+ require 'logger'
5
+ require 'pathname'
6
+
7
+ require_relative '../lib/debug_me'
8
+ include DebugMe
9
+
10
+ require_relative './world_view'
11
+
12
+
13
+
14
+ require 'minitest/autorun'
15
+
16
+ describe DebugMe do
17
+
18
+ describe "source header included" do
19
+
20
+ before do
21
+ @line = __LINE__
22
+ @file = __FILE__
23
+ @out_string = debug_me(file:nil)
24
+ end
25
+
26
+ it "has the keywords DEBUG and Source" do
27
+ assert @out_string.include? "DEBUG"
28
+ assert @out_string.include? "Source"
29
+ end
30
+
31
+ it "includes the filename" do
32
+ assert @out_string.include? __FILE__
33
+ end
34
+
35
+ it "includes the line number" do
36
+ assert @out_string.include? ".rb:#{@line+2}:"
37
+ end
38
+
39
+ end # describe "source header included" do
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
+
62
+ describe "source header excluded" do
63
+
64
+ before do
65
+ @out_string = debug_me(file:nil,header:false)
66
+ end
67
+
68
+ it "is empty" do
69
+ assert @out_string.empty?
70
+ end
71
+
72
+ end # describe "source header excluded" do
73
+
74
+ describe "works with local variable" do
75
+
76
+ it "supports a single variable" do
77
+ a,b,c = 1,2,3
78
+ out_string = debug_me(file:nil,header:false){:a}
79
+ assert out_string.include? "a -=> #{a}"
80
+ out_string.split("\n").size.must_equal 1
81
+ end
82
+
83
+ it "supports multible variables" do
84
+ a,b,c = 1,2,3
85
+ out_string = debug_me(file:nil,header:false){[:a, :b, :c]}
86
+ assert out_string.include? "a -=> #{a}"
87
+ assert out_string.include? "b -=> #{b}"
88
+ assert out_string.include? "c -=> #{c}"
89
+ out_string.split("\n").size.must_equal 3
90
+ end
91
+
92
+ it "shows all local variables" do
93
+ a,b,c = 1,2,3
94
+ out_string = debug_me(
95
+ file:nil,
96
+ header:false,
97
+ lvar: true,
98
+ ivar: false,
99
+ cvar: false,
100
+ cconst: false
101
+ ){}
102
+ assert out_string.include? "a -=> #{a}"
103
+ assert out_string.include? "b -=> #{b}"
104
+ assert out_string.include? "c -=> #{c}"
105
+ assert out_string.include? "out_string -=> "
106
+
107
+ out_string.split("\n").size.must_equal 4
108
+ end
109
+
110
+ end # describe "works with local variable" do
111
+
112
+ describe "works with instance variable" do
113
+
114
+ it "supports a single variable" do
115
+ @a,@b,@c = 1,2,3
116
+ out_string = debug_me(file:nil,header:false){:@a}
117
+ assert out_string.include? "@a -=> #{@a}"
118
+ out_string.split("\n").size.must_equal 1
119
+ end
120
+
121
+ it "supports multible variables" do
122
+ @a,@b,@c = 1,2,3
123
+ out_string = debug_me(file:nil,header:false){[:@a, :@b, :@c]}
124
+ assert out_string.include? "@a -=> #{@a}"
125
+ assert out_string.include? "@b -=> #{@b}"
126
+ assert out_string.include? "@c -=> #{@c}"
127
+ out_string.split("\n").size.must_equal 3
128
+ end
129
+
130
+ it "shows all instance variables" do
131
+ @a,@b,@c = 1,2,3
132
+ out_string = debug_me(
133
+ file:nil,
134
+ header:false,
135
+ lvar: false,
136
+ ivar: true,
137
+ cvar: false,
138
+ cconst: false
139
+ ){}
140
+ assert out_string.include? "@a -=> #{@a}"
141
+ assert out_string.include? "@b -=> #{@b}"
142
+ assert out_string.include? "@c -=> #{@c}"
143
+
144
+ out_string.include?("out_string -=> ").must_equal false
145
+ out_string.split("\n").size.must_equal instance_variables.size
146
+ end
147
+
148
+ end # describe "works with instance variable" do
149
+
150
+
151
+ describe "works with class variable" do
152
+
153
+ it "supports a single variable" do
154
+ @@a,@@b,@@c = 1,2,3
155
+ out_string = debug_me(file:nil,header:false){:@@a}
156
+ assert out_string.include? "@@a -=> #{@@a}"
157
+ out_string.split("\n").size.must_equal 1
158
+ end
159
+
160
+ it "supports multible variables" do
161
+ @@a,@@b,@@c = 1,2,3
162
+ out_string = debug_me(file:nil,header:false){[:@@a, :@@b, :@@c]}
163
+ assert out_string.include? "@@a -=> #{@@a}"
164
+ assert out_string.include? "@@b -=> #{@@b}"
165
+ assert out_string.include? "@@c -=> #{@@c}"
166
+ out_string.split("\n").size.must_equal 3
167
+ end
168
+
169
+ it "shows all class variables" do
170
+ @@a,@@b,@@c = 1,2,3
171
+ @d = 4
172
+ out_string = debug_me(
173
+ file:nil,
174
+ header:false,
175
+ lvar: false,
176
+ ivar: false,
177
+ cvar: true,
178
+ cconst: false
179
+ ){}
180
+
181
+ assert out_string.include? "@@a -=> #{@@a}"
182
+ assert out_string.include? "@@b -=> #{@@b}"
183
+ assert out_string.include? "@@c -=> #{@@c}"
184
+
185
+ out_string.include?("out_string -=> ").must_equal false
186
+ out_string.include?("@d -=> ").must_equal false
187
+
188
+ out_string.split("\n").size.must_equal self.class.class_variables.size
189
+ end
190
+
191
+ end # describe "works with class variable" do
192
+
193
+
194
+ describe "works with CONSTANTS" do
195
+
196
+ it "supports a single CONSTANT" do
197
+ A,B,C = 1,2,3
198
+ out_string = debug_me(file:nil,header:false){:A}
199
+ assert out_string.include? "A -=> #{A}"
200
+ out_string.split("\n").size.must_equal 1
201
+ end
202
+
203
+ it "supports multible CONSTANTS" do
204
+ A,B,C = 1,2,3
205
+ out_string = debug_me(file:nil,header:false){[:A, :B, :C]}
206
+ assert out_string.include? "A -=> #{A}"
207
+ assert out_string.include? "B -=> #{B}"
208
+ assert out_string.include? "C -=> #{C}"
209
+ out_string.split("\n").size.must_equal 3
210
+ end
211
+
212
+ end # describe "works with CONSTANTS" do
213
+
214
+
215
+ describe "works with class CONSTANTS" do
216
+
217
+ before do
218
+ @my_world_view = WorldView.new
219
+ end
220
+
221
+ it "supports a single class CONSTANT" do
222
+ out_string = debug_me(file:nil,header:false){'WorldView::A'}
223
+ assert out_string.include? "WorldView::A -=> #{WorldView::A}"
224
+ out_string.split("\n").size.must_equal 1
225
+ end
226
+
227
+ it "supports multible class CONSTANTS" do
228
+ out_string = debug_me(file:nil,header:false){[
229
+ 'WorldView::A', 'WorldView::B', 'WorldView::C']}
230
+ assert out_string.include? "WorldView::A -=> #{WorldView::A}"
231
+ assert out_string.include? "WorldView::B -=> #{WorldView::B}"
232
+ assert out_string.include? "WorldView::C -=> #{WorldView::C}"
233
+ out_string.split("\n").size.must_equal 3
234
+ end
235
+
236
+ it "shows all class CONSTANTS" do
237
+ out_string = @my_world_view.my_constants
238
+
239
+ assert out_string.include? "A -=> #{WorldView::A}"
240
+ assert out_string.include? "B -=> #{WorldView::B}"
241
+ assert out_string.include? "C -=> #{WorldView::C}"
242
+ assert out_string.include? 'MY_CONSTANT -=> "Jesus"'
243
+
244
+ out_string.include?("out_string -=> ").must_equal false
245
+ out_string.include?("@d -=> ").must_equal false
246
+
247
+ out_string.split("\n").size.must_equal WorldView.constants.size
248
+ end
249
+
250
+ end # describe "works with class CONSTANTS" do
251
+
252
+ describe "works with a Logger class" do
253
+
254
+ it 'default logger class is nil' do
255
+ DebugMeDefaultOptions[:logger].must_equal nil
256
+ end
257
+
258
+ it 'works with standard ruby Logger class' do
259
+ logger_output_path = Pathname.pwd + 'logger_class_output.txt'
260
+ logger_output_path.exist?.must_equal false
261
+
262
+ logger = Logger.new(logger_output_path)
263
+ logger.level = Logger::DEBUG
264
+
265
+ out_string = debug_me(
266
+ logger: logger, # Use instance of Ruby's Logger
267
+ time: false, # turn off debug_me's timestamp
268
+ file: nil, # don't write to STDOUT the default
269
+ tag: 'Hello World' # say hello
270
+ )
271
+ # Generates an entry like this:
272
+ =begin
273
+ # Logfile created on 2020-04-27 16:16:38 -0500 by logger.rb/v1.4.2
274
+ D, [2020-04-27T16:16:38.580889 #54662] DEBUG -- : Hello World Source: debug_me_test.rb:244:in `block (3 levels) in <main>'
275
+ =end
276
+
277
+ lines = logger_output_path.read.split("\n")
278
+
279
+ lines.size.must_equal 2
280
+
281
+ lines[0].start_with?('# Logfile created on').must_equal true
282
+ lines[1].start_with?('D, [').must_equal true
283
+ lines[1].include?('DEBUG').must_equal true
284
+ lines[1].include?('Hello World').must_equal true
285
+ lines[1].include?('debug_me_test.rb').must_equal true
286
+ lines[1].include?(out_string.chomp).must_equal true
287
+
288
+ logger_output_path.delete
289
+ end
290
+
291
+ end
292
+
293
+ end # describe DebugMe do
@@ -0,0 +1,43 @@
1
+ class WorldView
2
+ MY_CONSTANT = 'Jesus'
3
+ A = 1
4
+ B = 2
5
+ C = 3
6
+
7
+ def initialize
8
+ @a,@b,@c = 1,2,3
9
+ @@d, @@e, @@f = 4,5,6
10
+ end
11
+
12
+ def everything
13
+ debug_me(
14
+ file: nil,
15
+ header: true,
16
+ lvar: true,
17
+ ivar: true,
18
+ cvar: true,
19
+ cconst: true
20
+ ){}
21
+ end
22
+
23
+ def my_constants
24
+ debug_me(
25
+ file:nil,
26
+ header:false,
27
+ lvar: false,
28
+ ivar: false,
29
+ cvar: false,
30
+ cconst: true
31
+ ){}
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
43
+ end # class WorldView
metadata CHANGED
@@ -1,63 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug_me
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dewayne VanHoozer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-18 00:00:00.000000000 Z
11
+ date: 2020-05-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '1.7'
19
+ version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '1.7'
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
- version: '10.0'
33
+ version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
- version: '10.0'
46
- description: ! 'This thing is pretty old. There are much better
47
-
40
+ version: '0'
41
+ description: |-
42
+ This thing is pretty old. There are much better
48
43
  ways of debugging in a complex application. But,
49
-
50
44
  you know, I keep returning to this little method
51
-
52
- time after time. I guess that marks me as a geezer.'
45
+ time after time. I guess that marks me as a geezer.
53
46
  email:
54
47
  - dvanhoozer@gmail.com
55
48
  executables: []
56
49
  extensions: []
57
50
  extra_rdoc_files: []
58
51
  files:
59
- - .gitignore
60
- - .rultor.yml
52
+ - ".gitignore"
53
+ - ".rultor.yml"
61
54
  - Gemfile
62
55
  - LICENSE.txt
63
56
  - README.md
@@ -66,29 +59,29 @@ files:
66
59
  - lib/debug_me.rb
67
60
  - lib/debug_me/version.rb
68
61
  - rubygems.yml.asc
62
+ - tests/debug_me_test.rb
63
+ - tests/world_view.rb
69
64
  homepage: http://github.com/MadBomber/debug_me
70
65
  licenses:
71
66
  - You want it, its yours
67
+ metadata: {}
72
68
  post_install_message:
73
69
  rdoc_options: []
74
70
  require_paths:
75
71
  - lib
76
72
  required_ruby_version: !ruby/object:Gem::Requirement
77
- none: false
78
73
  requirements:
79
- - - ! '>='
74
+ - - ">="
80
75
  - !ruby/object:Gem::Version
81
76
  version: '0'
82
77
  required_rubygems_version: !ruby/object:Gem::Requirement
83
- none: false
84
78
  requirements:
85
- - - ! '>='
79
+ - - ">="
86
80
  - !ruby/object:Gem::Version
87
81
  version: '0'
88
82
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 1.8.23
83
+ rubygems_version: 3.1.3
91
84
  signing_key:
92
- specification_version: 3
85
+ specification_version: 4
93
86
  summary: A tool to print the labeled value of variables.
94
87
  test_files: []