Sha256: 1c08451d510cb4c656e90882b5e9c5ec988e5c9328f6e23b7d438b48fc3eb956

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

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)
        if msg =~ /I, \[/ # fix for asset precompile
          print_stdout msg
        else
          puts "       #{color(msg, 31)}"
        end
      end

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mina-1.2.5 lib/mina/helpers/output.rb