Module: Mina::Helpers::Output

Included in:
Internal, Runner::Pretty, Runner::Printer
Defined in:
lib/mina/helpers/output.rb

Instance Method Summary collapse

Instance Method Details

#color(str, c) ⇒ Object


45
46
47
# File 'lib/mina/helpers/output.rb', line 45

def color(str, c)
  ENV['NO_COLOR'] ? str : "\033[#{c}m#{str}\033[0m"
end

33
34
35
# File 'lib/mina/helpers/output.rb', line 33

def print_command(msg)
  puts "       #{color('$', 36)} #{color(msg, 36)}"
end

21
22
23
# File 'lib/mina/helpers/output.rb', line 21

def print_error(msg)
  puts " #{color('!', 33)}     #{color(msg, 31)}"
end

37
38
39
# File 'lib/mina/helpers/output.rb', line 37

def print_info(msg)
  puts "       #{color(msg, 96)}"
end

4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/mina/helpers/output.rb', line 4

def print_line(line)
  case line
  when /^\-+> (.*?)$/
    print_status Regexp.last_match[1]
  when /^! (.*?)$/
    print_error Regexp.last_match[1]
  when /^\$ (.*?)$/
    print_command Regexp.last_match[1]
  else
    print_stdout line
  end
end

17
18
19
# File 'lib/mina/helpers/output.rb', line 17

def print_status(msg)
  puts "#{color('----->', 32)} #{msg}"
end

25
26
27
28
29
30
31
# File 'lib/mina/helpers/output.rb', line 25

def print_stderr(msg)
  if msg =~ /I, \[/ # fix for asset precompile
    print_stdout msg
  else
    puts "       #{color(msg, 31)}"
  end
end

41
42
43
# File 'lib/mina/helpers/output.rb', line 41

def print_stdout(msg)
  puts "       #{msg}"
end