Sha256: b2e6c72ed3c7cc6dc6ef24b745c551d672add0467c491bafb431bd5e9f3289fb

Contents?: true

Size: 875 Bytes

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
rubycritic-2.9.2 lib/rubycritic/generators/text/list.rb
rubycritic-2.9.1 lib/rubycritic/generators/text/list.rb
rubycritic-2.9.0 lib/rubycritic/generators/text/list.rb
rubycritic-2.8.0 lib/rubycritic/generators/text/list.rb
rubycritic-2.7.1 lib/rubycritic/generators/text/list.rb
rubycritic-2.7.0 lib/rubycritic/generators/text/list.rb