Sha256: c8800260cc7d0e925f93e60bc8d75c9eedb52300bacda3c02f04406832f03a1a

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

module Megam
  class Dumpout

    attr_reader :stdout
    attr_reader :stderr
    attr_reader :stdin
    
    def initialize(stdout, stderr, stdin)
      @stdout, @stderr, @stdin = stdout, stderr, stdin
    end

    def highline
      @highline ||= begin
      require 'highline'
      HighLine.new
      end
    end

    
    def msg(message)
      stdout.puts message
    end

    # Prints a message to stdout. Aliased as +info+ for compatibility with
    # the logger API.

    def info(message)
      stdout.puts("#{color('INFO:', :green, :bold)} #{message}")
    end

    # Prints a msg to stderr. Used for warn, error, and fatal.
    def err(message)
      stderr.puts message
    end

    # Print a warning message
    def warn(message)
      err("#{color('WARNING:', :yellow, :bold)} #{message}")
    end

    # Print an error message
    def error(message)
      err("#{color('ERROR:', :red, :bold)} #{message}")
    end

    # Print a message describing a fatal error.
    def fatal(message)
      err("#{color('FATAL:', :red, :bold)} #{message}")
    end

    def color(string, *colors)
      if color?
        highline.color(string, *colors)
      else
      string
      end
    end

    # Should colored output be used ?. When output is not to a
    # terminal, colored output is never used
    def color?
      stdout.tty?
    end

    def list(*args)
      highline.list(*args)
    end

    def pretty_print(data)
      stdout.puts data
    end

  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
megam_gogs-0.8.0 lib/megam/gogs/dumpout.rb
megam_gogs-0.7.0 lib/megam/gogs/dumpout.rb
megam_gogs-0.6.0 lib/megam/gogs/dumpout.rb
megam_gogs-0.5.0 lib/megam/gogs/dumpout.rb
megam_gogs-0.4.0 lib/megam/gogs/dumpout.rb
megam_gogs-0.3.0 lib/megam/gogs/dumpout.rb
megam_gogs-0.2.0 lib/megam/gogs/dumpout.rb
megam_gogs-0.1.0 lib/megam/gogs/dumpout.rb
megam_scmmanager-0.1.0 lib/megam/scmmanager/dumpout.rb