twb 1.0.5 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/twb.rb +10 -6
- data/lib/twb/analysis/CalculatedFields/CSVEmitter.rb +154 -0
- data/lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb +527 -0
- data/lib/twb/analysis/CalculatedFields/MarkdownEmitter.rb +71 -0
- data/lib/twb/analysis/DataSources/DataSourceTableFieldsCSVEmitter.rb +117 -0
- data/lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb +192 -0
- data/lib/twb/calculatedfield.rb +47 -0
- data/lib/twb/columnfield.rb +94 -0
- data/lib/twb/dashboard.rb +1 -1
- data/lib/twb/datasource.rb +368 -121
- data/lib/twb/fieldcalculation.rb +157 -81
- data/lib/twb/localfield.rb +32 -29
- data/lib/twb/metadatafield.rb +57 -15
- data/lib/twb/util/ftpPublisher.rb +48 -0
- data/lib/twb/util/joinUtilities.rb +52 -0
- data/lib/twb/workbook.rb +27 -10
- data/lib/twb/worksheet.rb +146 -53
- metadata +11 -5
- data/lib/twb/analysis/calculatedfieldsanalyzer.rb +0 -508
- data/lib/twb/apps/X-Ray Dashboards.rb +0 -80
- data/lib/twb/countNodes.rb +0 -98
@@ -1,80 +0,0 @@
|
|
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 'twb'
|
17
|
-
|
18
|
-
system "cls"
|
19
|
-
|
20
|
-
$doctwb = true
|
21
|
-
$replacetwb = false # true|false - replace/new name TWB
|
22
|
-
$dashdoclbl = 'dashdoc'
|
23
|
-
$localurl = 'file:///' + Dir.pwd + '/' # for Dashboard Web Page objects
|
24
|
-
|
25
|
-
def xray twbname
|
26
|
-
twb = Twb::Workbook.new(twbname)
|
27
|
-
xrayer = Twb::DashboardXRayer.new(twb)
|
28
|
-
xrays = xrayer.xray
|
29
|
-
cnt = 0
|
30
|
-
xrays.each do |dash, html|
|
31
|
-
htmlfilename = twb.name + '.' + dash.to_s + '.html'
|
32
|
-
saveHTML(htmlfilename, html)
|
33
|
-
cnt += 1
|
34
|
-
if $doctwb
|
35
|
-
inject(twb, dash.to_s, htmlfilename)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
puts "\t #{cnt} \t #{twbname}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def saveHTML(htmlfilename, html)
|
42
|
-
begin
|
43
|
-
htmlfile = File.open(htmlfilename, 'w')
|
44
|
-
htmlfile.puts html
|
45
|
-
htmlfile.close
|
46
|
-
rescue
|
47
|
-
# Common failure is when the Dashboard name contains
|
48
|
-
# invalid file name Characters. or when the name is
|
49
|
-
# an invalid file name.
|
50
|
-
# Stripping the non-ASCII characters from the Dashboard
|
51
|
-
# name fixes this, in the cases seen so far.
|
52
|
-
# This rescue-recursion technique can potentially cause
|
53
|
-
# an infite-loop condition. (not seen, but possible)
|
54
|
-
saveHTML( sanitize(htmlfilename), html)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def inject(twb, dashboard, htmlfilename)
|
59
|
-
vDash = Twb::DocDashboardWebVert.new
|
60
|
-
vDash.title=('Doc Dashboard: ' + sanitize(dashboard))
|
61
|
-
vDash.url=($localurl + '/' + htmlfilename)
|
62
|
-
twb.addDocDashboard(vDash)
|
63
|
-
if $replacetwb
|
64
|
-
twb.write
|
65
|
-
else
|
66
|
-
twb.writeAppend($dashdoclbl)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def sanitize(str)
|
71
|
-
str.gsub(/[^a-z0-9\-]+/i, ' ')
|
72
|
-
end
|
73
|
-
|
74
|
-
system 'cls'
|
75
|
-
puts "\n\n\t X-raying Dashboards"
|
76
|
-
puts "\n\n\t # Dashboards Workbook"
|
77
|
-
puts "\n\t ------------ ----------------------"
|
78
|
-
|
79
|
-
path = if ARGV.empty? then '*.twb' else ARGV[0] end
|
80
|
-
Dir.glob(path) {|twb| xray twb }
|
data/lib/twb/countNodes.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
require 'csv'
|
3
|
-
require 'twb'
|
4
|
-
|
5
|
-
def init
|
6
|
-
system 'cls'
|
7
|
-
$pFile = File.open('sqlFromTwbDc.txt','w')
|
8
|
-
|
9
|
-
sqiCSV = 'TWBFieldsByType.csv'
|
10
|
-
$fieldsCSV = CSV.open(sqiCSV, 'w')
|
11
|
-
$fieldsCSV << [
|
12
|
-
'TWB',
|
13
|
-
'Data Connection - UI',
|
14
|
-
'Field Name',
|
15
|
-
'Field Type',
|
16
|
-
]
|
17
|
-
$path = if ARGV.empty? then '**/*.twb' else ARGV[0] end
|
18
|
-
emit " "
|
19
|
-
emit " Generating SQL Create Table code for Tableau Workbook Data Connections (TWDCs)."
|
20
|
-
emit " Each TWDC will have it's own *.sql file containing the SQL code.\n "
|
21
|
-
emit " Looking for Workbooks matching: '#{$path}' - from: #{ARGV[0]}\n\n "
|
22
|
-
end
|
23
|
-
|
24
|
-
def method_name
|
25
|
-
datasources = {}
|
26
|
-
dataSourcesNode = doc.at_xpath('//workbook/datasources')
|
27
|
-
dataSourcesNodes = doc.xpath('//workbook/datasources/datasource').to_a
|
28
|
-
puts " dsn: #{dataSourcesNodes}"
|
29
|
-
datasourceNodes.each do |node|
|
30
|
-
datasource = Twb::DataSource.new(node)
|
31
|
-
datasources[datasource.name] = datasource
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
$localEmit = true
|
36
|
-
def emit stuff
|
37
|
-
$pFile.puts stuff
|
38
|
-
puts stuff if $localEmit
|
39
|
-
end
|
40
|
-
|
41
|
-
$paths = {
|
42
|
-
'Relation Columns' => './connection/relation/columns/column',
|
43
|
-
'Metadata Records' => './connection/metadata-records/metadata-record',
|
44
|
-
'Columns' => './column',
|
45
|
-
}
|
46
|
-
|
47
|
-
def proc file
|
48
|
-
emit "\n == #{file}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def process file
|
52
|
-
emit "\n == #{file}"
|
53
|
-
doc = Nokogiri::XML(open(file))
|
54
|
-
dataSourcesNodes = doc.xpath('//workbook/datasources/datasource')
|
55
|
-
dataSourcesNodes.each do |ds|
|
56
|
-
emit "\n dc: #{ds.attribute('caption')}"
|
57
|
-
emit " dn: #{ds.attribute('name')}\n ---"
|
58
|
-
typeCounts = {}
|
59
|
-
$paths.each do |type, path|
|
60
|
-
nodes = ds.xpath(path).to_a
|
61
|
-
# emit " : %3i %-17s %-s" % [nodes.size, type, path]
|
62
|
-
typeCnt = nodes.size
|
63
|
-
nodes.each do |n|
|
64
|
-
$fieldsCSV << [file,ds.attribute('name'),n.attribute('name'),type]
|
65
|
-
end
|
66
|
-
if type == 'Columns' then
|
67
|
-
calcCnt = 0
|
68
|
-
nodes.each do |n|
|
69
|
-
calc = n.xpath('./calculation')
|
70
|
-
# emit " c: #{calc.size} "
|
71
|
-
calcCnt += calc.size
|
72
|
-
end
|
73
|
-
# emit ' ---'
|
74
|
-
# emit " c#: %3i " % [calcCnt]
|
75
|
-
# emit " !c#: %3i " % [nodes.size - calcCnt]
|
76
|
-
typeCounts['Columns'] = nodes.size
|
77
|
-
typeCounts['Columns - calc'] = calcCnt
|
78
|
-
typeCounts['Columns - not calc'] = nodes.size - calcCnt
|
79
|
-
else
|
80
|
-
typeCounts[type] = typeCnt
|
81
|
-
end
|
82
|
-
end
|
83
|
-
# emit ' ---'
|
84
|
-
typeCounts.each do |t,c|
|
85
|
-
emit " tc: %3i %-s" % [c, t]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
init
|
91
|
-
|
92
|
-
$paths.each do |path|
|
93
|
-
emit " p: #{path}"
|
94
|
-
end
|
95
|
-
|
96
|
-
Dir.glob($path) {|twb| process twb }
|
97
|
-
|
98
|
-
emit "\n\n== Done ==\n "
|