Class: D

Inherits:
Object
  • Object
show all
Defined in:
lib/quick-debug.rb,
lib/quick-debug/version.rb

Constant Summary collapse

VERSION =
"0.0.3"
@@logpath =
'/tmp/quick-debug.txt'
@@active =
{:bg => true, :lg => true}

Class Method Summary collapse

Class Method Details

.bg(command = nil, &block) ⇒ Object



23
24
25
26
# File 'lib/quick-debug.rb', line 23

def self.bg(command = nil, &block)
  return if not @@active[:bg]
  puts eval_inspect(caller.first, command, &block)
end

.disable(where) ⇒ Object



9
10
11
12
# File 'lib/quick-debug.rb', line 9

def self.disable where
  locations = where == :all ? [:bg, :lg] : where
  locations.each{ |location| @@active[location] = false }
end

.enable(where) ⇒ Object



14
15
16
17
# File 'lib/quick-debug.rb', line 14

def self.enable where
  locations = where == :all ? [:bg, :lg] : where
  locations.each{ |location| @@active[location] = true }
end

.lg(command = nil, &block) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/quick-debug.rb', line 28

def self.lg(command = nil, &block)
  return if not @@active[:lg]
  timestamp = Time.now.strftime("%a %H:%M:%S")
  File.open(@@logpath, 'a+') do |f|
    f.puts "[#{timestamp}] #{eval_inspect(caller.first, command, &block)}"
  end
end

.logpath=(path) ⇒ Object



19
20
21
# File 'lib/quick-debug.rb', line 19

def self.logpath= path
  @@logpath = path
end

.str(command = nil, &block) ⇒ Object



36
37
38
# File 'lib/quick-debug.rb', line 36

def self.str(command = nil, &block)
  eval_inspect(caller.first, command, &block)
end