Class: Twb::Util::TwbDashSheetDataDotBuilder
- Inherits:
-
Object
- Object
- Twb::Util::TwbDashSheetDataDotBuilder
- Defined in:
- lib/twb/util/twbdashsheetdatadotbuilder.rb
Constant Summary collapse
- @@dotHeader =
<<-DOTHEADER digraph g { graph [rankdir="LR" splines="line"]; node [shape="box" width="2"]; "Tableau Tools generated Workbook map" [color="white" border="0"]; DOTHEADER
<<-DOTFOOTER } subgraph cluster_0 { color=white; node [shape="box3d" style="filled" ]; "Workbook" -> "Dashboard" -> "Worksheet" -> "Data Source" "Workbook" "Dashboard"; "Worksheet"; "Data Source"; } } DOTFOOTER
Instance Attribute Summary collapse
-
#dashCount ⇒ Object
readonly
Returns the value of attribute dashCount.
-
#dataSourceCount ⇒ Object
readonly
Returns the value of attribute dataSourceCount.
-
#dotFile ⇒ Object
readonly
Returns the value of attribute dotFile.
-
#dotFileName ⇒ Object
readonly
Returns the value of attribute dotFileName.
-
#sheetCount ⇒ Object
readonly
Returns the value of attribute sheetCount.
-
#workbook ⇒ Object
readonly
Returns the value of attribute workbook.
Instance Method Summary collapse
- #buildBody(pairs) ⇒ Object
- #buildHeader ⇒ Object
- #closeDot ⇒ Object
- #initDot ⇒ Object
-
#initialize(twb) ⇒ TwbDashSheetDataDotBuilder
constructor
A new instance of TwbDashSheetDataDotBuilder.
- #labelDataSources ⇒ Object
- #processDashboards ⇒ Object
- #processOrphans ⇒ Object
- #processWorksheets ⇒ Object
- #sameRank(elements) ⇒ Object
Constructor Details
#initialize(twb) ⇒ TwbDashSheetDataDotBuilder
Returns a new instance of TwbDashSheetDataDotBuilder.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 46 def initialize twb @workbook = if twb.instance_of?(Twb::Workbook) then twb else Twb::Workbook.new(twb) end @dashCount = @workbook.dashboards.length @worksheets = @workbook.worksheetNames @sheetCount = @worksheets.length @datasources = @workbook.datasourceUINames @dataSourceCount = @datasources.length pairs = processDashboards pairs += processWorksheets pairs += processOrphans initDot buildBody(pairs) sameRank([@workbook.name] ) sameRank( @workbook.dashboardNames ) sameRank( @workbook.worksheetNames ) sameRank( @workbook.datasourceNames ) buildHeader labelDataSources closeDot end |
Instance Attribute Details
#dashCount ⇒ Object (readonly)
Returns the value of attribute dashCount.
44 45 46 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 44 def dashCount @dashCount end |
#dataSourceCount ⇒ Object (readonly)
Returns the value of attribute dataSourceCount.
44 45 46 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 44 def dataSourceCount @dataSourceCount end |
#dotFile ⇒ Object (readonly)
Returns the value of attribute dotFile.
44 45 46 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 44 def dotFile @dotFile end |
#dotFileName ⇒ Object (readonly)
Returns the value of attribute dotFileName.
44 45 46 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 44 def dotFileName @dotFileName end |
#sheetCount ⇒ Object (readonly)
Returns the value of attribute sheetCount.
44 45 46 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 44 def sheetCount @sheetCount end |
#workbook ⇒ Object (readonly)
Returns the value of attribute workbook.
44 45 46 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 44 def workbook @workbook end |
Instance Method Details
#buildBody(pairs) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 76 def buildBody(pairs) @dotFile.puts "\n subgraph cluster_1 {" @dotFile.puts " color= grey;" @dotFile.puts "" pairs.each { |pair| @dotFile.puts " \"#{pair[0]}\" -> \"#{pair[1]}\" " } @dotFile.puts "" @dotFile.puts " }" end |
#buildHeader ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 93 def buildHeader @dotFile.puts '' @dotFile.puts ' subgraph cluster_0 {' @dotFile.puts ' color=white;' @dotFile.puts ' node [shape="box3d" style="filled" ];' @dotFile.puts ' "Workbook" -> "Dashboard" -> "Worksheet" -> "Data Source"' @dotFile.puts ' }' end |
#closeDot ⇒ Object
110 111 112 113 114 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 110 def closeDot @dotFile.puts ' ' @dotFile.puts '}' @dotFile.close end |
#initDot ⇒ Object
70 71 72 73 74 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 70 def initDot @dotFileName = @workbook.name + '.dot' @dotFile = File.open(@dotFileName,'w') @dotFile.puts @@dotHeader end |
#labelDataSources ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 102 def labelDataSources @dotFile.puts " " @workbook.datasources.each do |ds| name = ds.name @dotFile.puts " \"#{name}\" [label=\"#{ds.uiname}\"];" end end |
#processDashboards ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 116 def processDashboards pairs = [] @workbook.dashboards.each do |dash| dashName = dash.name pairs << [@workbook.name,dashName] dash.worksheets.each do |sheet| sheetName = sheet.name pairs << [dashName,sheetName] @worksheets.delete sheetName end end return pairs end |
#processOrphans ⇒ Object
143 144 145 146 147 148 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 143 def processOrphans pairs = [] #@datasources.each { |dsn| pairs << [@workbook.name,dsn] } #@worksheets.each { |wsn| pairs << [@workbook.name,wsn] } return pairs end |
#processWorksheets ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 130 def processWorksheets pairs = [] @workbook.worksheets.each do |sheet| sheetName = sheet.name sheet.datasources.each do |ds| dsName = ds.name pairs << [sheetName,ds.name] @datasources.delete ds.uiname end end return pairs end |
#sameRank(elements) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/twb/util/twbdashsheetdatadotbuilder.rb', line 85 def sameRank(elements) @dotFile.puts "\n {rank=same " elements.each do |e| @dotFile.puts " \"#{e}\"" end @dotFile.puts " }" end |