twb 0.0.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.
Files changed (3) hide show
  1. data/lib/GemTest.rb +7 -0
  2. data/lib/tableauworkbook.rb +67 -0
  3. metadata +47 -0
data/lib/GemTest.rb ADDED
@@ -0,0 +1,7 @@
1
+ class GemTest
2
+
3
+ def self.speak
4
+ puts "GemTest here.\narf!"
5
+ end
6
+
7
+ end
@@ -0,0 +1,67 @@
1
+ require 'nokogiri'
2
+ require 'zip'
3
+ require 'digest/md5'
4
+
5
+ class GemTestInner
6
+
7
+ def self.speak
8
+ puts "GemTest here.\narf!"
9
+ end
10
+
11
+ end
12
+
13
+ class Workbook
14
+
15
+ attr_reader :name, :dir, :modtime, :version, :build, :ndoc
16
+
17
+ def initialize twbWithDir
18
+ file = File.new(twbWithDir)
19
+ @name = File.basename(twbWithDir)
20
+ @dir = File.dirname(File.expand_path(twbWithDir))
21
+ @modtime = File.new(twbWithDir).mtime
22
+ @ndoc = Nokogiri::XML(open(twbWithDir))
23
+ @version = @ndoc.xpath('/workbook/@version')
24
+ @build = @ndoc.xpath('/workbook/comment()').text.gsub(/^[^0-9]+/,'').strip
25
+ end
26
+
27
+ end #class Workbook
28
+
29
+
30
+ # Tableau Workbook <datasource XML node
31
+ # =====================================
32
+ class DataSource
33
+
34
+ @@hasher = Digest::SHA256.new
35
+
36
+ attr_reader :node, :name, :caption, :uiname, :connHash, :class, :connection
37
+
38
+ def initialize dataSourceNode
39
+ @node = dataSourceNode
40
+ @name = @node.xpath('./@name').text
41
+ @caption = @node.xpath('./@caption').text
42
+ @uiname = if @caption.nil? || @caption == '' then @name else @caption end
43
+ # puts "DS: n:#{@name}"
44
+ # puts " caption:#{@caption}"
45
+ # puts " c.len :#{@caption.length}"
46
+ # puts " c.nil?:#{@caption.nil?}"
47
+ # puts " uiname:#{@uiname}"
48
+ # puts " "
49
+ processConnection
50
+ end
51
+
52
+ def processConnection
53
+ @connHash = ''
54
+ @connection = @node.at_xpath('./connection')
55
+ if !@connection.nil? then
56
+ @class = @connection.attribute('class').text
57
+ dsAttributes = @node.xpath('./connection/@*')
58
+ dsConnStr = ''
59
+ dsAttributes.each do |attr|
60
+ dsConnStr += attr.text
61
+ # Note: only collects non-'' attribute values
62
+ end
63
+ @connHash = Digest::MD5.hexdigest(dsConnStr)
64
+ end
65
+ end
66
+
67
+ end #class DataSource
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Gerrard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-03-07 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Classes for accessing Tableau Workbooks and their contents
15
+ email: Chris@Gerrard.net
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/tableauworkbook.rb
21
+ - lib/GemTest.rb
22
+ homepage: http://rubygems.org/gems/tableauwokbook
23
+ licenses:
24
+ - MIT
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 1.8.16
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: Classes for accessing Tableau Workbooks and their contents.
47
+ test_files: []