Class: CC::Analyzer::Formatters::HTMLFormatter::ReportTemplate

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/cc/analyzer/formatters/html_formatter.rb

Constant Summary collapse

TEMPLATE_PATH =
File.expand_path(File.join(File.dirname(__FILE__), "templates/html.erb"))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issues, filesystem) ⇒ ReportTemplate

Returns a new instance of ReportTemplate.



364
365
366
367
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 364

def initialize(issues, filesystem)
  @issues = issues
  @filesystem = filesystem
end

Instance Attribute Details

#issuesObject (readonly)

Returns the value of attribute issues.



360
361
362
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 360

def issues
  @issues
end

Instance Method Details

#param(str) ⇒ Object



378
379
380
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 378

def param(str)
  str.downcase.gsub(/\s+/, "-")
end

#params(values) ⇒ Object



382
383
384
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 382

def params(values)
  values.map { |c| param c }.join(" ")
end

#project_nameObject



374
375
376
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 374

def project_name
  File.basename(filesystem.root)
end

#renderObject



369
370
371
372
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 369

def render
  template = File.read(TEMPLATE_PATH)
  ERB.new(template, nil, "-").result(binding)
end