quick-debug 0.0.4 → 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.
data/README.md CHANGED
@@ -24,7 +24,7 @@ What if you could just do this instead?
24
24
 
25
25
  ```ruby
26
26
  def main
27
- D.bg :in
27
+ D.bg
28
28
  movie_dirs.each do |movie_dir|
29
29
  Find.find(movie_dir) do |fn|
30
30
  if fn.is_movie?
@@ -32,7 +32,7 @@ def main
32
32
  movie = nil
33
33
  if movie_dirs.include? parent_dir or parent_dir.has_another_movie(fn)
34
34
  movie = get_movie fn
35
- D.bg(:in){'movie'}
35
+ D.bg{'movie'}
36
36
  else
37
37
  movie = get_movie(fn, true)
38
38
  end
@@ -67,7 +67,7 @@ Then, from within your code:
67
67
  ```ruby
68
68
  require '/quick-debug'
69
69
  def main
70
- D.bg :in
70
+ D.bg
71
71
  movie_dirs.each do |movie_dir|
72
72
  ....
73
73
  ```
@@ -77,16 +77,10 @@ Usage
77
77
  ```
78
78
  D.bg{'@somevar'}
79
79
  ```
80
- prints `@somevar ~> <contents of @somevar.inspect>` to STDOUT. Any object can be passed in, but it must be surrounded by quotes or be made a symbol.
81
-
82
- ```
83
- D.bg(:in){'@somevar'} or D.bg(:at){'@somevar'}
84
- ```
85
- prints `[<caller filename, method, and line number>] @somevar ~> <contents of @somevar.inspect>` to STDOUT. If the block is omitted, only the caller method and line number will be printed.
80
+ Prints `[<caller filename, method, and line number>] @somevar ~> <contents of @somevar.inspect>` to STDOUT. Any object can be passed in, but it must be surrounded by quotes or be made a symbol. If the block is omitted, only the caller method and line number will be printed.
86
81
 
87
82
  ```
88
83
  D.lg{'@somevar'}
89
- D.lg(:in){'@somevar'} or D.lg(:at){'@somevar'}
90
84
  ```
91
85
  Same as above, but prints to `/tmp/quick-debug.txt` instead. A short timestamp is also printed at the start of each line. To change the output filepath, do
92
86
 
@@ -96,7 +90,6 @@ D.logpath = '</some/path/log.txt>'
96
90
 
97
91
  ```
98
92
  D.str{'@somevar'}
99
- D.str(:in){'@somevar'} or D.str(:at){'@somevar'}
100
93
  ```
101
94
  The above methods just return the deubg output as a string, rather than printing them anywhere. This can be very useful if you need to use your own logging framework, for example: `logger.debug D.str{'@somevar'}`.
102
95
 
@@ -109,4 +102,10 @@ D.enable
109
102
  ```
110
103
  to re-enable them. It accepts the same options.
111
104
 
105
+ ```
106
+ D.bg(:force){'@somevar'}
107
+ D.lg(:force){'@somevar'}
108
+ ```
109
+ The debug methods accept a `:force` argument, which will cause those calls to run even though that output location been disabled.
110
+
112
111
  ### Happy Debugging!! ###
@@ -29,29 +29,26 @@ class D
29
29
  end
30
30
 
31
31
  def self.bg(command = nil, &block)
32
- return if not @@active[:bg]
33
- puts eval_inspect(caller.first, command, &block)
32
+ return if !@@active[:bg] && command != :force
33
+ puts eval_inspect(caller.first, &block)
34
34
  end
35
35
 
36
36
  def self.lg(command = nil, &block)
37
- return if not @@active[:lg]
37
+ return if !@@active[:lg] && command != :force
38
38
  timestamp = Time.now.strftime("%a %H:%M:%S")
39
39
  File.open(@@logpath, 'a+') do |f|
40
- f.puts "[#{timestamp}] #{eval_inspect(caller.first, command, &block)}"
40
+ f.puts "[#{timestamp}] #{eval_inspect(caller.first, &block)}"
41
41
  end
42
42
  end
43
43
 
44
44
  def self.str(command = nil, &block)
45
- eval_inspect(caller.first, command, &block)
45
+ eval_inspect(caller.first, &block)
46
46
  end
47
47
 
48
48
  private
49
49
 
50
- def self.eval_inspect(caller_string, command = nil, &block)
51
- outputs = []
52
- if command && [:in, :at].include?(command.to_sym)
53
- outputs << "[#{strip_filepath caller_string}]"
54
- end
50
+ def self.eval_inspect(caller_string, &block)
51
+ outputs = ["[#{strip_filepath caller_string}]"]
55
52
  if block
56
53
  varname = block.call.to_s
57
54
  outputs << "#{varname} ~> #{PP.pp eval(varname, block), ''}"
@@ -1,3 +1,3 @@
1
1
  class D
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick-debug
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 4
10
- version: 0.0.4
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Suan-Aik Yeo
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-01-05 00:00:00 Z
18
+ date: 2013-01-18 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Debug your Ruby code with just a few keystrokes!