tableauworkbook 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/GemTest.rb +7 -0
  2. data/lib/tableauworkbook.rb +59 -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,59 @@
1
+ require 'nokogiri'
2
+ require 'zip'
3
+ require 'digest/md5'
4
+
5
+ class Workbook
6
+
7
+ attr_reader :name, :dir, :modtime, :version, :build, :ndoc
8
+
9
+ def initialize twbWithDir
10
+ file = File.new(twbWithDir)
11
+ @name = File.basename(twbWithDir)
12
+ @dir = File.dirname(File.expand_path(twbWithDir))
13
+ @modtime = File.new(twbWithDir).mtime
14
+ @ndoc = Nokogiri::XML(open(twbWithDir))
15
+ @version = @ndoc.xpath('/workbook/@version')
16
+ @build = @ndoc.xpath('/workbook/comment()').text.gsub(/^[^0-9]+/,'').strip
17
+ end
18
+
19
+ end #class Workbook
20
+
21
+
22
+ # Tableau Workbook <datasource XML node
23
+ # =====================================
24
+ class DataSource
25
+
26
+ @@hasher = Digest::SHA256.new
27
+
28
+ attr_reader :node, :name, :caption, :uiname, :connHash, :class, :connection
29
+
30
+ def initialize dataSourceNode
31
+ @node = dataSourceNode
32
+ @name = @node.xpath('./@name').text
33
+ @caption = @node.xpath('./@caption').text
34
+ @uiname = if @caption.nil? || @caption == '' then @name else @caption end
35
+ # puts "DS: n:#{@name}"
36
+ # puts " caption:#{@caption}"
37
+ # puts " c.len :#{@caption.length}"
38
+ # puts " c.nil?:#{@caption.nil?}"
39
+ # puts " uiname:#{@uiname}"
40
+ # puts " "
41
+ processConnection
42
+ end
43
+
44
+ def processConnection
45
+ @connHash = ''
46
+ @connection = @node.at_xpath('./connection')
47
+ if !@connection.nil? then
48
+ @class = @connection.attribute('class').text
49
+ dsAttributes = @node.xpath('./connection/@*')
50
+ dsConnStr = ''
51
+ dsAttributes.each do |attr|
52
+ dsConnStr += attr.text
53
+ # Note: only collects non-'' attribute values
54
+ end
55
+ @connHash = Digest::MD5.hexdigest(dsConnStr)
56
+ end
57
+ end
58
+
59
+ end #class DataSource
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tableauworkbook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
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: []