Top Level Namespace

Defined Under Namespace

Modules: DepWalker

Instance Method Summary collapse

Instance Method Details

#green(string) ⇒ Object

Set the terminal’s foreground color to green if colored output is set through options



9
10
11
12
13
14
15
# File 'lib/dep_walker.rb', line 9

def green(string)
  if $options.color
    "\e[1;32m#{string}\e[0m"
  else
    string
  end
end

#red(string) ⇒ Object

Set the terminal’s foreground color to red if colored output is set through options



21
22
23
24
25
26
27
# File 'lib/dep_walker.rb', line 21

def red(string)
  if $options.color
    "\e[1;31m#{string}\e[0m"
  else
    string
  end
end

#trace(message, level = TRACE_INFO) ⇒ Object

Output message colored according to the message level (info - no color, success - green, error - red)



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dep_walker.rb', line 33

def trace(message, level=TRACE_INFO)
  return unless $options.trace
  
  case level
  when DepWalker::TRACE_INFO
    puts message
  when DepWalker::TRACE_SUCCESS
    puts green(message)
  when DepWalker::TRACE_ERROR
    puts red(message)
  end
end