Sha256: bd5a8b5846e265c6dc9d317ee61d36c40632c56b044b6171c3c3c9111c47ad1f

Contents?: true

Size: 793 Bytes

Versions: 6

Compression:

Stored size: 793 Bytes

Contents

module GitBundle
  module Console
    COLORS = {error: 31,
              attention: 32,
              prompt: 33,
              heading: 34}

    def puts_repo_heading(repo)
      puts colorize("\n=== #{repo.name} (#{repo.branch})", COLORS[:heading], true)
    end

    def puts_heading(text)
      puts colorize("\n=== #{text}", COLORS[:heading])
    end

    def puts_attention(text)
      puts colorize(text, COLORS[:attention])
    end

    def puts_prompt(text)
      puts colorize(text, COLORS[:prompt])
    end

    def puts_error(text)
      puts colorize(text, COLORS[:error])
    end

    private
    def colorize(text, color_code, bold = false)
      if bold
        "\e[1m\e[#{color_code}m#{text}\e[0m"
      else
        "\e[#{color_code}m#{text}\e[0m"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git-bundle-1.0.7 lib/git_bundle/console.rb
git-bundle-1.0.6 lib/git_bundle/console.rb
git-bundle-1.0.5 lib/git_bundle/console.rb
git-bundle-1.0.4 lib/git_bundle/console.rb
git-bundle-1.0.3 lib/git_bundle/console.rb
git-bundle-1.0.2 lib/git_bundle/console.rb