Class: D

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

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

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



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

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
13
14
15
16
# File 'lib/quick-debug.rb', line 9

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

.enable(where) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/quick-debug.rb', line 18

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



36
37
38
39
40
41
42
# File 'lib/quick-debug.rb', line 36

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



27
28
29
# File 'lib/quick-debug.rb', line 27

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

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



44
45
46
# File 'lib/quick-debug.rb', line 44

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