Class: Twb::Analysis::AnnotatedFieldsCSVEmitter
- Inherits:
-
Object
- Object
- Twb::Analysis::AnnotatedFieldsCSVEmitter
- Defined in:
- lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb
Constant Summary collapse
- @@csvHeader =
['Record #', 'Workbook', 'Workbook Dir', 'Data Source', 'Field', 'Doc Type', 'Doc Line #', 'Doc Line' ]
- @@csvFileType =
'TwbAnnotatedFields'- @@csvFileName =
@@csvFileType + '.csv'
Instance Attribute Summary collapse
-
#csvFileName ⇒ Object
readonly
Returns the value of attribute csvFileName.
-
#csvRecords ⇒ Object
readonly
Returns the value of attribute csvRecords.
-
#dsCount ⇒ Object
readonly
Returns the value of attribute dsCount.
-
#fieldsCount ⇒ Object
readonly
Returns the value of attribute fieldsCount.
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup ⇒ Object
- #emitFields(fields) ⇒ Object
- #emitTech(dataSource, fieldName, type, properties) ⇒ Object
-
#initialize ⇒ AnnotatedFieldsCSVEmitter
constructor
A new instance of AnnotatedFieldsCSVEmitter.
- #processTwb(twb) ⇒ Object
-
#recordField(field) ⇒ Object
def processTwb twb.
- #recordTech(field, type) ⇒ Object
Constructor Details
#initialize ⇒ AnnotatedFieldsCSVEmitter
Returns a new instance of AnnotatedFieldsCSVEmitter.
39 40 41 42 43 44 45 46 47 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 39 def initialize @csvFile = CSV.open(@@csvFileName,'w') @csvFile << @@csvHeader @csvRecords = Set.new # -- @recNum = 0 @dsCount = 0 @fieldNum = 0 end |
Instance Attribute Details
#csvFileName ⇒ Object (readonly)
Returns the value of attribute csvFileName.
24 25 26 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 24 def csvFileName @csvFileName end |
#csvRecords ⇒ Object (readonly)
Returns the value of attribute csvRecords.
24 25 26 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 24 def csvRecords @csvRecords end |
#dsCount ⇒ Object (readonly)
Returns the value of attribute dsCount.
25 26 27 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 25 def dsCount @dsCount end |
#fieldsCount ⇒ Object (readonly)
Returns the value of attribute fieldsCount.
25 26 27 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 25 def fieldsCount @fieldsCount end |
Class Method Details
.csvFileNaame ⇒ Object
57 58 59 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 57 def self.csvFileNaame @@csvFileName end |
.csvFileType ⇒ Object
53 54 55 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 53 def self.csvFileType @@csvFileType end |
.csvHeader ⇒ Object
49 50 51 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 49 def self.csvHeader @@csvHeader end |
Instance Method Details
#cleanup ⇒ Object
175 176 177 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 175 def cleanup @csvFile.close unless @csvFile.nil? end |
#emitFields(fields) ⇒ Object
def recordField fields, field, props
# puts "%-65s :: %s " % [fieldName,props]
return if field.uiname.nil?
if fields.has_key? field.uiname
fields[field.uiname].merge! field.properties
else
fields[field.uiname] = field.properties
end
end
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 122 def emitFields fields fields.each do |fieldName,props| # puts "FIELD:: %-40s :: %s" % [fieldName,props.inspect] # class = props[] csvRec = [ @recNum+=1, @twb.name, @twb.dir, @dsname, fieldName, props[:type], props['hidden'], props[:columnField], props[:calculatedField], props[:dbField], props[:mappedField], props[:metadataField] ] @csvFile << csvRec @csvRecords.add csvRec end end |
#emitTech(dataSource, fieldName, type, properties) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 159 def emitTech dataSource, fieldName, type, properties # puts "XX #{dataSource.uiname} :: #{fieldName} #{} :: #{type} :: #{properties}" @recNum+=1 properties.each do |name,value| @csvFileTech << [ @recNum, @twb.name, @twb.dir, dataSource.uiname, fieldName, type, name, value ] end end |
#processTwb(twb) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 61 def processTwb twb @twb = nil @twb = twb if twb.instance_of? Twb::Workbook @twb = Twb::Workbook.new(twb) if twb.instance_of? String 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 # -- dss = @twb.datasources dss.each do |ds| @dsname = ds.uiname # puts "\n -- #{ds.uiname} " # tables = Set.new fields = {} @dsCount += 1 ds.columnFields.each do |field| recordField field end end end |
#recordField(field) ⇒ Object
def processTwb twb
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 80 def recordField field @fieldNum += 1 @lineNum = 0 field.comment.each do |line| # dispLine = if ''.eql?(line) the ? '' : line @csvFile << [ @recNum+=1, @twb.name, @twb.dir, @dsname, field.uiname, 'Comment', @lineNum+=1, # ''.eql?(line) ? " " : line line ] end unless field.calcField.nil? @lineNum = 0 field.calcField.formulaResolvedLines.each do |line| @csvFile << [ @recNum+=1, @twb.name, @twb.dir, @dsname, field.uiname, 'Formula', @lineNum+=1, line ] end end end |
#recordTech(field, type) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb', line 144 def recordTech field, type @recNum+=1 field.properties.each do |name,value| @csvFileTech << [ @recNum, @twb.name, @twb.dir, @dsname, field.uiname, type, name, value ] end end |