Class: Twb::Analysis::CalculatedFields::DotAnalyzer

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

Constant Summary collapse

@@gvDotLocation =
'C:\\tech\\graphviz\\Graphviz2.38\\bin\\dot.exe'
@@imageTypes =
['pdf', 'png', 'svg']

Instance Attribute Summary collapse

Attributes included from TabTool

#alerts, #docDir, #docfiles, #funcdoc, #id, #licensed, #logfilename, #logger, #loglevel, #metrics, #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) ⇒ DotAnalyzer

Returns a new instance of DotAnalyzer.


29
30
31
32
33
34
35
# File 'lib/twb/analysis/calculatedfields/dotanalyzer.rb', line 29

def initialize(**args)
  @args = args
  init
  @funcdoc = {:class=>self.class, :blurb=>'Create Dot files documenting Calculated Fields', :description=>'Analyze Calculated Fields - create Dot files' }
  @metrics = {}
  @imageFiles = Array.new
end

Instance Attribute Details

#docFileNameObject (readonly)

Returns the value of attribute docFileName


24
25
26
# File 'lib/twb/analysis/calculatedfields/dotanalyzer.rb', line 24

def docFileName
  @docFileName
end

Instance Method Details

#processTWB(twb) ⇒ Object


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
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/twb/analysis/calculatedfields/dotanalyzer.rb', line 37

def processTWB twb
  # twb = File.basename(twb)
  @twb         = twb #Twb::Workbook.new twb
  addDocFile @dotFile, @dotFileName, "Dot file of Calculated fields for Workbook '#{@twb.name}'"
  @twb.datasources.each do |ds|
    unless ds.calculatedFields.empty?
      initDotFile ds.uiname
      # @dotFile.puts "\n ## #{ds.uiname} \n "
      # @dotFile.puts "__has #{ds.calculatedFields.length} calculated fields__\n "
      @cfCnt = 0
      calcFields = Set.new
      refFields  = Set.new
      edges      = Set.new
      ds.calculatedFields.each do |cf|
        @cfCnt += 1
        calcFields << cf.uiname
        edges            << " \"#{ds.uiname}\" -> \"#{cf.uiname}\"  [tailport=e, headport=w] "
        cf.referencedFields.each do |rf|
          refFields << rf.uiname
          edges            << " \"#{cf.uiname}\" -> \"#{rf.uiname}\" [tailport=e, headport=w] "
        end
      end # ds.calculatedFields.each
      # "federated.17h7owt0rsacke17cql8o0w2ittk"  ->  "New AO Actuals Query in PP+ (AO Variance Data)::vs Prior Year [YTD]"
      # "federated.01s5lca037ted31gxs9sg0t9mnnt" [label="Controls"    ]
      edges.each do |edge|
        @dotFile.puts "\t #{edge.strip}"
      end
      @dotFile.puts " "
      allFields = calcFields + refFields
      allFields.each do |f|
        @dotFile.puts "\t \"#{f}\" [label=\"#{f}\"]"
      end
      endPointFields = allFields - calcFields
      rankSame(endPointFields) unless endPointFields.nil? || endPointFields.empty?
      closeDotFile
      @@imageTypes.each do |type|
        renderDot type
      end
    end
  end  # twb.datasources.each
  finis
end