Sha256: b0abbf86fe7b23bd6c84ccbce98615787d3e6883840c5e0c6885ee73197a42e8
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
#!/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 "<HTML><BODY>" @fileHtml.puts "<pre>" 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 = "<font size=\"3\"" if !lineType.isValid font += "color=\"red\"" @invalidLines += 1 else font += "color=\"#52CC52\"" @validLines += 1 end font += ">#{line.chomp}</font>" @fileHtml.puts font else @fileHtml.puts "<code>#{line.chomp}</code>" end end end def endWriting @fileHtml.puts "</pre>" @fileHtml.puts "</BODY></HTML>" @fileHtml.close() end def directory @directory end def name @name end def validLines @validLines end def invalidLines @invalidLines end def totalLines @totalLines end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dftsg-0.1.2 | lib/AnalysisHTMLFile.rb |
dftsg-0.1.1 | lib/AnalysisHTMLFile.rb |