Class: Twb::Analysis::SheetFiltersAnalyzer

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

Returns a new instance of SheetFiltersAnalyzer.



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
# File 'lib/twb/analysis/sheets/sheetfiltersanalyzer.rb', line 28

def initialize(**args)
  @args      = args
  # puts "@args: #{@args}"
  @recordDir = !@args.nil? && @args[:recordDir] == true
  @ttdocdir  = @args[:ttdocdir]
  @csvAdd    = args[:csvMode] == :add
  @csvMode   = @csvAdd ? 'a' : 'w'
  init
  @funcdoc   = {:class=>self.class, :blurb=>'Analyze Worksheet Filters', :description=>'Documents Quick Filters and the values they employ, if any. Work in progess.',}
  #--
  docFileName      = docFile('WorksheetFilters.csv')
  @sheetFieldsCSV  = CSV.open( docFileName,@csvMode)
  unless @csvAdd
    if @recordDir
      @sheetFieldsCSV  << ['Rec #','Workbook','Workbook Modified','Worksheet','Filter Type','Operation','Data Source','Field','Value','Alias', 'Alias?','Operation Mode','Include Null?','Kind','Workbook Dir']
    else
      @sheetFieldsCSV  << ['Rec #','Workbook','Workbook Modified','Worksheet','Filter Type','Operation','Data Source','Field','Value','Alias', 'Alias?','Operation Mode','Include Null?','Kind']
    end
  end
  addDocFile @sheetFieldsCSV, docFileName, "Workbooks, Worksheets and the sheets' Quick Filters"
  #--
  @sheetCount  = 0
  @filterCount = 0
  @recNum      = 0
end

Instance Attribute Details

#localEmitObject

Returns the value of attribute localEmit.



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

def localEmit
  @localEmit
end

Instance Method Details

#metricsObject



54
55
56
57
58
59
# File 'lib/twb/analysis/sheets/sheetfiltersanalyzer.rb', line 54

def metrics
  {
    '# of Worksheets'        => @sheetCount,
    '# of Worksheet Filters' => @filterCount
  }
end

#parseFiltersObject



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

def parseFilters
  @worksheets  = @twb.worksheets
  @worksheets.each do |sheet|
    emit "\n\nSHEET: #{sheet.name}"
    filters = sheet.filters
    filters.each do |filter|
      filter.emit "-----------------------------\nWORKSHEET:: #{sheet.name}\n-----------------------------"
      if filter.values.empty?
      # @sheetFieldsCSV  << ['Workbook','Worksheet','Filter Type','Operation'     ,'Data Source','Field','Value','Alias', 'Alias?']
        recordCSV [@twbName, @modTime, sheet.name, filter.type, filter.inexclude, filter.dataSource.uiname, filter.uiname, nil,   nil,    nil,  filter.inexMode, filter.includeNull, filter.kind]
      end
      filter.values.each do |valueMap|
        value  = valueMap[:value]
        valias = valueMap[:alias]
        same   = value.eql? valias
        emit "RECORDING FILTER VALUES:  %-35s  --  %-25s  same? %s " % [value,valias,same]
        recordCSV [@twbName, @modTime, sheet.name, filter.type, filter.inexclude, filter.dataSource.uiname, filter.uiname, value, valias, same, filter.inexMode, filter.includeNull, filter.kind]
      end
    end
  end
end

#processTWB(twb) ⇒ Object



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

def processTWB twb
   @twb     = twb
   @twbName = @twb.name
   @twbDir  = @twb.dir
   @modTime = @twb.modtime
   emit "   -- #{@twbName}"
   @twbDomainsLoaded = false
   parseFilters
end