Sha256: d51e329b5ae2c93f4a79ad087987c1b623246c0549dc41d82e4ec3718bff939b

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

require 'colorize'

module RubyCritic
  module Generator
    module Text
      class List
        class << self
          TEMPLATE_PATH = File.expand_path('../templates/list.erb', __FILE__)

          def erb_template
            @erb_template ||= ERB.new(File.read(TEMPLATE_PATH), nil, '-')
          end
        end

        RATING_TO_COLOR = {
          'A' => :green,
          'B' => :green,
          'C' => :yellow,
          'D' => :light_red,
          'F' => :red
        }.freeze

        def initialize(analysed_module)
          @analysed_module = analysed_module
        end

        def render
          erb_template.result(binding)
        end

        private

        def erb_template
          self.class.erb_template
        end

        def color
          @color ||= RATING_TO_COLOR[@analysed_module.rating.to_s]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubycritic-2.9.3 lib/rubycritic/generators/text/list.rb