Class: Twb::Analysis::CalculatedFieldsAnalyzer
- Inherits:
-
Object
- Object
- Twb::Analysis::CalculatedFieldsAnalyzer
- Defined in:
- lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb
Overview
< Twb::Util::Graph
Constant Summary collapse
- @@ttlogfile =
'CalculatedFieldsAnalyzer.ttlog'- @@gvDotLocation =
'C:\\tech\\graphviz\\Graphviz2.38\\bin\\dot.exe'- @@processName =
'.CalculatedFields'- @@calcFieldsCSVFileName =
'TwbCalculatedFields.csv'- @@calcFieldsCSVFileHeader =
['Record #', 'Workbook', 'Workbook Dir', 'Data Source', 'Data Source Caption', 'Data Source Name (tech)', 'Field Name', 'Field Caption', 'Field Name (tech)', 'Data Source + Field Name (tech)', 'Data Type', 'Role', 'Type', 'Class', 'Scope Isolation', 'Formula Length', 'Formula', 'Formula (tech)', 'Formula Comments', 'Formula LOD?' ]
- @@calcLinesCSVFileName =
'TwbCalculatedFieldFormulaLines.csv'- @@calcLinesCSVFileHeader =
['Calc Field #', 'Workbook', 'Workbook Dir', 'Data Source', 'Data Source Caption', 'Data Source Name (tech)', 'Field Name', 'Field Caption', 'Field Name (tech)', 'Formula', 'Formula Line #', 'Formula Line' ]
- @@formFieldsCSVFileName =
'TwbCalculatedFieldsReferenced.csv'- @@formFieldsCSVFileHeader =
['Rec #', 'Workbook', 'Workbook Dir', 'Data Source', 'Field - Calculated', 'Formula (tech)', 'Formula', 'Field - Referenced (tech)', 'Field - Referenced', 'Data Source + Field - Referenced', 'Table' ]
- @@dotHeader =
" digraph g {\n graph [rankdir=\"LR\" splines=line];\n node [shape=\"box\" width=\"2\"];\n\n"
Constants included from TabTool
Instance Attribute Summary collapse
-
#calculatedFieldsCount ⇒ Object
readonly
Returns the value of attribute calculatedFieldsCount.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#referencedFieldsCount ⇒ Object
readonly
Returns the value of attribute referencedFieldsCount.
-
#ttdocdir ⇒ Object
Returns the value of attribute ttdocdir.
Attributes included from Graph
Attributes included from TabTool
#alerts, #docfiles, #funcdoc, #id, #licensed, #logfilename, #logger, #loglevel, #properties, #type, #uuid
Instance Method Summary collapse
-
#initialize ⇒ CalculatedFieldsAnalyzer
constructor
A new instance of CalculatedFieldsAnalyzer.
- #loadMetrics ⇒ Object
- #processTWB(workbook) ⇒ Object
Methods included from TabTool
#addDocFile, #alert, #docFile, #docFileMaxNameLen, #docfilesdoc, #emit, #emitCSV, #finis, #init, #initCSV, #initDocDir, #initLogger, #license=, #licensed?
Constructor Details
#initialize ⇒ CalculatedFieldsAnalyzer
Returns a new instance of CalculatedFieldsAnalyzer.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb', line 84 def initialize init @funcdoc = {:class=>self.class, :blurb=>'Analyze Calculated Fields from Tableau Workbooks.', :description=>'Calculated fields can be complex, this tool provides robust coverage.',} #-- CSV records collectors @csvCalculatedFields = [] @csvFormulaFields = [] @csvFormulaLines = [] #-- Counters setup -- @twbCount = 0 @calculatedFieldsCount = 0 @referencedFieldsCount = 0 #-- @referencedFields = SortedSet.new #-- @csvCF = initCSV(@@calcFieldsCSVFileName, 'Calculated fields and their formulas.', @@calcFieldsCSVFileHeader) @csvCFLs = initCSV(@@calcLinesCSVFileName, "Calculated fields and their formulas' individual lines.", @@calcLinesCSVFileHeader) @csvFF = initCSV(@@formFieldsCSVFileName, 'Calculated fields and the fields their formulas reference.', @@formFieldsCSVFileHeader) #-- @localEmit = false @imageFiles = [] end |
Instance Attribute Details
#calculatedFieldsCount ⇒ Object (readonly)
Returns the value of attribute calculatedFieldsCount.
29 30 31 |
# File 'lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb', line 29 def calculatedFieldsCount @calculatedFieldsCount end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
29 30 31 |
# File 'lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb', line 29 def metrics @metrics end |
#referencedFieldsCount ⇒ Object (readonly)
Returns the value of attribute referencedFieldsCount.
29 30 31 |
# File 'lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb', line 29 def referencedFieldsCount @referencedFieldsCount end |
#ttdocdir ⇒ Object
Returns the value of attribute ttdocdir.
30 31 32 |
# File 'lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb', line 30 def ttdocdir @ttdocdir end |
Instance Method Details
#loadMetrics ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb', line 138 def loadMetrics @metrics = { '# of Workbooks' => @twbCount, '# of Calculated Fields' => @calculatedFieldsCount, '# of Referenced Fields' => @referencedFieldsCount, } end |
#processTWB(workbook) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb', line 106 def processTWB workbook @twb = workbook.is_a?(String) ? Twb::Workbook.new(workbook) : workbook throw Exception unless @twb.is_a? Twb::Workbook emit "- Workbook: #{workbook}" emit " version: #{@twb.version}" @twbDir = @twb.dir #File.dirname(File.expand_path(workbook)) @edges = Set.new #-- processing dss = @twb.datasources # puts " # data sources: #{dss.length}" @twbRootFields = Set.new @twbFields = {} @nodes = Set.new dss.each do |ds| # puts "\t\t - #{ds.uiname} \t\t #{ds.calculatedFields.length}" next if ds.Parameters? # don't process the Parameters data source - Parameters' fields aren't Calculated fields for our purposes # dataSourceNode = Twb::Util::Graphnode.new(name: ds.uiname, id: ds.id, type: ds, properties: {workbook: workbook}) # @nodes.add dataSourceNode # ds.calculatedFields.each do |calcField| # end processDataSource ds end mapTwb emitGml @twbCount += 1 finis end |