Class: D
- Inherits:
-
Object
- Object
- D
- Defined in:
- lib/quick-debug.rb,
lib/quick-debug/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
- @@logpath =
'/tmp/quick-debug.txt'
- @@active =
{:bg => true, :lg => true}
- @@print_separator =
true
Class Method Summary collapse
- .bg(command = nil, &block) ⇒ Object
- .disable(where) ⇒ Object
- .enable(where) ⇒ Object
- .lg(command = nil, &block) ⇒ Object
- .logpath=(path) ⇒ Object
- .str(command = nil, &block) ⇒ Object
Class Method Details
.bg(command = nil, &block) ⇒ Object
32 33 34 35 |
# File 'lib/quick-debug.rb', line 32 def self.bg(command = nil, &block) return if !@@active[:bg] && command != :force puts eval_inspect(caller.first, &block) end |
.disable(where) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/quick-debug.rb', line 10 def self.disable where locations = if where == :all [:bg, :lg] else [where] end locations.each{ |location| @@active[location] = false } end |
.enable(where) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/quick-debug.rb', line 19 def self.enable where locations = if where == :all [:bg, :lg] else [where] end locations.each{ |location| @@active[location] = true } end |
.lg(command = nil, &block) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/quick-debug.rb', line 37 def self.lg(command = nil, &block) return if !@@active[:lg] && command != :force = Time.now.strftime("%a %H:%M:%S") File.open(@@logpath, 'a+') do |f| print_separator_if_needed f f.puts "[#{}] #{eval_inspect(caller[1], &block)}" end end |
.logpath=(path) ⇒ Object
28 29 30 |
# File 'lib/quick-debug.rb', line 28 def self.logpath= path @@logpath = path end |
.str(command = nil, &block) ⇒ Object
46 47 48 |
# File 'lib/quick-debug.rb', line 46 def self.str(command = nil, &block) eval_inspect(caller.first, &block) end |