#!/usr/bin/env ruby require_relative 'AnalyzedClass' require 'fileutils' require 'pathname' class AnalysisHTMLFile def initialize (directory, analyzedClass) @directory = directory @analyzedClass = analyzedClass @name = @analyzedClass.fileName.gsub("#{File.dirname(@analyzedClass.fileName)}", "").gsub("/", "") end def writeFile FileUtils::mkdir_p "#{@directory}" @fileHtml = File.new("#{@directory}/#{@name}.html", "w+") @fileHtml.puts "
" @fileHtml.puts ""
funcCurlyBraces = 0
isInFunction = false
puts @analyzedClass.fileName
f = File.open(@analyzedClass.fileName, "r")
f.each_line do |line|
if @analyzedClass.isLineWithTestedFunction line
isInFunction = true
end
if isInFunction
if line.include? "{"
funcCurlyBraces += 1
end
if line.include? "}"
funcCurlyBraces -= 1
end
@fileHtml.puts "#{line.chomp}"
if funcCurlyBraces == 0
isInFunction = false
end
else
@fileHtml.puts "#{line.chomp}
"
end
end
f.close
@fileHtml.puts "
"
@fileHtml.puts ""
@fileHtml.close()
end
def directory
@directory
end
def name
@name
end
end