Sha256: daba1c1f8890a1bd3bd3b4a6cdd4bb4c9081a92f60ffb9e61d4c7e84a827d8a9

Contents?: true

Size: 953 Bytes

Versions: 11

Compression:

Stored size: 953 Bytes

Contents

# encoding: utf-8

module Inch
  module CLI
    module TraceHelper
      def debug(msg)
        return unless ENV['DEBUG']
        msg.to_s.lines.each do |line|
          trace edged :dark, line.gsub(/\n$/,'').dark
        end
      end

      # Writes the given +text+ to stdout
      # @param text [String]
      # @return [void]
      def trace(text = "")
        puts text
      end

      def trace_header(text, color, bg_color = nil)
        trace header(text, color, bg_color)
        trace if !use_color?
      end

      private

      def edged(color, msg, edge = "┃ ")
        edge.color(color) + msg
      end

      def header(text, color, bg_color = nil)
        bg_color ||= "intense_#{color}"
        bar = " #{text}".ljust(CLI::COLUMNS-1)
                .on_color(bg_color).color(:color16)
        "#".color(color).on_color(color) + bar
      end

      def use_color?
        Term::ANSIColor::coloring?
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
inch-0.3.0 lib/inch/cli/trace_helper.rb
inch-0.3.0.rc3 lib/inch/cli/trace_helper.rb
inch-0.3.0.rc2 lib/inch/cli/trace_helper.rb
inch-0.3.0.rc1 lib/inch/cli/trace_helper.rb
inch-0.2.3 lib/inch/cli/trace_helper.rb
inch-0.2.2 lib/inch/cli/trace_helper.rb
inch-0.2.1 lib/inch/cli/trace_helper.rb
inch-0.2.0 lib/inch/cli/trace_helper.rb
inch-0.1.4 lib/inch/cli/trace_helper.rb
inch-0.1.3 lib/inch/cli/trace_helper.rb
inch-0.1.2 lib/inch/cli/trace_helper.rb