module TabTool
Attributes
alerts[R]
docDir[RW]
docfiles[RW]
funcdoc[R]
id[RW]
licensed[R]
logfilename[RW]
logger[RW]
loglevel[RW]
metrics[R]
properties[RW]
ttdocdir[RW]
type[RW]
uuid[RW]
Public Instance Methods
addDocFile(file, name, description)
click to toggle source
# File lib/twb/tabtool.rb, line 118 def addDocFile file, name, description @docfiles = [] if @docfiles.nil? @docfiles << {:file=>file, :name=>name, :description=>description} end
alert(str)
click to toggle source
# File lib/twb/tabtool.rb, line 214 def alert str @alerts << str emit "#{self.class} :: #{str}" end
closeDocFiles()
click to toggle source
# File lib/twb/tabtool.rb, line 123 def closeDocFiles emit "Closing doc files" unless @docfiles.nil? @docfiles.each do |dfh| docfile = dfh[:file] fileName = dfh[:name] emit " -- #{dfh}" # system "ls -l '#{fileName}'" docfile.close unless docfile.nil? # system "ls -l '#{fileName}'" # emit true, " -- #{dfh[:name]}" end end emit "-----------------" end
config(param)
click to toggle source
# File lib/twb/tabtool.rb, line 102 def config param hasConfig(param) ? @configParams[param] : nil end
docFile(name)
click to toggle source
# File lib/twb/tabtool.rb, line 81 def docFile name @docDir.nil? ? name : "#{@docDir}/#{name}" end
docFileMaxNameLen()
click to toggle source
# File lib/twb/tabtool.rb, line 139 def docFileMaxNameLen maxlen = 0 docfiles.each do |f| nameLen = f[:name].class == String ? [maxlen, f[:name].length].max : 0 maxlen = nameLen.nil? ? maxlen : [maxlen,nameLen].max end return maxlen end
docfilesdoc(pad=' ',desc='For documentation and generated data see the following:')
click to toggle source
# File lib/twb/tabtool.rb, line 148 def docfilesdoc(pad=' ',desc='For documentation and generated data see the following:') lines = SortedSet.new paddesc = "#{pad}#{desc}" unless @docfiles.nil? || @docfiles.empty? nameLen = docFileMaxNameLen docfiles.each do |dfi| lines << "#{pad}- %-#{nameLen}s %-s " % [ dfi[:name], dfi[:description] ] end end docLines = lines.empty? || paddesc =~ /^[ ]+/ ? [] : [' ',"#{pad}#{desc}"] lines.each do |l| docLines << l end return docLines end
docfilesdocto_s(pad=' ',desc='For documentation and generated data see the following:')
click to toggle source
# File lib/twb/tabtool.rb, line 164 def docfilesdocto_s(pad=' ',desc='For documentation and generated data see the following:') str = '' docfilesdoc(pad,desc).each { |l| str += "#{l}\n"} return str end
emit(local=@localEmit, stuff)
click to toggle source
# File lib/twb/tabtool.rb, line 192 def emit(local=@localEmit, stuff) # if @logger.closed? # @logger.reopen # end if stuff.is_a? String then lines = stuff.split(/\n/) lines.each do |line| @logger.debug "#{@emitPrefix}#{line}" unless @logger.nil? puts "#{@emitPrefix}#{line}" if local end else @logger.debug "#{@emitPrefix}#{stuff}" unless @logger.nil? puts "#{@emitPrefix}#{stuff}" if local end end
emitCSV(csvFile, record)
click to toggle source
# File lib/twb/tabtool.rb, line 208 def emitCSV csvFile, record emit record csvFile << record unless csvFile.nil? emit "##### ALERT ##### CSV file expected, is nil" if csvFile.nil? end
finis()
click to toggle source
# File lib/twb/tabtool.rb, line 219 def finis # @logger.close unless @logger.nil? || @logger.closed? end
hasConfig(param)
click to toggle source
# File lib/twb/tabtool.rb, line 97 def hasConfig param loadConfig if @configParams.nil? @configParams[param] ? true : false end
init()
click to toggle source
@docDirSet = false
# File lib/twb/tabtool.rb, line 41 def init @alerts = [] initDocDir initLogger end
initCSV(fileName, desc=nil, header=nil)
click to toggle source
def metrics
{}
end
# File lib/twb/tabtool.rb, line 174 def initCSV(fileName, desc=nil, header=nil) emit "def initCSV" csvName = docFile(fileName) emit " @recordDir: #{@recordDir.nil?} \t :: #{@recordDir}" emit " header: #{@header.nil?} \t :: #{header}" emit " csvName: #{csvName.nil?} :: #{csvName}" csvFile = CSV.open(csvName, 'w') unless header.nil? if @recordDir csvFile << header.push('Workbook Directory') else csvFile << header end end addDocFile csvFile, csvName, desc return csvFile end
initDocDir()
click to toggle source
# File lib/twb/tabtool.rb, line 53 def initDocDir # puts "def initDocDir" # return if @@TTDOCDIR.nil? # return if ''.eql?($ttdocdir) && ''.eql?(@@TTDOCDIR) @docDir = @ttdocdir.nil? ? @@TTDOCDIR : @ttdocdir # puts " @@TTDOCDIR: #{@@TTDOCDIR}" # puts " @ttdocdir: #{@ttdocdir}" # puts " @docDir : #{@docDir}" # puts "" return if Dir.exists?(@docDir) if File.exists? @docDir # on the off chance that the doc dir is already present as a file @docDir = '' else Dir.mkdir @docDir end return @docDir end
initLogger()
click to toggle source
# File lib/twb/tabtool.rb, line 71 def initLogger @logger = nil if config(:log) logFileName = docFile("#{self.class.to_s.split('::').last}.ttlog") @logger = Logger.new(logFileName) @logger.level = Logger::DEBUG end return @logger end
license=(fileName)
click to toggle source
# File lib/twb/tabtool.rb, line 85 def license= fileName @@licensed = fileName.is_a?(String) && File.exist?(fileName) end
licensed?()
click to toggle source
# File lib/twb/tabtool.rb, line 89 def licensed? @@licensed end
loadConfig()
click to toggle source
# File lib/twb/tabtool.rb, line 106 def loadConfig @configParams = if File.exist?('./ttconfig.yml') YAML.load( File.open('./ttconfig.yml').read ) else {} end end
ttdocdir=(docdir)
click to toggle source
# File lib/twb/tabtool.rb, line 47 def ttdocdir= docdir # puts "def ttdocdir= #{docdir}" @ttdocdir = docdir init end