Class: Twb::Analysis::DataSources::DataSourcesEnumerator

Inherits:
Object
  • Object
show all
Includes:
TabTool
Defined in:
lib/twb/analysis/datasources/datasourcesenumerator.rb

Instance Attribute Summary collapse

Attributes included from TabTool

#alerts, #docDir, #docfiles, #funcdoc, #id, #licensed, #logfilename, #logger, #loglevel, #properties, #ttdocdir, #type, #uuid

Instance Method Summary collapse

Methods included from TabTool

#addDocFile, #alert, #closeDocFiles, #config, #docFile, #docFileMaxNameLen, #docfilesdoc, #docfilesdocto_s, #emit, #emitCSV, #finis, #hasConfig, #init, #initCSV, #initDocDir, #initLogger, #license=, #licensed?, #loadConfig

Constructor Details

#initialize(**args) ⇒ DataSourcesEnumerator

Returns a new instance of DataSourcesEnumerator.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/twb/analysis/datasources/datasourcesenumerator.rb', line 30

def initialize(**args)
  @args      = args
  @recordDir = !@args.nil? && @args[:recordDir] == true
  @ttdocdir  = @args[:ttdocdir]
  @csvAdd    = args[:csvMode] == :add
  @csvMode   = @csvAdd ? 'a' : 'w'
  init
  @funcdoc   = {:class=>self.class, :blurb=>"Enumerate Workbooks' Data Sources", :description=>'Documents Data Sources, recoring their names.',}
  #--
  docFileName      = docFile('DataSources.csv')
  @sheetFieldsCSV  = CSV.open( docFileName,@csvMode)
  unless @csvAdd
    if @recordDir
      @sheetFieldsCSV  << ['Rec #','Workbook','Data Source','Data Source (tech)','Class','Extract?','# Connections','# Fields','Published?', '# Tables', '# Aliases', '# Groups', 'Workbook Dir']
    else
      @sheetFieldsCSV  << ['Rec #','Workbook','Data Source','Data Source (tech)','Class','Extract?','# Connections','# Fields','Published?', '# Tables', '# Aliases', '# Groups']
    end
  end
  addDocFile @sheetFieldsCSV, docFileName, "Workbooks and the Data Sources they contain."
  #--
  @dsCount  = 0
  @recNum   = 0
end

Instance Attribute Details

#localEmitObject

Returns the value of attribute localEmit.



28
29
30
# File 'lib/twb/analysis/datasources/datasourcesenumerator.rb', line 28

def localEmit
  @localEmit
end

Instance Method Details

#metricsObject



54
55
56
57
58
# File 'lib/twb/analysis/datasources/datasourcesenumerator.rb', line 54

def metrics
  {
    '# of Data Sources'        => @dsCount,
  }
end

#parseDataSourcesObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/twb/analysis/datasources/datasourcesenumerator.rb', line 68

def parseDataSources
  @dataSources  = @twb.datasources
  @dataSources.each do |ds|
    @dsCount += 1
    recordCSV [ @twbName, 
                ds.uiname, 
                ds.name, 
                ds.dsclass, 
                ds.isExtract, 
                ds.connections.length,
                ds.allFields.length, 
                ds.isPublished, 
                ds.tables.length, 
                ds.aliases.length, 
                ds.groups.length 
              ]
    # [@twbName, @modTime, sheet.name, filter.type, filter.inexclude, filter.dataSource.uiname, filter.uiname, nil,   nil,    nil,  filter.inexMode, filter.includeNull, filter.kind]
  end
end

#processTWB(twb) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/twb/analysis/datasources/datasourcesenumerator.rb', line 60

def processTWB twb
   @twb     = twb
   @twbName = @twb.name
   @twbDir  = @twb.dir
   emit "   -- #{@twbName}"
   parseDataSources
end