Sha256: 63ae6e4b85a81af2efa5a6c3081344f86f281b5d93c882dcb2ae99b8f3fbe864

Contents?: true

Size: 884 Bytes

Versions: 3

Compression:

Stored size: 884 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'thor'

module Pacto
  module UI
    # Colors for HTTP Methods, intended to match colors of Swagger-UI (as close as possible with ANSI Colors)
    METHOD_COLORS = {
      'POST' => :green,
      'PUT'  => :yellow,
      'DELETE' => :red,
      'GET' => :blue,
      'PATCH' => :yellow,
      'HEAD' => :green
    }

    def self.shell
      @shell ||= Thor::Shell::Color.new
    end

    def self.deprecation(msg)
      $stderr.puts colorize(msg, :yellow) unless Pacto.configuration.hide_deprecations
    end

    def self.colorize(msg, color)
      return msg unless Pacto.configuration.color

      shell.set_color(msg, color)
    end

    def self.colorize_method(method)
      method_string = method.to_s.upcase

      color = METHOD_COLORS[method_string] || :red # red for unknown methods
      colorize(method_string, color)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pacto-0.4.0.rc3 lib/pacto/ui.rb
pacto-0.4.0.rc2 lib/pacto/ui.rb
pacto-0.4.0.rc1 lib/pacto/ui.rb