twb 4.6.0 → 4.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e049f4ada5ac7d92e8c34a843e3593a632b2c009854fa09f3c085567e7904289
4
- data.tar.gz: 423d1b5cd090535b6a60409e468df0ffd7fd28583660a5ff86c9ce9101dcfb1a
3
+ metadata.gz: 199291219b0d5c06c822c4eedce63579a9a7cf80a1c4acfc53429403aeddc7f6
4
+ data.tar.gz: c6889a7c889c8c0890bde9f6e9e8b8a016af6a319d75dc3634d266ce36a7cbab
5
5
  SHA512:
6
- metadata.gz: a814663aa667f6af9e62bff76c3bedf7497eb248e8883e1cbfa09a2631f8cf51a3714929c98f852f5c328f66d9a022c8f0df28c767e39e90ce860cd311cb99a3
7
- data.tar.gz: 6bcd9e6d20bab6ca85dfc6d954c99d711dc4475784068c8d7598a4f718a2fc446d90d277c03924b122a402fddd06b594efb93ec827668694bdfd3aeb865d9c84
6
+ metadata.gz: 74f35bd36b750b031999d6fbdfc3f57113114ab54c8fbec33e9874203402e09c24374619ec74af683cd5c687e5dea5d8e5a7a2ec5f99a06851f975590aeceabc
7
+ data.tar.gz: 92af9190a8661aee7e1e45fe689c7737c802b617ba74eac8efd409c5c7b5569bbfa5a822bd16e4b9b4a18f7d297c889c8e27c1ab566df105722ae32db1b01bcb
data/lib/twb.rb CHANGED
@@ -56,7 +56,8 @@ require_relative 'twb/analysis/calculatedfields/calculatedfieldsanalyzer'
56
56
  require_relative 'twb/analysis/calculatedfields/groupfieldsanalyzer'
57
57
  require_relative 'twb/analysis/calculatedfields/markdownemitter'
58
58
  require_relative 'twb/analysis/calculatedfields/csvemitter'
59
- require_relative 'twb/analysis/datasources/datasourcefieldscsvemitter'
59
+ # require_relative 'twb/analysis/datasources/datasourcefieldscsvemitter'
60
+ require_relative 'twb/analysis/datasources/datasourcefieldsanalyzer'
60
61
  require_relative 'twb/analysis/datasources/datasourcetablefieldscsvemitter'
61
62
  require_relative 'twb/analysis/datasources/categoricalcolorcodinganalyzer'
62
63
  require_relative 'twb/analysis/datasources/googlesheetdatasourcesanalyzer'
@@ -71,5 +72,5 @@ require_relative 'twb/analysis/sheets/dashsheetsanalyzer'
71
72
  # Represents Tableau Workbooks, their contents, and classes that analyze and manipulate them.
72
73
  #
73
74
  module Twb
74
- VERSION = '4.6.0'
75
+ VERSION = '4.6.1'
75
76
  end
@@ -0,0 +1,284 @@
1
+ # calculatedfieldsanalyzer.rb - this Ruby script Copyright 2017, 2018 Christopher 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 'twb'
17
+ require 'csv'
18
+
19
+ module Twb
20
+ module Analysis
21
+ module DataSources
22
+
23
+ class DataSourceFieldsAnalyzer
24
+
25
+ include TabTool
26
+
27
+ attr_reader :csvFileName, :csvRecords
28
+ attr_reader :dsCount, :fieldsCount
29
+
30
+ # @@csvHeader = ['Record #',
31
+ # 'Workbook',
32
+ # 'Workbook Dir',
33
+ # 'Data Source',
34
+ # 'Field',
35
+ # 'Twb Type',
36
+ # 'Hidden', # props[:hidden],
37
+ # 'Type - Column', # props[:columnField],
38
+ # 'Type - Calculated', # props[:calculatedField],
39
+ # 'Type - Db', # props[:dbField],
40
+ # 'Type - Mapped', # props[:mappedField]
41
+ # 'Type - MetaData', # props[:mappedField]
42
+ # ]
43
+ # @@csvFileType = 'TwbDataSourceFields'
44
+ # @@csvFileName = @@csvFileType + '.csv'
45
+
46
+ @@fullFileType = 'DataSourceFieldsDetails'
47
+ @@fullFileName = @@fullFileType + '.csv'
48
+ @@fullHeader = ['Field #',
49
+ 'Workbook',
50
+ 'Data Source',
51
+ 'Field',
52
+ 'Field - source',
53
+ 'Field - class',
54
+ 'Field - path',
55
+ 'Property - Name',
56
+ 'Property - Value'
57
+ ]
58
+
59
+ # @@techFileType = 'TwbDataSourceFieldsTech'
60
+ # @@techFileName = @@techFileType + '.csv'
61
+ # @@techHeader = ['Field #',
62
+ # 'Workbook',
63
+ # 'Workbook Dir',
64
+ # 'Data Source',
65
+ # 'Field',
66
+ # 'Field Type',
67
+ # 'Property - Name',
68
+ # 'Property - Value'
69
+ # ]
70
+
71
+ def initialize(**args)
72
+ @args = args
73
+ # puts "@args: #{@args}"
74
+ @recordDir = !@args.nil? && @args[:recordDir] == true
75
+ @ttdocdir = @args[:ttdocdir]
76
+ @csvAdd = args[:csvMode] == :add
77
+ @csvMode = @csvAdd ? 'a' : 'w'
78
+ init
79
+ @funcdoc = {:class=>self.class, :blurb=>'Analyze Data Source Fields', :description=>'Documents Data Source fields, with (some) technical information.',}
80
+ #--
81
+ docFileName = docFile(@@fullFileName)
82
+ @csvFile = CSV.open( docFileName,@csvMode)
83
+ unless @csvAdd
84
+ if @recordDir
85
+ @csvFile << @@fullHeader + ['Workbook Dir']
86
+ else
87
+ @csvFile << @@fullHeader
88
+ end
89
+ end
90
+ addDocFile @csvFile, docFileName, "Workbooks, Data Sources, and Fields."
91
+ #--
92
+ # --
93
+ @dsCount = 0
94
+ @recNum = 0
95
+ end
96
+
97
+ def initializeX
98
+ # @csvFile = CSV.open(@@csvFileName,'w')
99
+ # @csvFile << @@csvHeader
100
+ # @csvRecords = Set.new
101
+ # puts "Opened: #{!@csvFile.nil?} - #{@@csvFileName}"
102
+ # --
103
+ @csvFileFull = CSV.open(@@fullFileName,'w')
104
+ @csvFileFull << @@fullHeader
105
+ puts "Opened: #{!@csvFileFull.nil?} - #{@@fullFileName} "
106
+ # --
107
+ # @csvFileTech = CSV.open(@@techFileName,'w')
108
+ # @csvFileTech << @@techHeader
109
+ # puts "Opened: #{!@csvFileTech.nil?} - #{@@techFileName}"
110
+ # --
111
+ end
112
+
113
+ def self.csvHeader
114
+ @@csvHeader
115
+ end
116
+
117
+ def self.csvFileType
118
+ @@csvFileType
119
+ end
120
+
121
+ def self.csvFileNaame
122
+ @@csvFileName
123
+ end
124
+
125
+ def processTWB twb
126
+ @twb = nil
127
+ @twb = twb if twb.instance_of? Twb::Workbook
128
+ @twb = Twb::Workbook.new(twb) if twb.instance_of? String
129
+ raise ArgumentError.new("ERROR in Workbok processing: '#{twb}' must be a Workbook (class) or the name of a Workbook (String), is a #{twb.class} \n ") unless @twb.is_a? Twb::Workbook
130
+ # --
131
+ dss = @twb.datasources
132
+ @fieldCnt = 0
133
+ dss.each do |ds|
134
+ @dsname = ds.uiname
135
+ # puts "\n -- #{ds.uiname} "
136
+ # tables = Set.new
137
+ # fields = {}
138
+ @dsCount += 1
139
+ fclasses = Set.new
140
+ ds.localFields.each do |field|
141
+ recordFieldFull field, :local
142
+ # recordField( fields, field, {:type=>:local,:columnField=>true,:hidden=>field.hidden} )
143
+ # emitTech( ds, field.uiname, 'Local', field.properties)
144
+ # recordTech( field, 'LocalA')
145
+ end
146
+ ds.columnFields.each do |field|
147
+ recordFieldFull field, :column
148
+ # recordField( fields, field, {:type=>'column',:columnField=>true,:hidden=>field.hidden} )
149
+ # emitTech( ds, field.uiname, 'Column', field.properties)
150
+ # recordTech( field, 'ColumnA')
151
+ end
152
+ ds.calculatedFields.each do |field|
153
+ recordFieldFull field, :calc
154
+ # puts "WWW #{field.class} :: #{field} ::prop:: #{field.properties.class} :: #{field.properties}"
155
+ # recordField( fields, field, {:type=>'calc',:calculatedField=>true,:hidden=>field.hidden} )
156
+ # emitTech( ds, field.uiname, 'Calculated', field.properties)
157
+ # recordTech( field, 'CalcA')
158
+ end
159
+ ds.metadataFields.each do |field|
160
+ recordFieldFull field, :metadata
161
+ # recordField( fields, field, {:type=>'metadata',:metadataField=>true} )
162
+ # emitTech( ds, field.uiname, 'MetaData', field.properties)
163
+ # recordTech( field, 'MetadataA')
164
+ end
165
+ ds.dbFields.each do |field|
166
+ recordFieldFull field, :db
167
+ # recordField( fields, field, {:type=>'database',:dbField=>true} )
168
+ # emitTech( ds, field.uiname, 'Db', field.properties)
169
+ # recordTech( field, 'DbA')
170
+ end
171
+ ds.mappedFields.each do |field|
172
+ recordFieldFull field, :mapped
173
+ # recordField( fields, field, {:type=>'mapped',:mappedField=>true} )
174
+ # emitTech( ds, field.uiname, 'Mapped', field.properties)
175
+ # recordTech( field, 'MappedA')
176
+ end
177
+ # emitFields(fields)
178
+ end
179
+ end # def processTwb twb
180
+
181
+ def metrics
182
+ {
183
+ '# of Data Sources' => @dsCount,
184
+ '# of Records' => @recNum
185
+ }
186
+ end
187
+
188
+ private
189
+
190
+ def recordFieldFull field, source
191
+ # print field.properties.nil? ? '-' : ":#{field.properties.length}"
192
+ # puts field.properties
193
+ @fieldCnt+=1
194
+ field.properties.each do |name,value|
195
+ # print name
196
+ csvRec = [ @recNum+=1,
197
+ @twb.name,
198
+ # @twb.dir,
199
+ @dsname,
200
+ field.uiname,
201
+ source,
202
+ field.class,
203
+ field.node.path.to_s.gsub(/[0-9]/,'').gsub('[]',''),
204
+ name,
205
+ value
206
+ ]
207
+ csvRec << @twb.dir if @recordDir
208
+ @csvFile << csvRec
209
+ end
210
+ end
211
+
212
+ # def recordField fields, field, props
213
+ # # puts "%-65s :: %s " % [fieldName,props]
214
+ # return if field.uiname.nil?
215
+ # if fields.has_key? field.uiname
216
+ # fields[field.uiname].merge! field.properties
217
+ # else
218
+ # fields[field.uiname] = field.properties
219
+ # end
220
+ # end
221
+
222
+ # def emitFields fields
223
+ # fields.each do |fieldName,props|
224
+ # # puts "FIELD:: %-40s :: %s" % [fieldName,props.inspect]
225
+ # # class = props[]
226
+ # csvRec = [ @recNum+=1,
227
+ # @twb.name,
228
+ # @twb.dir,
229
+ # @dsname,
230
+ # fieldName,
231
+ # props[:type],
232
+ # props['hidden'],
233
+ # props[:columnField],
234
+ # props[:calculatedField],
235
+ # props[:dbField],
236
+ # props[:mappedField],
237
+ # props[:metadataField]
238
+ # ]
239
+ # @csvFile << csvRec
240
+ # @csvRecords.add csvRec
241
+ # end
242
+ # end
243
+
244
+ # def recordTech field, type
245
+ # @recNum+=1
246
+ # field.properties.each do |name,value|
247
+ # @csvFileTech << [ @recNum,
248
+ # @twb.name,
249
+ # @twb.dir,
250
+ # @dsname,
251
+ # field.uiname,
252
+ # type,
253
+ # name,
254
+ # value
255
+ # ]
256
+ # end
257
+ # end
258
+
259
+ # def emitTech dataSource, fieldName, type, properties
260
+ # # puts "XX #{dataSource.uiname} :: #{fieldName} #{} :: #{type} :: #{properties}"
261
+ # @recNum+=1
262
+ # properties.each do |name,value|
263
+ # @csvFileTech << [ @recNum,
264
+ # @twb.name,
265
+ # @twb.dir,
266
+ # dataSource.uiname,
267
+ # fieldName,
268
+ # type,
269
+ # name,
270
+ # value
271
+ # ]
272
+ # end
273
+ # end
274
+
275
+ # def cleanup
276
+ # @csvFile.close unless @csvFile.nil?
277
+ # end
278
+
279
+ end # class DataSourceFieldsCSVEmitter
280
+
281
+
282
+ end # module DataSources
283
+ end # module Analysis
284
+ end # module Twb
@@ -22,6 +22,8 @@ module DataSources
22
22
 
23
23
  class DataSourceFieldsCSVEmitter
24
24
 
25
+ include TabTool
26
+
25
27
  attr_reader :csvFileName, :csvRecords
26
28
  attr_reader :dsCount, :fieldsCount
27
29
 
@@ -67,7 +69,33 @@ module DataSources
67
69
  # 'Property - Value'
68
70
  # ]
69
71
 
70
- def initialize
72
+ def initialize(**args)
73
+ @args = args
74
+ # puts "@args: #{@args}"
75
+ @recordDir = !@args.nil? && @args[:recordDir] == true
76
+ @ttdocdir = @args[:ttdocdir]
77
+ @csvAdd = args[:csvMode] == :add
78
+ @csvMode = @csvAdd ? 'a' : 'w'
79
+ init
80
+ @funcdoc = {:class=>self.class, :blurb=>'Analyze Worksheet Filters', :description=>'Documents Quick Filters and the values they employ, if any. Work in progess.',}
81
+ #--
82
+ docFileName = docFile(@@fullFileName)
83
+ @sheetFieldsCSV = CSV.open( docFileName,@csvMode)
84
+ unless @csvAdd
85
+ if @recordDir
86
+ @sheetFieldsCSV << ['Rec #','Workbook','Workbook Modified','Worksheet','Filter Type','Operation','Data Source','Field','Value','Alias', 'Alias?','Operation Mode','Include Null?','Kind','Workbook Dir']
87
+ else
88
+ @sheetFieldsCSV << ['Rec #','Workbook','Workbook Modified','Worksheet','Filter Type','Operation','Data Source','Field','Value','Alias', 'Alias?','Operation Mode','Include Null?','Kind']
89
+ end
90
+ end
91
+ addDocFile @sheetFieldsCSV, docFileName, "Workbooks, Worksheets and the sheets' Quick Filters"
92
+ #--
93
+ @sheetCount = 0
94
+ @filterCount = 0
95
+ @recNum = 0
96
+ end
97
+
98
+ def initializeX
71
99
  # @csvFile = CSV.open(@@csvFileName,'w')
72
100
  # @csvFile << @@csvHeader
73
101
  # @csvRecords = Set.new
@@ -461,7 +461,10 @@ module Twb
461
461
  end
462
462
 
463
463
  def allFields
464
- return @allFields unless @allFields.nil?
464
+ return @allFields ||= loadAllFields
465
+ end
466
+
467
+ def loadAllFields
465
468
  @allFields = SortedSet.new
466
469
  dbf = dbFields
467
470
  @allFields << dbf.keys
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.0
4
+ version: 4.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Gerrard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-19 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: creek
@@ -66,6 +66,7 @@ files:
66
66
  - lib/twb/analysis/calculatedfields/groupfieldsanalyzer.rb
67
67
  - lib/twb/analysis/calculatedfields/markdownemitter.rb
68
68
  - lib/twb/analysis/datasources/categoricalcolorcodinganalyzer.rb
69
+ - lib/twb/analysis/datasources/datasourcefieldsanalyzer.rb
69
70
  - lib/twb/analysis/datasources/datasourcefieldscsvemitter.rb
70
71
  - lib/twb/analysis/datasources/datasourceoriginsanalyzer.rb
71
72
  - lib/twb/analysis/datasources/datasourceslocationsanalyzer.rb