class Twb::Analysis::GroupFieldsAnalyzer

Attributes

localEmit[RW]

Public Class Methods

new() click to toggle source
# File lib/twb/analysis/CalculatedFields/groupfieldsanalyzer.rb, line 28
def initialize
  init
  @funcdoc     = {:class=>self.class, :blurb=>'Analyze Group Fields.', :description=>'Identifies the Groups and their Members for grouped fields.',}
  #--
  docFileName  = docFile('GroupFields.csv')
  @csv         = CSV.open(docFileName,'w')
  @csv        << ['Workbook','Data Source','Field','Group','Member']
  addDocFile @csv, docFileName, "Workbooks, Data Sources, and their Grouped Fields"
  #--
  @twbCount    = 0
  @dsCount     = 0
  @gfCount     = 0
  @gfmCount    = 0
end

Public Instance Methods

initMarkdown() click to toggle source
# File lib/twb/analysis/CalculatedFields/groupfieldsanalyzer.rb, line 63
def initMarkdown
  $mdFile = File.open(docFile("#{@twbName}.GroupFields.md"), 'w')
  $mdFile << "# #{@twbName}\n "
end
metrics() click to toggle source
# File lib/twb/analysis/CalculatedFields/groupfieldsanalyzer.rb, line 43
def metrics
  {
    # '# of Workbooks'           => @twbCount,
    '# of Data Sources'        => @dsCount,
    '# of Group Fields'        => @gfCount,
    '# of Group Field Members' => @gfmCount
  }
end
parseDataSources() click to toggle source
# File lib/twb/analysis/CalculatedFields/groupfieldsanalyzer.rb, line 68
def parseDataSources
  @twb.datasources.each do |ds|
      $mdFile.puts "\n## #{ds.uiname}" 
      @dsCount += 1
      cfs = ds.calculatedFields
      cfs.each do |cf|
          if cf.isGroup
            @gfCount += 1
            $mdFile.puts "###  #{cf.name}"
            cf.groupMembers.each do |lead,values|
                $mdFile.puts "* #{lead}"
                values.each do |v|
                  @gfmCount += 1
                    $mdFile.puts "    >  #{v}"
                    @csv << [@twbName, ds.uiname,cf.uiname,lead,v]
                end
            end
          end
      end
  end
end
processTWB(twb) click to toggle source
# File lib/twb/analysis/CalculatedFields/groupfieldsanalyzer.rb, line 52
def processTWB twb
   @twb     = twb
   @twbName = @twb.name
   emit "   -- #{@twbName}"
   @twbCount += 1
   initMarkdown
   parseDataSources
   finis
   $mdFile.close unless $mdFile.nil?
end