Sha256: 92ada6607d7a83afaede693ecadd35f123872ff18ba3bb4fefdeb83a50316e42

Contents?: true

Size: 630 Bytes

Versions: 6

Compression:

Stored size: 630 Bytes

Contents

require "erb"
require "rubycritic/report_generators/base_generator"
require "cgi"

module Rubycritic

  class LineGenerator < BaseGenerator
    NORMAL_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "line.html.erb")))
    SMELLY_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "smelly_line.html.erb")))

    def initialize(text, smells)
      @text = CGI::escapeHTML(text.chomp)
      @smells = smells
      @template =
        if @smells.empty?
          NORMAL_TEMPLATE
        else
          SMELLY_TEMPLATE
        end
    end

    def render
      @template.result(binding).delete("\n") + "\n"
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubycritic-0.0.9 lib/rubycritic/report_generators/line_generator.rb
rubycritic-0.0.8 lib/rubycritic/report_generators/line_generator.rb
rubycritic-0.0.7 lib/rubycritic/report_generators/line_generator.rb
rubycritic-0.0.6 lib/rubycritic/report_generators/line_generator.rb
rubycritic-0.0.5 lib/rubycritic/report_generators/line_generator.rb
rubycritic-0.0.4 lib/rubycritic/report_generators/line_generator.rb