Sha256: cdc17a815332b4ca00f9060d57e2bac8ccfdbfd816c541a7aba60e163df60279

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

module DtcRake
  module UI
    def error(msg)
      if DtcRake::UI.colorize?
        msg = Rainbow(msg).red
      end
      abort msg
    end
    module_function :error

    def announce(msg)
      if DtcRake::UI.colorize?
        msg = Rainbow(msg).aqua
      end
      puts msg
    end
    module_function :announce

    def success(msg)
      if DtcRake::UI.colorize?
        msg = Rainbow(msg).green
      end
      puts msg
    end
    module_function :success

    def warning(msg)
      if DtcRake::UI.colorize?
        msg = Rainbow(msg).yellow
      end
      puts msg
    end
    module_function :warning

    def info(msg)
      if DtcRake::UI.colorize?
        msg = Rainbow(msg).white
      end
      puts msg
    end
    module_function :info

    def colorize?
      return @colorize if defined? @colorize

      colorize = Config.instance.colorize
      if colorize
        begin
          require "rainbow"
        rescue LoadError
          colorize = false
        end
      end
      @colorize = colorize
    end
    module_function :colorize?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dtc_rake-1.2.1 lib/dtc_rake/ui.rb
dtc_rake-1.2.0 lib/dtc_rake/ui.rb
dtc_rake-1.1.0 lib/dtc_rake/ui.rb
dtc_rake-1.0.0 lib/dtc_rake/ui.rb
dtc_rake-1.0.0.pre.beta.2 lib/dtc_rake/ui.rb
dtc_rake-1.0.0.pre.beta.1 lib/dtc_rake/ui.rb