Sha256: 2f21aa04b6b0594386a2562fdb8582d8664fce81628cd84e612edcb63c937856

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 Bytes

Contents

module Mina
  module Helpers
    module Output
      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

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

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

      def print_stderr(msg)
        puts "       #{color(msg, 31)}"
      end

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mina-1.0.0.beta2 lib/mina/helpers/output.rb
mina-1.0.0.beta1 lib/mina/helpers/output.rb