Class: Twb::Analysis::CalculatedFields::MarkdownEmitter
- Inherits:
-
Object
- Object
- Twb::Analysis::CalculatedFields::MarkdownEmitter
- Defined in:
- lib/twb/analysis/CalculatedFields/MarkdownEmitter.rb
Instance Attribute Summary collapse
-
#docFileName ⇒ Object
readonly
Returns the value of attribute docFileName.
Instance Method Summary collapse
-
#initialize ⇒ MarkdownEmitter
constructor
A new instance of MarkdownEmitter.
- #processTwb(twb) ⇒ Object
Constructor Details
#initialize ⇒ MarkdownEmitter
Returns a new instance of MarkdownEmitter.
26 27 28 |
# File 'lib/twb/analysis/CalculatedFields/MarkdownEmitter.rb', line 26 def initialize # puts "" end |
Instance Attribute Details
#docFileName ⇒ Object (readonly)
Returns the value of attribute docFileName.
24 25 26 |
# File 'lib/twb/analysis/CalculatedFields/MarkdownEmitter.rb', line 24 def docFileName @docFileName end |
Instance Method Details
#processTwb(twb) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/twb/analysis/CalculatedFields/MarkdownEmitter.rb', line 30 def processTwb twb twb = File.basename(twb) @twb = Twb::Workbook.new twb @docFileName = twb + '.CalculatedFields.md' @docFile = File.open(@docFileName,'w') @docFile.puts "## #{twb}" dsNames = @twb.datasourceUINames @docFile.puts "#{dsNames.length} Data Sources" dsNames.each do |dsn| ds = @twb.datasource dsn # puts " => #{ds.uiname} " # end # dss = @twb.datasources # dss.each do |ds| @docFile.puts "### #{ds.uiname}" calcFields = ds.calculatedFieldsMap.sort_by { |fldName,calc| fldName } calcFields.each do |fldname, field| calculation = field.calculation @docFile.puts "\n##### #{fldname} " @docFile.puts "###### ...description..." @docFile.puts "```" if calculation.has_formula @docFile.puts calculation.formulaResolved @docFile.puts "\n -- Fields --" unless calculation.calcFields.empty? refFields = SortedSet.new calculation.calcFields.each do |cf| fds = if cf.dataSourceRef == :remote then "<<#{cf.dataSource}>>" else '' end refFields.add "#{cf.uiName} \t #{fds}" end refFields.each do |rf| @docFile.puts " #{rf}" end @docFile.puts "```" end end end end |