Sha256: e738da86420024cc212036a0c3c016075b3756534f80ded9fb602370f00b6741

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

module Wordmove
  class Logger < ::Logger
    MAX_LINE = 70

    def task(title)
      prefix = "▬" * 2
      title = " #{title} "
      padding = "▬" * padding_length(title)

      puts "\n" + prefix + title.light_white + padding
    end

    def task_step(local_step, title)
      if local_step
        puts "    local".cyan + " | ".black + title.to_s
      else
        puts "   remote".yellow + " | ".black + title.to_s
      end
    end

    def error(message)
      puts "    ✗ error".red + " | ".black + message.to_s
    end

    def success(message)
      puts "    ✓ success".green + " | ".black + message.to_s
    end

    def debug(message)
      puts "    ⚠ debug".magenta + " | ".black + message.to_s
    end

    def warn(message)
      puts "    ⚠ warning".yellow + " | ".black + message.to_s
    end

    private

    def padding_length(line)
      result = MAX_LINE - line.length
      result.positive? ? result : 0
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wordmove-3.0.2 lib/wordmove/logger.rb
wordmove-3.0.1 lib/wordmove/logger.rb
wordmove-3.0.0 lib/wordmove/logger.rb