twb 0.0.26 → 0.0.27

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/lib/twb/dashboard.rb CHANGED
@@ -25,6 +25,7 @@ module Twb
25
25
  attr_reader :node, :name, :sheets
26
26
 
27
27
  def initialize dashboardNode
28
+ "initialize Dashboard"
28
29
  @node = dashboardNode
29
30
  @name = @node.attr('name')
30
31
  loadSheets
@@ -26,8 +26,8 @@ module Twb
26
26
 
27
27
  def initialize dataSourceNode
28
28
  @node = dataSourceNode
29
- @name = @node.xpath('./@name').text
30
- @caption = @node.xpath('./@caption').text
29
+ @name = @node.attr('name')
30
+ @caption = @node.attr('caption')
31
31
  @uiname = if @caption.nil? || @caption == '' then @name else @caption end
32
32
  processConnection
33
33
  return self
@@ -0,0 +1,44 @@
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 'digest/md5'
18
+
19
+ module Twb
20
+
21
+ class Storyboard
22
+
23
+ @@hasher = Digest::SHA256.new
24
+
25
+ attr_reader :node, :name, :sheets
26
+
27
+ def initialize node
28
+ # puts "initialize Storyboard"
29
+ @node = node
30
+ @name = @node.attr('name')
31
+ loadSheets
32
+ end
33
+
34
+ def loadSheets
35
+ @sheets = []
36
+ sheets = @node.xpath('.//story-point').to_a
37
+ sheets.each do |node|
38
+ @sheets.push node.attr('captured-sheet')
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
data/lib/twb/workbook.rb CHANGED
@@ -20,7 +20,7 @@ module Twb
20
20
 
21
21
  class Workbook
22
22
 
23
- attr_reader :name, :dir, :modtime, :version, :build, :ndoc, :dataSources, :dashboards
23
+ attr_reader :name, :dir, :modtime, :version, :build, :ndoc, :datasources, :dashboards, :storyboards, :worksheets
24
24
 
25
25
  def initialize twbWithDir
26
26
  file = File.new(twbWithDir)
@@ -30,28 +30,101 @@ module Twb
30
30
  @ndoc = Nokogiri::XML(open(twbWithDir))
31
31
  @version = @ndoc.xpath('/workbook/@version')
32
32
  @build = @ndoc.xpath('/workbook/comment()').text.gsub(/^[^0-9]+/,'').strip
33
+ loaddatasources
33
34
  loadDashboards
34
- loadDataSources
35
- return self
35
+ loadStoryboards
36
+ loadWorksheets
37
+ return true
36
38
  end
37
39
 
38
- def loadDataSources
39
- @dataSources = []
40
- @dataSourceNodes = @ndoc.xpath('//workbook/datasources/datasource').to_a
41
- @dataSourceNodes.each do |dsn|
42
- @dataSources.push Twb::DataSource.new(dsn)
40
+ def loaddatasources
41
+ @datasources = {}
42
+ @datasourceNodes = @ndoc.xpath('//workbook/datasources/datasource').to_a
43
+ @datasourceNodes.each do |node|
44
+ datasource = Twb::DataSource.new(node)
45
+ @datasources[datasource.name] = datasource
43
46
  end
47
+ return true
44
48
  end
45
49
 
46
50
  def loadDashboards
47
- @dashboards = []
48
- @ndoc.xpath('//workbook/dashboards/dashboard').to_a.each do |dshn|
49
- @dashboards.push Twb::Dashboard.new(dshn)
51
+ @dashboards = {}
52
+ dashes = @ndoc.xpath('//workbook/dashboards/dashboard' ).to_a
53
+ dashes.each do |node|
54
+ unless node.attr('type') == 'storyboard' then
55
+ dashboard = Twb::Dashboard.new(node)
56
+ @dashboards[dashboard.name] = dashboard
57
+ end
50
58
  end
51
59
  end
52
60
 
53
- def dataSourceNodes
54
- @ndoc.xpath('//workbook/datasources/datasource').to_a
61
+ def loadStoryboards
62
+ @storyboards = {}
63
+ boards = @ndoc.xpath("//workbook/dashboards/dashboard[@type='storyboard']" ).to_a
64
+ boards.each do |node|
65
+ sheet = Twb::Storyboard.new(node)
66
+ @storyboards[sheet.name] = sheet
67
+ end
68
+ end
69
+
70
+ def loadWorksheets
71
+ @worksheets = {}
72
+ sheets = @ndoc.xpath('//workbook/worksheets/worksheet' ).to_a
73
+ sheets.each do |node|
74
+ sheet = Twb::Worksheet.new(node)
75
+ @worksheets[sheet.name] = sheet
76
+ end
77
+ end
78
+
79
+
80
+ def datasources
81
+ @datasources.values
82
+ end
83
+
84
+ def dashboards
85
+ @dashboards.values
86
+ end
87
+
88
+ def storyboards
89
+ @storyboards.values
90
+ end
91
+
92
+ def worksheets
93
+ @worksheets.values
94
+ end
95
+
96
+
97
+ def datasourceNames
98
+ @datasources.keys
99
+ end
100
+
101
+ def dashboardNames
102
+ @dashboards.keys
103
+ end
104
+
105
+ def storyboardNames
106
+ @storyboards.keys
107
+ end
108
+
109
+ def worksheetNames
110
+ @worksheets.keys
111
+ end
112
+
113
+
114
+ def datasource name
115
+ @datasources[name]
116
+ end
117
+
118
+ def dashboard name
119
+ @dashboards[name]
120
+ end
121
+
122
+ def storyboard name
123
+ @storyboards[name]
124
+ end
125
+
126
+ def worksheet name
127
+ @worksheets[name]
55
128
  end
56
129
 
57
130
  end
data/lib/twb.rb CHANGED
@@ -2,10 +2,11 @@ require_relative 'twb/workbook'
2
2
  require_relative 'twb/dashboard'
3
3
  require_relative 'twb/worksheet'
4
4
  require_relative 'twb/datasource'
5
+ require_relative 'twb/storyboard'
5
6
 
6
7
 
7
8
  module Twb
8
9
  VERSION = '0.0.1'
9
10
  end
10
11
 
11
- # puts "Version: #{Twb::VERSION}"
12
+ puts "Twb version: #{Twb::VERSION}"
data/testTwbGem.rb CHANGED
@@ -1,26 +1,41 @@
1
1
  # testTwbGem.rb - this Ruby script Copyright 2013, 2014 Christopher Gerrard
2
2
 
3
3
  require 'nokogiri'
4
- require 'open-uri'
5
4
 
6
5
  #require 'twb'
7
6
  require 'C:\tech\Tableau\tools\Ruby\gems\twb\lib\twb.rb'
8
7
 
9
8
  def processTWB twbWithDir
9
+ puts "\n\n\n== #{twbWithDir}"
10
10
  twb = Twb::Workbook.new twbWithDir
11
- puts "\n#{twb.name}"
11
+ puts "#{twb.name}"
12
12
  doc = twb.ndoc
13
+
13
14
  puts " Data Sources"
14
- twb.dataSources.each do |ds|
15
+ twb.datasources.each do |ds|
15
16
  puts "\n\t n\t-#{ds.name}\n\t :: c\t-#{ds.caption}\n\t :: uin\t-#{ds.uiname} \n\t :: ch\t-#{ds.connHash}\n\t :: prms?\t-#{ds.Parameters?} "
16
17
  end
18
+
17
19
  puts "\n Dashboards ...."
20
+ puts "\t \t-#{twb.dashboardNames}"
18
21
  twb.dashboards.each do |dsh|
19
22
  puts "\t n\t-#{dsh.name} "
20
23
  dsh.sheets.each do |sheet|
21
24
  puts "\t n\t -#{sheet.name} "
22
25
  end
23
26
  end
27
+
28
+ puts "\n Storyboards ...."
29
+ puts "\t \t-#{twb.storyboardNames}"
30
+ if twb.storyboards
31
+ twb.storyboards.each do |sb|
32
+ puts "\t n\t-#{sb.name} "
33
+ sb.sheets.each do |sheet|
34
+ puts "\t n\t -#{sheet} "
35
+ end
36
+ end
37
+ end
38
+
24
39
  end
25
40
 
26
41
  def getName techName
@@ -29,6 +44,9 @@ end
29
44
 
30
45
  puts "START"
31
46
 
32
- Dir.glob("**/TwoDashboards.twb") {|twb| processTWB twb }
47
+ path = if ARGV.empty? then '*.twb' else ARGV[0] end
48
+
49
+
50
+ Dir.glob(path) {|twb| processTWB twb }
33
51
 
34
52
  $f.close unless $f.nil?
data/twb-0.0.26.gem ADDED
Binary file
data/twb.gemspec CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
2
2
  s.name = 'twb'
3
3
  s.summary = "Classes for accessing Tableau Workbooks and their contents - summary."
4
4
  s.description = "Classes for accessing Tableau Workbooks and their contents - description"
5
- s.version = '0.0.26'
5
+ s.version = '0.0.27'
6
6
  s.date = "2015-03-14"
7
7
  s.author = "Chris Gerrard"
8
8
  s.email = "Chris@Gerrard.net"
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.26
4
+ version: 0.0.27
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -17,11 +17,11 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - bin/twb.cmd
21
20
  - bin/twb.rb
22
21
  - lib/twb/dashboard.rb
23
22
  - lib/twb/dashboard.txt
24
23
  - lib/twb/datasource.rb
24
+ - lib/twb/storyboard.rb
25
25
  - lib/twb/there.rb
26
26
  - lib/twb/TwbTest.rb
27
27
  - lib/twb/workbook.rb
@@ -37,6 +37,7 @@ files:
37
37
  - twb-0.0.23.gem
38
38
  - twb-0.0.24.gem
39
39
  - twb-0.0.25.gem
40
+ - twb-0.0.26.gem
40
41
  - twb.gemspec
41
42
  homepage: http://rubygems.org/gems/twb
42
43
  licenses:
data/bin/twb.cmd DELETED
@@ -1,3 +0,0 @@
1
- .echo TWB.cmd here
2
-
3
- ruby twb.rb