Class: Twb::Util::AtomizeCSVRecords
- Inherits:
-
Object
- Object
- Twb::Util::AtomizeCSVRecords
- Includes:
- TabTool
- Defined in:
- lib/twb/util/atomizecsvrecords.rb
Constant Summary collapse
- @@ttlogfile =
'AtomizeCSVRecords.ttlog'
- @@csvFileName =
'AtomizedCSVRecords.csv'
Instance Attribute Summary collapse
-
#metrics ⇒ Object
readonly
include Graph.
-
#ttdocdir ⇒ Object
Returns the value of attribute ttdocdir.
Attributes included from TabTool
#alerts, #docDir, #docfiles, #funcdoc, #id, #licensed, #logfilename, #logger, #loglevel, #properties, #type, #uuid
Instance Method Summary collapse
-
#initialize(**args) ⇒ AtomizeCSVRecords
constructor
A new instance of AtomizeCSVRecords.
- #loadFields(fileName) ⇒ Object
- #loadMetrics ⇒ Object
- #processData(fileName) ⇒ Object
- #processTWB(workbook) ⇒ Object
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) ⇒ AtomizeCSVRecords
Returns a new instance of AtomizeCSVRecords.
35 36 37 38 39 40 41 42 43 |
# File 'lib/twb/util/atomizecsvrecords.rb', line 35 def initialize(**args) @ttdocdir = @args[:ttdocdir] @csvAdd = @args[:csvMode] == :add @csvMode = @csvAdd ? 'a' : 'w' init @funcdoc = {:class=>self.class, :blurb=>'Analyze Calculated Fields', :description=>'Calculated fields can be complex, this tool provides robust coverage.',} # -- @executed = false end |
Instance Attribute Details
#metrics ⇒ Object (readonly)
include Graph
29 30 31 |
# File 'lib/twb/util/atomizecsvrecords.rb', line 29 def metrics @metrics end |
#ttdocdir ⇒ Object
Returns the value of attribute ttdocdir.
30 31 32 |
# File 'lib/twb/util/atomizecsvrecords.rb', line 30 def ttdocdir @ttdocdir end |
Instance Method Details
#loadFields(fileName) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/twb/util/atomizecsvrecords.rb', line 45 def loadFields fileName fields = Set.new file = File.open(fileName) unless file.nil? file.each_line { |line| fields.add line.chomp } end return fields end |
#loadMetrics ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/twb/util/atomizecsvrecords.rb', line 92 def loadMetrics @metrics = { '# of Data Sources' => @dataSourcesCount, '# of Calculated Fields' => @calculatedFieldsCount, '# of Referenced Fields' => @referencedFieldsCount, } end |
#processData(fileName) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/twb/util/atomizecsvrecords.rb', line 62 def processData fileName unless @executed emit true, "initialize AtomizeCSVRecords args #{args}" @atomicCSV = CSV.open(@@csvFileName, 'w') # -- inputFileName = fileName.nil? ? 'csvData.csv' : fileName keyFields = loadFields 'key.fields' excludeFields = loadFields 'exclude.fields' puts "\t Using these key fields: #{$keyFields.inspect}" puts "\t Excluding these fields: #{$excludeFields.inspect}" $fieldValsCSV = '.csv' $atomicCSV = CSV.open($fieldValsCSV, 'w') $atomicFields = $keyFields.to_a + [ 'Rec #', 'Field', 'Value' ] puts "\n\t CSV output fields: #{$atomicFields.inspect}" $atomicCSV << $atomicFields $recCnt, $fldsCnt = 0, 0 $recNum = 0 @executed = true end end |
#processTWB(workbook) ⇒ Object
56 57 58 59 60 |
# File 'lib/twb/util/atomizecsvrecords.rb', line 56 def processTWB workbook puts "\n\t ALERT: Utility tool: #{self.class} - does not implement Workbook processing" puts "\t - deferring to single execution" processData fileName end |