twb 0.0.35 → 0.0.36

Sign up to get free protection for your applications and to get access to all the features.
data/lib/twb.rb CHANGED
@@ -13,6 +13,6 @@ require_relative 'twb/util/xraydashboards'
13
13
  # Represents Tableau Workbooks and their contents.
14
14
  #
15
15
  module Twb
16
- VERSION = '0.0.35'
16
+ VERSION = '0.0.36'
17
17
  end
18
18
 
@@ -0,0 +1,65 @@
1
+ # X-Ray Dashboards.rb - this Ruby script Copyright 2013-2015 Christopher Gerrard
2
+
3
+ require 'twb'
4
+
5
+ system "cls"
6
+
7
+ $doctwb = true
8
+ $replacetwb = false
9
+ $dashdoclbl = 'dashdoc'
10
+ $localurl = 'file:///' + Dir.pwd + '/'
11
+
12
+ def xray twbname
13
+ twb = Twb::Workbook.new(twbname)
14
+ xrayer = Twb::DashboardXRayer.new(twb)
15
+ xrays = xrayer.xray
16
+ cnt = 0
17
+ xrays.each do |dash, html|
18
+ htmlfilename = twb.name + '.' + dash.to_s + '.html'
19
+ saveHTML(htmlfilename, html)
20
+ cnt += 1
21
+ if $doctwb
22
+ inject(twb, dash.to_s, htmlfilename)
23
+ end
24
+ end
25
+ puts "\t #{cnt} \t #{twbname}"
26
+ end
27
+
28
+ def saveHTML(htmlfilename, html)
29
+ begin
30
+ htmlfile = File.open(htmlfilename, 'w')
31
+ htmlfile.puts html
32
+ htmlfile.close
33
+ rescue
34
+ # Common failure is when the Dashboard name contains
35
+ # invalid file name Characters. or when the name is
36
+ # an invalid file name.
37
+ # Stripping the non-ASCII characters from the Dashboard
38
+ # name fixes this, in the cases see so far.
39
+ # This rescue-recursion technique can potentially cause
40
+ # an infite-loop condition. (not seen, but possible)
41
+ saveHTML( sanitize(htmlfilename), html)
42
+ end
43
+ end
44
+
45
+ def inject(twb, dashboard, htmlfilename)
46
+ vDash = Twb::DocDashboardWebVert.new
47
+ vDash.title=('Doc Dashboard: ' + sanitize(dashboard))
48
+ vDash.url=($localurl + '/' + htmlfilename)
49
+ twb.addDocDashboard(vDash)
50
+ if $replacetwb
51
+ twb.write
52
+ else
53
+ twb.writeAppend($dashdoclbl)
54
+ end
55
+ end
56
+
57
+ def sanitize(str)
58
+ str.gsub(/[^a-z0-9\-]+/i, ' ')
59
+ end
60
+
61
+ system 'cls'
62
+ puts "\n\n\t X-raying Dashboards\n\n\t # Dashboards Workbook\n\t ------------ ----------------------"
63
+
64
+ path = if ARGV.empty? then '*.twb' else ARGV[0] end
65
+ Dir.glob(path) {|twb| xray twb }
@@ -46,7 +46,14 @@ module Twb
46
46
  @@shapeDiam = 2*@@shapeRadius
47
47
 
48
48
  @@htmlTableLead = '<p style="font: normal 12px Verdana, Calibri, Geneva, sans-serif; color: #000000;">The Dashboard\'s panels, one per row.<br />Mousing over the table highlights the Dashboard\'s panels in the diagram.</p>'
49
- @@htmlTableFNote = '<p><span style="font: normal 12px Verdana, Calibri, Geneva, sans-serif; color: #000000;">Note: the Dashboard\'s \'x\', \'y\', \'w\', and \'h\' values are shown as coded in the<br />Tableau Workbook. It appears that the maximum value &ndash;100,000&ndash; indicates<br />that the Dashboard size is set to Automatic.</span></p>'
49
+ @@htmlTableFNote = <<-TABLEFNOTE
50
+ <p><span style="font: normal 12px Verdana, Calibri, Geneva, sans-serif; color: #000000;">
51
+ Note: the Dashboard\'s \'x\', \'y\', \'w\', and \'h\' values are shown as coded in the<br />Tableau Workbook.
52
+ It appears that the maximum value &ndash;100,000&ndash; indicates<br />
53
+ that the Dashboard size is set to Automatic, or Range with no upper limit.
54
+ </span>
55
+ </p>
56
+ TABLEFNOTE
50
57
 
51
58
  @maxSVGDim = 600.0 # need the decimal for dashboard scaling with svgScale in fn termDashSVG
52
59
  @maxDashWidth = 1.0
data/twb-0.0.35.gem ADDED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - bg.cmd
21
21
  - bin/twb.rb
22
+ - lib/twb/apps/X-Ray Dashboards.rb
22
23
  - lib/twb/dashboard.rb
23
24
  - lib/twb/dashboard.txt
24
25
  - lib/twb/datasource.rb
@@ -54,6 +55,7 @@ files:
54
55
  - twb-0.0.32.gem
55
56
  - twb-0.0.33.gem
56
57
  - twb-0.0.34.gem
58
+ - twb-0.0.35.gem
57
59
  - twb.gemspec
58
60
  homepage: http://rubygems.org/gems/twb
59
61
  licenses: