tableautools 0.0.1

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.
@@ -0,0 +1,39 @@
1
+ # TWB - The Tableau Tools Ruby gem.
2
+
3
+ This gem provides a collection of classes to manage Tableau workbooks and their major components.
4
+ It's the result of years of writing similar code.
5
+
6
+ ## Philosophy
7
+
8
+ Tableau Workbook governance should be:
9
+ - simple and straightforward in the way that basic data analysis is simple and straightforward in Tableau,
10
+ - free, as in beer and speech, and
11
+ - constantly evolving to incorporate new and interesting things people can think of to see about do with their Workbooks.
12
+
13
+ Tableau Tools are designed in the model of mini-tools, small independent tools that are individually useful and can be
14
+ used together to accomplish broader tasks.
15
+
16
+ The gem is released to the Tableau community in the hope that it will prove to be useful and valuable,
17
+ that people will build useful things with it, and that they will offer improvements and extensions to it.
18
+
19
+ ## History and rationale
20
+
21
+ A number of Ruby scripts that parse Workbooks and emit a variety of their contents/properties have been published at Tableau Friction, including a couple that identify Calculated fields and the fields they reference:
22
+ http://tableaufriction.blogspot.ca/2015/02/more-calculated-field-analysis-fields.html
23
+ http://tableaufriction.blogspot.ca/2014/09/do-you-know-what-your-calculated-fields.html
24
+
25
+ Other scripts find and record other useful information, still others enable Workbook management, e.g. unhiding worksheets and making field comments consistent across workbook.
26
+ One of them produces HTML pages with dynamic dashboard wire frames, making it easy to see what's in the dashboards and their properties
27
+
28
+
29
+ ## Historical: TWIS - The Tableau Workbook Inventory System
30
+ There's also TWIS - the Tableau Workbook Inventory System, an application that parses workbooks and extracts most of their
31
+ important elements into CSV files, allowing one to see things such as which sheets are in which with dashboards,
32
+ the data sources they connect to, and which Workbooks they're in.
33
+ TWIS also generates diagrams/maps of the Workbook - Dashboard - Worksheet - Data Source relationships, one for each Workbook in PDF, PNG, and SVG.
34
+
35
+ TWIS is described and available here: http://betterbi.biz/TWIS.html
36
+
37
+ #### TWIS is deprecated, no longer maintained
38
+
39
+ I created TWIS in Java, beginning in 2007. It was very valuable but became exceedingly difficult to maintain.
@@ -0,0 +1,22 @@
1
+ # Copyright (C) 2014, 2018 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_relative 'tableautools/utilities/anonymizer'
17
+
18
+ # Represents Tableau Workbooks and their contents.
19
+ #
20
+ module TableauTools
21
+ VERSION = '0.0.1'
22
+ end
@@ -0,0 +1,86 @@
1
+ require 'csv'
2
+
3
+ module TableauTools
4
+
5
+ class Anonymizer
6
+
7
+ attr_reader :anonWords, :low, :high
8
+ attr_accessor :input, :output, :field
9
+
10
+ @minWords = 2
11
+ @maxWords = 4
12
+
13
+ @@anonymousText = <<ANONTEXT
14
+ Lorem ipsum dolor sit amet consectetur adipiscing elit Mauris urna erat volutpat a ullamcorper sit amet
15
+ convallis quis dui Ut sem erat euismod in iaculis id tincidunt aliquam magna Vivamus lobortis eu erat in feugiat
16
+ Vestibulum fermentum dictum fermentum Class aptent taciti sociosqu ad litora torquent per conubia nostra
17
+ per inceptos himenaeos Ut quis rutrum mi Mauris sit amet cursus nisi Suspendisse accumsan leo ac lobortis egestas
18
+ sapien eros mattis lorem eu posuere mi justo in nunc Sed felis ligula egestas vel nulla sed egestas lobortis justo
19
+ Donec quis interdum velit Proin felis arcu vestibulum non augue nec ultricies pulvinar velit Nunc ac libero velit
20
+ Aenean bibendum varius nisi ut molestie Nam tempus nec lacus eget malesuada Donec et accumsan dolor et ullamcorper ante
21
+ Etiam quis consectetur leo Suspendisse mattis sagittis imperdiet Phasellus facilisis eget justo ac mollis
22
+ Phasellus eleifend tortor est sit amet venenatis enim fringilla id Vestibulum rutrum tempus tortor ac volutpat
23
+ Nullam non imperdiet lorem Cras tincidunt porttitor condimentum Pellentesque tincidunt magna id aliquet interdum augue
24
+ nisl convallis enim volutpat mollis urna metus et lacus Donec tortor sapien ultrices sit amet blandit quis gravida ut
25
+ massa Mauris mauris lacus pretium sit amet risus quis blandit viverra lorem Nunc fringilla elit a elementum gravida
26
+ Duis vel sodales elit eget tempor leo Quisque in semper nisl Fusce eget risus sollicitudin molestie diam et tincidunt
27
+ sem Curabitur accumsan pretium interdum Suspendisse semper enim ac augue hendrerit vel sollicitudin diam mollis
28
+ Curabitur lacinia ante nec eros maximus a vehicula velit aliquet In ullamcorper nec ante eu dictum Proin mi enim
29
+ malesuada ut ornare sit amet maximus commodo ipsum Nullam venenatis purus non sollicitudin sollicitudin augue
30
+ augue euismod lorem ut hendrerit velit neque sed nibh Class aptent taciti sociosqu ad litora torquent per conubia
31
+ nostra per inceptos himenaeos Proin ac elementum nisl
32
+ ANONTEXT
33
+
34
+ @codedWords = {}
35
+
36
+ def initialize
37
+ @anonWords = @@anonymousText.gsub(/\n/,' ').split
38
+ @coded = {}
39
+ @low = 0
40
+ @limit = @anonWords.length-1
41
+ @rand = Random.new
42
+ @minWords = 2
43
+ @maxWords = 4
44
+ end
45
+
46
+ def anonymize(input, fields, output)
47
+ puts "Anonymizing %-25s to %-25s - %s " % [input, output, fields.inspect]
48
+ raise 'The input file must be specified' if input.nil?
49
+ raise 'The input file must exist' unless File.exist?(input)
50
+ raise 'The field(s) to anonymize must be provided as a String or an array of Strings' unless fields.instance_of?(String) || fields.instance_of?(Array)
51
+ @input = input
52
+ @output = output
53
+ @anonVals = {}
54
+ csvFields = CSV.open(@input, &:readline)
55
+ output = CSV.open(@output,'w')
56
+ output << csvFields
57
+ fields = [fields] if fields.is_a? String
58
+ CSV.foreach('input.csv', :headers => true) do |row|
59
+ fields.each do |field|
60
+ row[field] = anonWords(row[field]) unless row[field].nil?
61
+ end
62
+ output << row
63
+ end
64
+ end
65
+
66
+ def anonWords value
67
+ return @anonVals[value] unless @anonVals[value].nil?
68
+ range = rand(@minWords..@maxWords)
69
+ limit = @limit - range
70
+ first = rand(range..limit)
71
+ last = first + range - 1
72
+ words = @anonWords[first..last].join(' ')
73
+ @anonVals[value] = words
74
+ end
75
+
76
+ def codeValue value
77
+ if @codedWords[value].nil?
78
+ @codedWords[value] = anonWords
79
+ end
80
+ @codedWords[value]
81
+ end
82
+
83
+
84
+ end # class Anonymizer
85
+
86
+ end # module utility
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tableautools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Gerrard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A collection of Ruby classes designed for accessing and recording information
14
+ about, producing documentation about, and for manipulating Tableau Workbooks and
15
+ their contents.
16
+ email: Chris@Gerrard.net
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE.md
22
+ - LICENSE.txt
23
+ - README.md
24
+ - lib/tableautools.rb
25
+ - lib/tableautools/utilities/anonymizer.rb
26
+ homepage: http://rubygems.org/gems/tableautools
27
+ licenses:
28
+ - GPL-3.0
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.6.13
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Classes for analyzing, documenting, and managing Tableau Workbooks.
50
+ test_files: []