class Twb::Analysis::GoogleSheetDataSourcesAnalyzer
Attributes
localEmit[RW]
twbcount[R]
twbname[R]
Public Class Methods
new(**args)
click to toggle source
# File lib/twb/analysis/DataSources/googlesheetdatasourcesanalyzer.rb, line 30 def initialize(**args) @args = args #-- TODO move @csvAdd * #csvMode resolution to TabTool @csvAdd = args[:csvMode] == :add @csvMode = @csvAdd ? 'a' : 'w' emit "@csvAdd : #{@csvAdd}" emit "@csvMode: #{@csvMode}" #-- init #-- set up metrics @twbcount = 0 @dscount = 0 @filecount = 0 @sheetcount = 0 #-- @funcdoc = {:class=>self.class, :blurb=>'Analyze Google Sheet Data Sources', :description=>nil,} docFileName = docFile('GoogleSheetDataSources.csv') @csv = CSV.open(docFileName, 'w') unless @csvAdd @csv << ["Workbook",'Data Source','Connection','File Name','Type','Table Name','Field'] end # @docfiles = [{:name=>docFileName,:description=>"CSV File containing the data relating Google Sheet-based Data Sources."}] addDocFile @dashSheetsCSV, docFileName, "Workbooks, Dashboards, and their Worksheets" end
Public Instance Methods
metrics()
click to toggle source
# File lib/twb/analysis/DataSources/googlesheetdatasourcesanalyzer.rb, line 94 def metrics { # '# of Workbooks' => @twbcount, '# of Data Sources' => @dscount, '# of Google Docs' => @filecount, '# of Worksheets' => @sheetcount } end
processTWB(twb)
click to toggle source
# File lib/twb/analysis/DataSources/googlesheetdatasourcesanalyzer.rb, line 55 def processTWB twb if Twb::Workbook != twb.class @twb = Twb::Workbook.new twb else @twb = twb end @twbname = @twb.name emit "Workbook:: #{@twbname}" @twbcount += 1 dss = twb.datasources dss.each do |ds| emit ds.uiname @dscount += 1 conns = ds.node.xpath(".//connection[@class='google-sheets']") if conns.length > 0 @relation = ds.node.at_xpath('./connection/relation') @relName = @relation.nil? ? 'n/a - no relation in connection' : @relation['name'] @relType = @relation.nil? ? 'n/a - no relation in connection' : @relation['type'] @fileName = ds.node.at_xpath('.//named-connection/connection')['filename'] @filecount += 1 emit "FILENAME: #{@fileName}" tables = ds.node.xpath(".//relation[@type='table']") # emit "# Tables: #{tables.length}" tables.each do |table| @sheetcount += 1 tableName = table.attribute('name') columns = table.xpath('.//column') columns.each do |column| emit [@twbname,ds.uiname,@relName,@fileName,@relType,tableName,column.attribute('name')].to_csv @csv << [@twbname,ds.uiname,@relName,@fileName,@relType,tableName,column.attribute('name')] emit '' end end end emit " " end finis end