#!/usr/bin/env ruby require_relative 'LineType' require_relative 'LineDeterminator' require 'fileutils' class AnalysisHTMLFile def initialize (directory, name) @directory = "#{directory}/#{File.dirname(name.gsub("./", ""))}" @name = name.gsub("#{File.dirname(name)}", "").gsub("/", "") @validLines = 0 @invalidLines = 0 @totalLines = 0 end def beginWriting FileUtils::mkdir_p "#{@directory}" @fileHtml = File.new("#{@directory}/#{@name}.html", "w+") @fileHtml.puts "
" @fileHtml.puts ""
end
def addLine (line)
lineType = LineDeterminator.new(line).lineType
@totalLines += 1
if lineType != nil
if lineType.instance_of? ClassLineType or lineType.instance_of? VariableLineType or lineType.instance_of? ConstantLineType or lineType.instance_of? CommentLineType
font = "#{line.chomp}"
@fileHtml.puts font
else
@fileHtml.puts "#{line.chomp}
"
end
end
end
def endWriting
@fileHtml.puts "
"
@fileHtml.puts ""
@fileHtml.close()
end
def directory
@directory
end
def name
@name
end
def validLines
@validLines
end
def invalidLines
@invalidLines
end
def totalLines
@totalLines
end
end