Class: Twb::Analysis::WorksheetSummarizer

Inherits:
Object
  • Object
show all
Includes:
TabTool
Defined in:
lib/twb/analysis/sheets/worksheetsummarizer.rb

Instance Attribute Summary collapse

Attributes included from TabTool

#alerts, #docDir, #docfiles, #funcdoc, #id, #licensed, #logfilename, #logger, #loglevel, #properties, #ttdocdir, #type, #uuid

Instance Method Summary collapse

Methods included from TabTool

#addDocFile, #alert, #closeDocFiles, #config, #docFile, #docFileMaxNameLen, #docfilesdoc, #docfilesdocto_s, #emit, #emitCSV, #finis, #hasConfig, #init, #initCSV, #initDocDir, #initLogger, #license=, #licensed?, #loadConfig

Constructor Details

#initialize(**args) ⇒ WorksheetSummarizer

attr_reader :node, :name, :datasourcenames, :datasources attr_reader :panesCount attr_reader :fields, :rowFields, :colFields, :paneFields, :datasourceFields, :pageFields, :encodedFields, :slicesFields attr_reader :filters attr_reader :tooltip attr_accessor :hidden, :visible


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/twb/analysis/sheets/worksheetsummarizer.rb', line 36

def initialize(**args)
  @args      = args
  @recordDir = !@args.nil? && @args[:recordDir] == true
  @ttdocdir  = @args[:ttdocdir]
  @csvAdd    = !@args.nil? && args[:csvMode] == :add
  @csvMode   = @csvAdd ? 'a' : 'w'
  init
  @funcdoc   = {:class=>self.class, :blurb=>'Summarize Worksheets', :description=>'Identifies Worksheets & summarizes them.',}
  #--
  docFileName     = docFile('WorkheetSummaries.csv')
  @worksheetsCSV  = CSV.open(docFileName,@csvMode)
  unless @csvAdd
    @csvHeader = [ 'Rec #', 
                   'Workbook', 
                   'Worksheet',
                   'Hidden', 'Visible',
                   '# Data Sources', 
                   '# Fields - Data', '# Fields - Rows', '# Fields - Cols',
                   'Tooltip?', 'Filters?'
                 ]
    if @recordDir
      @csvHeader.push 'Workbook Dir'
    end
    @worksheetsCSV << @csvHeader
  end
  addDocFile @worksheetsCSV, docFileName, "Workbooks and their Worksheets' summaries."
  #--
  @twbCount    = 0
  @sheetCount  = 0
  @recNum      = 0
end

Instance Attribute Details

#localEmitObject

Returns the value of attribute localEmit


26
27
28
# File 'lib/twb/analysis/sheets/worksheetsummarizer.rb', line 26

def localEmit
  @localEmit
end

Instance Method Details

#metricsObject


68
69
70
71
72
# File 'lib/twb/analysis/sheets/worksheetsummarizer.rb', line 68

def metrics
  {
    '# of Worksheets' => @sheetCount
  }
end

#parseSheetsObject


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/twb/analysis/sheets/worksheetsummarizer.rb', line 85

def parseSheets
  @worksheets  = @twb.worksheets
  @worksheets.each do |sheet|
    emit "SHEET:: #{sheet.name}"
    @sheetCount += 1
    recordCSV [ @twbName, 
                sheet.name, 
                sheet.hidden, 
                sheet.visible,
                sheet.datasources.length,
                sheet.datasourceFields.length,
                sheet.rowFields.length,
                sheet.colFields.length,
                !sheet.tooltip.nil?,
                !sheet.filters.nil?,
              ]
  end
end

#processTWB(twb) ⇒ Object


74
75
76
77
78
79
80
81
82
83
# File 'lib/twb/analysis/sheets/worksheetsummarizer.rb', line 74

def processTWB twb
   @twb     = twb
   @twbName = @twb.name
   @twbDir  = @twb.dir
   @modTime = @twb.modtime
   emit "   -- #{@twbName}"
   @twbCount += 1
   parseSheets
   finis
end