Class: Twb::Analysis::WorkbookSummaryAnalyzer

Inherits:
Object
  • Object
show all
Includes:
TabTool
Defined in:
lib/twb/analysis/workbooksummaryanalyzer.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) ⇒ WorkbookSummaryAnalyzer

Returns a new instance of WorkbookSummaryAnalyzer.


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/twb/analysis/workbooksummaryanalyzer.rb', line 28

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=>'Analyze Workbooks', :description=>'Workbook summary data: # Data Sources; Dashboards; Sheets; etc.'}
  #--
  docFileName  = docFile('WorkbookSummary.csv')
  @csvFile     = CSV.open(docFileName,@csvMode)
  unless @csvAdd
    csvHeader       = ['Rec #', 'Workbook','Directory','Type','Version','Build','Platform','Modified','# Data Sources','# Dashboards','# Worksheets']
    if @recordDir
      csvHeader.push('Workbook Directory')
    end
    @csvFile  << csvHeader 
  end
  addDocFile @csvFile, docFileName, "Workbook summary data."
  #--
  @twbCount    = 0
  @dashCount   = 0
  @dsCount     = 0
  @sheetCount  = 0
  @recNum      = 0
end

Instance Attribute Details

#localEmitObject

Returns the value of attribute localEmit


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

def localEmit
  @localEmit
end

Instance Method Details

#metricsObject


55
56
57
58
59
60
61
62
# File 'lib/twb/analysis/workbooksummaryanalyzer.rb', line 55

def metrics
  {
    # '# of Workbooks'    => @twbCount,
    '# of Data Sources' => @dsCount,
    '# of Dashboards'   => @dashCount,
    '# of Worksheets'   => @sheetCount
  }
end

#processTWB(twb) ⇒ Object


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/twb/analysis/workbooksummaryanalyzer.rb', line 64

def processTWB twb
   @twb     = twb
   emit "   -- #{@twbName}"
   recordCSV [ @twb.name,
               @twb.dir, 
               @twb.type, 
               @twb.version, 
               @twb.build,
               @twb.platform,
               # @twb.base, 
               @twb.modtime, 
               @twb.datasources.length,
               @twb.dashboards.length,
               @twb.worksheets.length
             ]
   @twbCount   += 1
   @dsCount    += @twb.datasources.length
   @dashCount  += @twb.dashboards.length
   @sheetCount += @twb.worksheets.length
   finis
end