class Twb::Analysis::CalculatedFields::CSVEmitter
Attributes
calcFieldsCount[R]
calcFieldsFile[R]
calcFieldsHeader[R]
calcFieldsRecords[R]
calcFieldsType[R]
csvFiles[R]
dictionary[R]
refFieldsCount[R]
refFieldsFile[R]
refFieldsHeader[R]
refFieldsRecords[R]
refFieldsType[R]
Public Class Methods
new()
click to toggle source
# File lib/twb/analysis/CalculatedFields/CSVEmitter.rb, line 28 def initialize @calcFieldsContents = 'Calculated Fields with Formulas' @calcFieldsType = 'CalculatedFieldsWithFormulas' @calcFieldsHeader = ['Record #', 'Workbook', 'Workbook Dir', 'Data Source Name (tech)', 'Data Source Caption', 'Data Source Name', 'Field Name (tech)', 'Field Caption', 'Field Name', 'Data Source + Field Name (tech)', 'Formula (flat)', 'Formula Length', 'Formula Table Calc?', 'Formula LOD?', 'Formula LOD Code Position' ] @refFieldsContents = 'Fields referenced in Calculated Fields Formulae' @refFieldsType = 'CalculatedFieldsReferencedFields' @refFieldsHeader = ['Record #', 'Workbook', 'Workbook Dir', 'Data Source Name (tech)', 'Data Source Caption', 'Data Source Name', 'Field Name (tech)', 'Field Caption', 'Field Name', 'Referenced Field', 'Referenced DataSource', 'Referenced DataSource Location' ] @dictionary = [ { :contents => @calcFieldsContents, :fileType => @calcFieldsType, :fileHeader => @calcFieldsHeader }, { :contents => @refFieldsContents, :fileType => @calcFieldsType, :fileHeader => @calcFieldsHeader } ] end
Public Instance Methods
processTwb(twbFileName)
click to toggle source
def calcFieldsHeader
@refFieldsHeader
end
# File lib/twb/analysis/CalculatedFields/CSVEmitter.rb, line 87 def processTwb twbFileName twb = File.basename(twbFileName) @twb = Twb::Workbook.new twb # -- @calcFieldsFile = "#{twb}.#{@calcFieldsType}.csv" @csvCalcFile = CSV.open(@calcFieldsFile,'w') @csvCalcFile << @calcFieldsHeader @calcFieldsCount = 0 @calcFieldsRecords = [] # -- @refFieldsFile = "#{twb}.#{@refFieldsType}.csv" # twb + '.CalcReferenceFields.csv' @csvRefFile = CSV.open(@refFieldsFile,'w') @csvRefFile << @refFieldsHeader @refFieldsCount = 0 @refFieldsRecords = [] # -- @csvFiles = [ { :contents => @calcFieldsContents, :name => @calcFieldsFile, :records => @calcFieldsRecords }, { :contents => @refFieldsContents, :name => @refFieldsFile, :records => @refFieldsRecords } ] # -- dss = @twb.datasources dss.each do |ds| calcFields = ds.calculatedFieldsMap.sort_by { |fldName,calc| fldName } calcFields.each do |fldname, field| formRecord = [ @calcFieldsCount += 1, @twb.name, @twb.dir, ds.name, ds.caption, ds.uiname, field.name, field.caption, field.uiname, "#{ds.name}.#{field.name}", field.calculation.formulaFlatResolved, field.calculation.formula.length, field.calculation.is_tableCalc, field.calculation.is_lod, field.calculation.lodCodePos ] @calcFieldsRecords.push formRecord @csvCalcFile << formRecord #-- field.calculation.calcFields.each do |cf| refRecord = [ @refFieldsCount += 1, @twb.name, @twb.dir, ds.name, ds.caption, ds.uiname, field.name, field.caption, field.uiname, cf.uiName, cf.dataSource, cf.dataSourceRef, ] @refFieldsRecords.push refRecord @csvRefFile << refRecord end end end @csvCalcFile.close unless @csvCalcFile.nil? @csvRefFile.close unless @csvRefFile.nil? end