class Twb::Analysis::SheetSourcesAnalyzer

Attributes

localEmit[RW]

Public Class Methods

new() click to toggle source
# File lib/twb/analysis/DataSources/datasourceslocationsanalyzer.rb, line 28
def initialize
  init
  @funcdoc    = {:class=>self.class, :blurb=>'Analyze Worksheet Fields', :description=>nil,}
  #--
  docFileName = docFile('WorksheetFields.csv')
  @sheetFieldsCSV  = CSV.open(docFileName,'w')
  @sheetFieldsCSV  << ['Workbook','Worksheet','Data Source','Data Source (tech)','Field','Field (tech)','Usage']
  addDocFile docFileName, "Workbooks, Worksheets, and the Sheets' Data Sources and Fields"
  #--
  @twbCnt     = 0
  @sheetCnt   = 0
  @fieldsCnt  = 0
end

Public Instance Methods

metrics() click to toggle source
# File lib/twb/analysis/DataSources/datasourceslocationsanalyzer.rb, line 42
def metrics
  {
    # '# of Workbooks'         => @twbcount,
    '# of Worksheets'        => @sheetCnt,
    '# of Worksheet Fields'  => @fieldsCnt
  }
end
processTWB(twb) click to toggle source
# File lib/twb/analysis/DataSources/datasourceslocationsanalyzer.rb, line 50
def processTWB twb
   @twb = twb
   emit "   -- twb:: #{@twb.name}"
   @twbCnt += 1
   @twbDomainsLoaded = false
   parseSheets
   finis
end

Private Instance Methods

parseSheets() click to toggle source
# File lib/twb/analysis/DataSources/datasourceslocationsanalyzer.rb, line 61
def parseSheets
  @worksheets  = @twb.worksheets
  @worksheets.each do |sheet|
    @sheet     = sheet.name
    @sheetCnt += 1
    emit "SHEET: #{@sheet}"
    showFields sheet unless sheet.datasourceFields.nil?
  end
end
showDBFields(sheet) click to toggle source
# File lib/twb/analysis/DataSources/datasourceslocationsanalyzer.rb, line 77
def showDBFields sheet
  fields = sheet.datasourceFields
  emit "def showDBFields sheet: #{sheet.name} #FIELDS: #{fields.length}"
  if fields.nil?
    @sheetFieldsCSV  << [@twb.name, @sheet, nil, nil, nil, nil, nil]
  end
  fields.each do |dsName, dsfields|
    ds = @twb.datasource dsName
    emit "      ds: #{dsName}"
    emit "        - #{ds.uiname}"
    emit "        : #{ds.class}"
    dsfields.each do |sheetField|
       @fieldsCnt += 1
       emit "       f: #{sheetField}"
       emit "       c: #{sheetField.class}"
       fuiName = ds.fieldUIName sheetField #Fields[sheetField]
       @sheetFieldsCSV  << [@twb.name, @sheet, ds.uiname, dsName, sheetField.uiname, sheetField.name, 'DB ref']
       # emit true, "        : #{dsFields[field].class}"
    end
  end
end
showFields(sheet) click to toggle source
# File lib/twb/analysis/DataSources/datasourceslocationsanalyzer.rb, line 71
def showFields sheet
  showDBFields  sheet
  showRCFields  sheet.rowFields, :row
  showRCFields  sheet.colFields, :column
end
showRCFields(fields, usage) click to toggle source
# File lib/twb/analysis/DataSources/datasourceslocationsanalyzer.rb, line 99
def showRCFields fields, usage
  emit "def showRCFields #fields: #{fields.length}  \t #{fields}"
  if fields.nil?
    @sheetFieldsCSV  << [@twb.name, @sheet, nil, nil, nil, nil, nil]
  else
    fields.each do |cf|
      emit "coded field: #{cf}"
      fldName = cf.name
      dsName  = cf.dataSource
      ds      = @twb.datasource cf.dataSource
      emit "DATASOURCE : #{ds.class} "  #{ }" #{ds}"
      fuiName = ds.fieldUIName cf.name
      emit "      ds: #{dsName}"
      emit "        - #{ds.uiname}"
      emit "        : #{ds.class}"
      @sheetFieldsCSV  << [@twb.name, @sheet, ds.uiname, dsName, fuiName, fldName, usage]
    end
  end
end