Class: Twb::Analysis::SheetsInTooltipAnalyzer

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

Instance Attribute Summary

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) ⇒ SheetsInTooltipAnalyzer

Returns a new instance of SheetsInTooltipAnalyzer.


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

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=>'Tooltip Vizzes', :description=>'Identifies the vizzes used in tooltips.',}
  #--
  docFileName     = docFile('SheetsInTooltips.csv')
  @csvFile  = CSV.open(docFileName,@csvMode)
  unless @csvAdd
    if @recordDir
      @csvFile  << ['Rec #','Workbook','Worksheet - Host','Worksheet - Toolip viz','Max Width','Max Height', 'Workbook Dir']
    else
      @csvFile  << ['Rec #','Workbook','Worksheet - Host','Worksheet - Toolip viz','Max Height','Max Width']
    end
  end
  addDocFile @csvFile, docFileName, "Workbooks, Worksheets with Vizzes in their Tooltips"
  #--
  @twbCount    = 0
  @sheetCount  = 0
  @ttvizCount  = 0
  @recNum      = 0
end

Instance Method Details

#metricsObject


52
53
54
55
56
57
58
# File 'lib/twb/analysis/sheets/sheetsintooltipanalyzer.rb', line 52

def metrics
  {
    # '# of Workbooks'  => @twbCount,
    '# of Worksheets' => @sheetCount,
    '# of Worksheets in Tooltips' => @ttvizCount
  }
end

#parseSheetsObject


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/twb/analysis/sheets/sheetsintooltipanalyzer.rb', line 71

def parseSheets
  @sheets      = @twb.worksheets
  # puts " #Sheets: #{@sheets.length}"
  @sheetCount += @sheets.length
  @sheets.each do |sheet|
    # puts "SHEET:: #{sheet.name}"
    # @dashCount += 1
    ttip = sheet.tooltip
    runs = ttip.xpath('.//run')
    runs.each do |run|
      # puts run.text
      text = run.text
      isViz = text =~ /.*<Sheet[ ]+name=.*>.*/
      # puts "\t   #{text}"
      if isViz
        vizCode = text.gsub(/^[^<]*/,'').gsub(/[^>]*$/,'')
        vizNode = Nokogiri::XML(vizCode).at_xpath('./Sheet')
        # puts "\t   #{vizCode}"
        # puts "\t   #{vizNode.class}  \t #{vizNode}"
        recordCSV [@twbName, sheet.name, vizNode['name'], vizNode['maxwidth'], vizNode['maxheight']]
      end
      
      # @sheetCount += 1
      # recordCSV [@twbName, dash.name, sheet.name, sheet.hidden, sheet.visible ]
    end
  end
end

#processTWB(twb) ⇒ Object


60
61
62
63
64
65
66
67
68
69
# File 'lib/twb/analysis/sheets/sheetsintooltipanalyzer.rb', line 60

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