twb 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Twb Gem.komodoproject +5 -0
- data/lib/twb.rb +7 -3
- data/lib/twb/dashboard.rb +5 -1
- data/lib/twb/datasource.rb +0 -4
- data/lib/twb/docdashboard.rb +0 -61
- data/lib/twb/docdashboardimagevert.rb +91 -0
- data/lib/twb/docdashboardwebvert.rb +122 -0
- data/lib/twb/field.rb +1 -1
- data/lib/twb/util/dotFileRenderer.rb +53 -0
- data/lib/twb/util/twbDashSheetDataDotBuilder.rb +154 -0
- data/lib/twb/util/twbDashSheetDataDotRenderer.rb +160 -0
- data/lib/twb/workbook.rb +15 -9
- data/lib/twb/worksheet.rb +1 -1
- data/test/No Content.injected.twb +82 -0
- data/test/No Content.injectedImage.twb +83 -0
- data/test/No Dashboards.injected.twb +618 -0
- data/test/No Dashboards.injectedImage.twb +619 -0
- data/test/TwoSheetDash.test.dot.pdf +0 -0
- data/test/TwoSheetDash.test.dot.png +0 -0
- data/test/TwoSheetDash.test.dot.svg +128 -0
- data/test/TwoSheetDash.twb +3789 -0
- data/test/TwoSheetDash.twb.dot +44 -0
- data/test/TwoSheetDash.twb.dot.pdf +0 -0
- data/test/TwoSheetDash.twb.dot.png +0 -0
- data/test/TwoSheetDash.twb.dot.svg +128 -0
- data/test/Web Page Dashboards.injected.twb +1327 -0
- data/test/Web Page Dashboards.twb +436 -470
- data/test/dotRender.cmd +0 -0
- data/test/testDocDashboardImageVert.rb +66 -0
- data/test/testDocDashboardWebVert.rb +67 -0
- data/test/testDotFileRenderer.rb +55 -0
- data/test/testTwbDashSheetDataDotBuilder.rb +44 -0
- data/twb-0.1.1.gem +0 -0
- data/twb-0.2.0.gem +0 -0
- data/twb-0.2.1.gem +0 -0
- data/twb-0.2.2.gem +0 -0
- metadata +29 -1
data/Twb Gem.komodoproject
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
<!-- Komodo Project File - DO NOT EDIT -->
|
|
3
3
|
<project id="887c8573-579f-4918-904e-b93029547076" kpf_version="5" name="Twb Gem.komodoproject">
|
|
4
4
|
<preference-set idref="887c8573-579f-4918-904e-b93029547076" id="project" preftype="project">
|
|
5
|
+
<string relative="path" id="import_dirname"></string>
|
|
6
|
+
<long id="indentWidth">2</long>
|
|
7
|
+
<string id="last_local_directory">None</string>
|
|
8
|
+
<string id="last_remote_directory">None</string>
|
|
5
9
|
<long id="prefs_version">1</long>
|
|
10
|
+
<long id="tabWidth">2</long>
|
|
6
11
|
</preference-set>
|
|
7
12
|
</project>
|
data/lib/twb.rb
CHANGED
|
@@ -20,15 +20,19 @@ require_relative 'twb/fieldcalculation.rb'
|
|
|
20
20
|
require_relative 'twb/localfield'
|
|
21
21
|
require_relative 'twb/metadatafield'
|
|
22
22
|
require_relative 'twb/storyboard'
|
|
23
|
-
require_relative 'twb/util/htmllistcollapsible'
|
|
24
|
-
require_relative 'twb/util/xraydashboards'
|
|
25
23
|
require_relative 'twb/window'
|
|
26
24
|
require_relative 'twb/workbook'
|
|
27
25
|
require_relative 'twb/worksheet'
|
|
26
|
+
require_relative 'twb/docdashboardimagevert.rb'
|
|
27
|
+
require_relative 'twb/docdashboardwebvert.rb'
|
|
28
|
+
require_relative 'twb/util/twbDashSheetDataDotBuilder'
|
|
29
|
+
require_relative 'twb/util/dotFileRenderer'
|
|
30
|
+
require_relative 'twb/util/htmllistcollapsible'
|
|
31
|
+
require_relative 'twb/util/xraydashboards'
|
|
28
32
|
|
|
29
33
|
# Represents Tableau Workbooks and their contents.
|
|
30
34
|
#
|
|
31
35
|
module Twb
|
|
32
|
-
VERSION = '0.
|
|
36
|
+
VERSION = '0.3.0'
|
|
33
37
|
end
|
|
34
38
|
|
data/lib/twb/dashboard.rb
CHANGED
data/lib/twb/datasource.rb
CHANGED
data/lib/twb/docdashboard.rb
CHANGED
|
@@ -52,67 +52,6 @@ module Twb
|
|
|
52
52
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
class DocDashboardWebVert < DocDashboard
|
|
56
|
-
|
|
57
|
-
attr_reader :url
|
|
58
|
-
|
|
59
|
-
def initialize
|
|
60
|
-
@oneColWebPageDash = Nokogiri::XML::Document.parse <<-ONECOlWEBDASH
|
|
61
|
-
<dashdoc>
|
|
62
|
-
<dashboard name='Single Column Web Page Automatic'>
|
|
63
|
-
<style></style>
|
|
64
|
-
<zones>
|
|
65
|
-
<zone h='100000' id='3' param='vert' type='layout-flow' w='100000' x='0' y='0'>
|
|
66
|
-
<zone h='6221' id='1' type='title' w='100000' x='0' y='0'></zone>
|
|
67
|
-
<zone h='93157' id='4' param='horz' type='layout-flow' w='100000' x='0' y='6221'>
|
|
68
|
-
<zone forceUpdate='' h='93157' id='6' param='URL' type='web' w='99655' x='0' y='6221'></zone>
|
|
69
|
-
</zone>
|
|
70
|
-
</zone>
|
|
71
|
-
</zones>
|
|
72
|
-
</dashboard>
|
|
73
|
-
<window auto-hidden='0' class='dashboard' maximized='1' name='Single Column Web Page Automatic'>
|
|
74
|
-
<zones>
|
|
75
|
-
<zone h='6221' id='1' name='' type='title' w='100000' x='0' y='0' />
|
|
76
|
-
<zone forceUpdate='' h='93157' id='5' name='' param='Web Page' type='web' w='50000' x='50000' y='6221' />
|
|
77
|
-
</zones>
|
|
78
|
-
</window>
|
|
79
|
-
</dashdoc>
|
|
80
|
-
ONECOlWEBDASH
|
|
81
|
-
# notes:
|
|
82
|
-
# - adding a size element to the <dashboard element will change it from automatic, e.g.
|
|
83
|
-
#
|
|
84
|
-
# <dashboard name='One Column Web Page Laptop (800w 600h)'>
|
|
85
|
-
# <style>
|
|
86
|
-
# </style>
|
|
87
|
-
# <size maxheight='600' maxwidth='800' minheight='600' minwidth='800' />
|
|
88
|
-
#
|
|
89
|
-
# - the 'name' sttributes for the window and dashboard must match
|
|
90
|
-
@type = 'columnar Web Page'
|
|
91
|
-
@dashnode = @oneColWebPageDash.at_xpath('//dashboard')
|
|
92
|
-
@winnode = @oneColWebPageDash.at_xpath('//window')
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def title=(title)
|
|
96
|
-
@title = title
|
|
97
|
-
@dashnode['name'] = title
|
|
98
|
-
@winnode['name'] = title
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def url=(url)
|
|
102
|
-
dashwebzone = @dashnode.at_xpath('.//zone[@type="web"]')
|
|
103
|
-
dashwebzone['param'] = url # unless dashwebzone.nil?
|
|
104
|
-
winwebzone = @winnode.at_xpath('.//zone[@type="web"]')
|
|
105
|
-
winwebzone['param'] = url # unless winwebzone.nil?
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def url
|
|
109
|
-
dashurl = @dashnode.at_xpath('.//zone[@type="web"]').attribute('param').value
|
|
110
|
-
winurl = @winnode.at_xpath( './/zone[@type="web"]').attribute('param').value
|
|
111
|
-
@url = if dashurl == winurl then dashurl end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
end
|
|
115
|
-
|
|
116
55
|
class DocDashboardWebHoriz < DocDashboard
|
|
117
56
|
def initialize
|
|
118
57
|
@type = 'horizontal'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Copyright (C) 2014, 2015 Chris Gerrard
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
require 'nokogiri'
|
|
17
|
+
|
|
18
|
+
module Twb
|
|
19
|
+
|
|
20
|
+
class DocDashboardImageVert < DocDashboard
|
|
21
|
+
|
|
22
|
+
attr_reader :image
|
|
23
|
+
|
|
24
|
+
def initialize
|
|
25
|
+
@oneImageDash = Nokogiri::XML::Document.parse <<-ONEIMAGEDASH
|
|
26
|
+
<dashdoc>
|
|
27
|
+
<dashboard name='Dashboard Automatic Vert with Image'>
|
|
28
|
+
<style>
|
|
29
|
+
</style>
|
|
30
|
+
<zones>
|
|
31
|
+
<zone h='100000' w='100000'
|
|
32
|
+
x='0' y='0'
|
|
33
|
+
type='layout-flow'
|
|
34
|
+
param='vert'
|
|
35
|
+
id='7'
|
|
36
|
+
>
|
|
37
|
+
<zone h='100000' w='100000'
|
|
38
|
+
x='0' y='0'
|
|
39
|
+
type='title'
|
|
40
|
+
id='6'
|
|
41
|
+
>
|
|
42
|
+
</zone>
|
|
43
|
+
<zone h='93157' w='100000'
|
|
44
|
+
x='0' y='6221'
|
|
45
|
+
type='bitmap'
|
|
46
|
+
is-centered='0'
|
|
47
|
+
is-scaled='1'
|
|
48
|
+
param='{fully qualified image file name here}'
|
|
49
|
+
id='8'
|
|
50
|
+
>
|
|
51
|
+
</zone>
|
|
52
|
+
</zone>
|
|
53
|
+
</zones>
|
|
54
|
+
</dashboard>
|
|
55
|
+
<window auto-hidden='0' class='dashboard' maximized='1' name='Dashboard Automatic with Image'>
|
|
56
|
+
<active id='8' />
|
|
57
|
+
<zones>
|
|
58
|
+
<zone is-centered='0' is-scaled='1' name='' type='bitmap' />
|
|
59
|
+
</zones>
|
|
60
|
+
</window>
|
|
61
|
+
</dashdoc>
|
|
62
|
+
ONEIMAGEDASH
|
|
63
|
+
# notes:
|
|
64
|
+
# - adding a size element to the <dashboard element will change it from automatic, e.g.
|
|
65
|
+
#
|
|
66
|
+
# <dashboard name='One Column Web Page Laptop (800w 600h)'>
|
|
67
|
+
# <style>
|
|
68
|
+
# </style>
|
|
69
|
+
# <size maxheight='600' maxwidth='800' minheight='600' minwidth='800' />
|
|
70
|
+
#
|
|
71
|
+
# - the 'name' sttributes for the window and dashboard must match
|
|
72
|
+
@type = 'columnar Image'
|
|
73
|
+
@dashnode = @oneImageDash.at_xpath('//dashboard')
|
|
74
|
+
@winnode = @oneImageDash.at_xpath('//window')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def title=(title)
|
|
78
|
+
@title = title
|
|
79
|
+
@dashnode['name'] = title
|
|
80
|
+
@winnode['name'] = title
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def image=(imageFile)
|
|
84
|
+
@image = imageFile
|
|
85
|
+
dashImageZone = @dashnode.at_xpath('.//zone[@type="bitmap"]')
|
|
86
|
+
dashImageZone['param'] = imageFile
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end # class
|
|
90
|
+
|
|
91
|
+
end # module
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Copyright (C) 2014, 2015 Chris Gerrard
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
require 'nokogiri'
|
|
17
|
+
require 'set'
|
|
18
|
+
|
|
19
|
+
module Twb
|
|
20
|
+
|
|
21
|
+
class DocDashboard
|
|
22
|
+
|
|
23
|
+
@@types = Set.new( ['h', 'horiz', 'horizontal',
|
|
24
|
+
'v', 'vert', 'vertical' ] )
|
|
25
|
+
|
|
26
|
+
attr_reader :title, :dashnode, :winnode, :type #, :panels, :autosize, :size
|
|
27
|
+
|
|
28
|
+
def title=(title)
|
|
29
|
+
@title = title
|
|
30
|
+
@dashnode['name'] = title
|
|
31
|
+
@winnode['name'] = title
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def size=(size)
|
|
35
|
+
@size = size
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def initialize type
|
|
39
|
+
dashboard = if @@types.include?(type)
|
|
40
|
+
then if type[0] == 'v'
|
|
41
|
+
then DocDashboardVert.new
|
|
42
|
+
else DocDashboardHoriz.new
|
|
43
|
+
end
|
|
44
|
+
else nil
|
|
45
|
+
end
|
|
46
|
+
return dashboard
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def to_s
|
|
50
|
+
return @title + ' :: ' + @type
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class DocDashboardWebVert < DocDashboard
|
|
56
|
+
|
|
57
|
+
attr_reader :url
|
|
58
|
+
|
|
59
|
+
def initialize
|
|
60
|
+
@oneColWebPageDash = Nokogiri::XML::Document.parse <<-ONECOlWEBDASH
|
|
61
|
+
<dashdoc>
|
|
62
|
+
<dashboard name='Single Column Web Page Automatic'>
|
|
63
|
+
<style></style>
|
|
64
|
+
<zones>
|
|
65
|
+
<zone h='100000' id='3' param='vert' type='layout-flow' w='100000' x='0' y='0'>
|
|
66
|
+
<zone h='6221' id='1' type='title' w='100000' x='0' y='0'></zone>
|
|
67
|
+
<zone h='93157' id='4' param='horz' type='layout-flow' w='100000' x='0' y='6221'>
|
|
68
|
+
<zone forceUpdate='' h='93157' id='6' param='URL' type='web' w='99655' x='0' y='6221'></zone>
|
|
69
|
+
</zone>
|
|
70
|
+
</zone>
|
|
71
|
+
</zones>
|
|
72
|
+
</dashboard>
|
|
73
|
+
<window auto-hidden='0' class='dashboard' maximized='1' name='Single Column Web Page Automatic'>
|
|
74
|
+
<zones>
|
|
75
|
+
<zone h='6221' id='1' name='' type='title' w='100000' x='0' y='0' />
|
|
76
|
+
<zone forceUpdate='' h='93157' id='5' name='' param='Web Page' type='web' w='50000' x='50000' y='6221' />
|
|
77
|
+
</zones>
|
|
78
|
+
</window>
|
|
79
|
+
</dashdoc>
|
|
80
|
+
ONECOlWEBDASH
|
|
81
|
+
# notes:
|
|
82
|
+
# - adding a size element to the <dashboard element will change it from automatic, e.g.
|
|
83
|
+
#
|
|
84
|
+
# <dashboard name='One Column Web Page Laptop (800w 600h)'>
|
|
85
|
+
# <style>
|
|
86
|
+
# </style>
|
|
87
|
+
# <size maxheight='600' maxwidth='800' minheight='600' minwidth='800' />
|
|
88
|
+
#
|
|
89
|
+
# - the 'name' sttributes for the window and dashboard must match
|
|
90
|
+
@type = 'columnar Web Page'
|
|
91
|
+
@dashnode = @oneColWebPageDash.at_xpath('//dashboard')
|
|
92
|
+
@winnode = @oneColWebPageDash.at_xpath('//window')
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def title=(title)
|
|
96
|
+
@title = title
|
|
97
|
+
@dashnode['name'] = title
|
|
98
|
+
@winnode['name'] = title
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def url=(url)
|
|
102
|
+
dashwebzone = @dashnode.at_xpath('.//zone[@type="web"]')
|
|
103
|
+
dashwebzone['param'] = url # unless dashwebzone.nil?
|
|
104
|
+
winwebzone = @winnode.at_xpath('.//zone[@type="web"]')
|
|
105
|
+
winwebzone['param'] = url # unless winwebzone.nil?
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def url
|
|
109
|
+
dashurl = @dashnode.at_xpath('.//zone[@type="web"]').attribute('param').value
|
|
110
|
+
winurl = @winnode.at_xpath( './/zone[@type="web"]').attribute('param').value
|
|
111
|
+
@url = if dashurl == winurl then dashurl end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
class DocDashboardWebHoriz < DocDashboard
|
|
117
|
+
def initialize
|
|
118
|
+
@type = 'horizontal'
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
data/lib/twb/field.rb
CHANGED
|
@@ -31,7 +31,7 @@ module Twb
|
|
|
31
31
|
@caption = @node.attr('caption')
|
|
32
32
|
@aggregation = @node.attr('aggregation')
|
|
33
33
|
@uiname = if @caption.nil? || @caption == '' then @name.gsub(/^\[/,'').gsub(/\]$/,'') else @caption end
|
|
34
|
-
puts "\t\t - n:#{@name} \t c:#{@caption} \t n:#{@uiname}"
|
|
34
|
+
#puts "\t\t - n:#{@name} \t c:#{@caption} \t n:#{@uiname}"
|
|
35
35
|
return self
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Copyright (C) 2012, 2015 Chris Gerrard
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
module Twb
|
|
17
|
+
module Util
|
|
18
|
+
|
|
19
|
+
class DotFileRenderer
|
|
20
|
+
@@gvDotLocation = 'C:\\tech\\graphviz\\Graphviz2.38\\bin\\dot.exe'
|
|
21
|
+
@@renderTypes = ['pdf', 'png', 'svg']
|
|
22
|
+
|
|
23
|
+
def initialize
|
|
24
|
+
@gvDotLocation = @@gvDotLocation
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def gvDotLocation=(location)
|
|
28
|
+
@gvDotLocation = location
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def renderAll(dotFile)
|
|
32
|
+
renderedFiles = []
|
|
33
|
+
@@renderTypes.each do |type|
|
|
34
|
+
renderedFiles << render(dotFile,type)
|
|
35
|
+
end
|
|
36
|
+
return renderedFiles
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def render(dotFile, type)
|
|
40
|
+
type = type.downcase
|
|
41
|
+
if @@renderTypes.include?(type)
|
|
42
|
+
typeParam = '-T' + type
|
|
43
|
+
renderedFile = dotFile.sub(/.dot$/,'') + '.' + type
|
|
44
|
+
renderedFileParam = '-o' + renderedFile
|
|
45
|
+
#puts "\t <render cmd> system #{@gvDotLocation}, #{typeParam}, #{renderedFileParam}, #{dotFile} "
|
|
46
|
+
system @gvDotLocation, typeParam, renderedFileParam, dotFile
|
|
47
|
+
end
|
|
48
|
+
return renderedFile
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end # module Util
|
|
53
|
+
end # module Twb
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Copyright (C) 2012, 2015 Chris Gerrard
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
module Twb
|
|
17
|
+
module Util
|
|
18
|
+
|
|
19
|
+
class TwbDashSheetDataDotBuilder
|
|
20
|
+
|
|
21
|
+
@@dotHeader = <<-DOTHEADER
|
|
22
|
+
digraph g {
|
|
23
|
+
graph [rankdir="LR" splines="line"];
|
|
24
|
+
node [shape="box" width="2"];
|
|
25
|
+
|
|
26
|
+
"Tableau Tools generated Workbook map" [color="white" border="0"];
|
|
27
|
+
DOTHEADER
|
|
28
|
+
|
|
29
|
+
@@dotFooter = <<-DOTFOOTER
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
subgraph cluster_0 {
|
|
33
|
+
color=white;
|
|
34
|
+
node [shape="box3d" style="filled" ];
|
|
35
|
+
"Workbook" -> "Dashboard" -> "Worksheet" -> "Data Source"
|
|
36
|
+
"Workbook" "Dashboard";
|
|
37
|
+
"Worksheet";
|
|
38
|
+
"Data Source";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
DOTFOOTER
|
|
43
|
+
|
|
44
|
+
attr_reader :workbook, :dotFile, :dotFileName, :dashCount, :sheetCount, :dataSourceCount
|
|
45
|
+
|
|
46
|
+
def initialize twb
|
|
47
|
+
@workbook = if twb.instance_of?(Twb::Workbook)
|
|
48
|
+
then twb
|
|
49
|
+
else Twb::Workbook.new(twb)
|
|
50
|
+
end
|
|
51
|
+
@dashCount = @workbook.dashboards.length
|
|
52
|
+
@worksheets = @workbook.worksheetNames
|
|
53
|
+
@sheetCount = @worksheets.length
|
|
54
|
+
@datasources = @workbook.datasourceUINames
|
|
55
|
+
@dataSourceCount = @datasources.length
|
|
56
|
+
pairs = processDashboards
|
|
57
|
+
pairs += processWorksheets
|
|
58
|
+
pairs += processOrphans
|
|
59
|
+
initDot
|
|
60
|
+
buildBody(pairs)
|
|
61
|
+
sameRank([@workbook.name] )
|
|
62
|
+
sameRank( @workbook.dashboards.keys )
|
|
63
|
+
sameRank( @workbook.worksheetNames )
|
|
64
|
+
sameRank( @workbook.datasourceNames )
|
|
65
|
+
buildHeader
|
|
66
|
+
labelDataSources
|
|
67
|
+
closeDot
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def initDot
|
|
71
|
+
@dotFileName = @workbook.name + '.dot'
|
|
72
|
+
# @dotFileName = gsub(/ /,'_')
|
|
73
|
+
@dotFile = File.open(@dotFileName,'w')
|
|
74
|
+
@dotFile.puts @@dotHeader
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def buildBody(pairs)
|
|
78
|
+
@dotFile.puts "\n subgraph cluster_1 {"
|
|
79
|
+
@dotFile.puts " color= grey;"
|
|
80
|
+
@dotFile.puts ""
|
|
81
|
+
pairs.each { |pair| @dotFile.puts " \"#{pair[0]}\" -> \"#{pair[1]}\" " }
|
|
82
|
+
@dotFile.puts ""
|
|
83
|
+
@dotFile.puts " }"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def sameRank(elements)
|
|
87
|
+
@dotFile.puts "\n {rank=same "
|
|
88
|
+
elements.each do |e|
|
|
89
|
+
@dotFile.puts " \"#{e}\""
|
|
90
|
+
end
|
|
91
|
+
@dotFile.puts " }"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def buildHeader
|
|
95
|
+
@dotFile.puts ''
|
|
96
|
+
@dotFile.puts ' subgraph cluster_0 {'
|
|
97
|
+
@dotFile.puts ' color=white;'
|
|
98
|
+
@dotFile.puts ' node [shape="box3d" style="filled" ];'
|
|
99
|
+
@dotFile.puts ' "Workbook" -> "Dashboard" -> "Worksheet" -> "Data Source"'
|
|
100
|
+
@dotFile.puts ' }'
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def labelDataSources
|
|
104
|
+
@dotFile.puts " "
|
|
105
|
+
dataSources = @workbook.datasources
|
|
106
|
+
dataSources.each do |name,ds|
|
|
107
|
+
@dotFile.puts " \"#{name}\" [label=\"#{ds.uiname}\"];"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def closeDot
|
|
112
|
+
@dotFile.puts ' '
|
|
113
|
+
#@dotFile.puts '// -------------------------------------------------------------'
|
|
114
|
+
@dotFile.puts '}'
|
|
115
|
+
@dotFile.close
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def processDashboards
|
|
119
|
+
pairs = []
|
|
120
|
+
@workbook.dashboards.each do |dashName,dash|
|
|
121
|
+
pairs << [@workbook.name,dashName]
|
|
122
|
+
sheets = dash.worksheets
|
|
123
|
+
sheets.each do |sheetName,sheet|
|
|
124
|
+
pairs << [dashName,sheetName]
|
|
125
|
+
@worksheets.delete sheetName
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
return pairs
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def processWorksheets
|
|
132
|
+
pairs = []
|
|
133
|
+
worksheets = @workbook.worksheets
|
|
134
|
+
worksheets.each do |sheetName,sheet|
|
|
135
|
+
datasources = sheet.datasources
|
|
136
|
+
datasources.each do |dsName,ds|
|
|
137
|
+
pairs << [sheetName,ds.name]
|
|
138
|
+
@datasources.delete ds.uiname
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
return pairs
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def processOrphans
|
|
145
|
+
pairs = []
|
|
146
|
+
@datasources.each { |dsn| pairs << [@workbook.name,dsn] }
|
|
147
|
+
@worksheets.each { |wsn| pairs << [@workbook.name,wsn] }
|
|
148
|
+
return pairs
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
end
|
|
154
|
+
end
|