Class: GdlDocBuilder
- Inherits:
-
Object
- Object
- GdlDocBuilder
- Defined in:
- lib/xmlutils/gdldocbuilder.rb
Overview
class GdlDocBuilder
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#createDocument(srcFile) ⇒ Object
————————————————————————————————————-# createDocument - create a GDL document from an XML document.
-
#initialize(options) ⇒ GdlDocBuilder
constructor
————————————————————————————————————-# initialize - CTor.
-
#parseExternalVarDefs(ctx) ⇒ Object
————————————————————————————————————-# parseExternalVarDefs - parse predefined GDL variable definition files.
-
#printMetrics(ctx) ⇒ Object
————————————————————————————————————-# printMetrics - Print context metrics.
-
#statusMsg(msg) ⇒ Object
————————————————————————————————————-# statusMsg - output a status message.
Constructor Details
#initialize(options) ⇒ GdlDocBuilder
————————————————————————————————————-# initialize - CTor
options - Document builder options
————————————————————————————————————#
32 33 34 35 36 |
# File 'lib/xmlutils/gdldocbuilder.rb', line 32 def initialize() = @context = GdlContext.new @context.setOptions() end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
22 23 24 |
# File 'lib/xmlutils/gdldocbuilder.rb', line 22 def context @context end |
#options ⇒ Object
Returns the value of attribute options.
21 22 23 |
# File 'lib/xmlutils/gdldocbuilder.rb', line 21 def end |
Instance Method Details
#createDocument(srcFile) ⇒ Object
————————————————————————————————————-# createDocument - create a GDL document from an XML document
srcFile - XML source file
————————————————————————————————————#
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 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 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/xmlutils/gdldocbuilder.rb', line 47 def createDocument(srcFile) # Setup context object builder ctxBuilder = ContextParser.new(@context) ctxBuilder.setFlag() statusMsg "Creating guideline context." ctxBuilder.parse(srcFile) printMetrics(@context) statusMsg "Parsing external variable definitions." parseExternalVarDefs(@context) statusMsg "Parsing rule data (#{ctxBuilder.context.rules.size.to_s} rules)." ruleBuilder = RuleParser.new(@context) ruleBuilder.setFlag() @context.rules.each do |key, rule| rule.src = ruleBuilder.parse(rule.xml) print "." end # rules.each puts # ctxBuilder.dumpResults # Create output file and output src. statusMsg "Generating document." gdlDoc = GdlDoc.new(srcFile, @context) gdlDoc.setOptions() genFile = gdlDoc.generate statusMsg "Document created: #{genFile}" genFile = gdlDoc.generateRenameList statusMsg "Rename list document created: #{genFile}" end |
#parseExternalVarDefs(ctx) ⇒ Object
————————————————————————————————————-# parseExternalVarDefs - parse predefined GDL variable definition files.
ctx - context containing variables to update
————————————————————————————————————#
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/xmlutils/gdldocbuilder.rb', line 144 def parseExternalVarDefs(ctx) puts "No external variable definition files provided." if (!ctx.[:verbose].nil? && ctx.[:includes].nil?) return if ctx.[:includes].nil? vp = LineParser.new # Parse externally defined GDL variable definition files. ctx.[:includes].each do |inc| vp.parse(inc) # TODO: Allow external var def files to be defined in a config file. end # ctx.options.each vp.dumpResults if $DEBUG puts "Searching for external DPM definitions." if $DEBUG ctx.dpms.each do |key, val| if (vp.dpms.has_key?(key)) ctx.dpms[key] = vp.dpms[key] puts "Found match: #{key}" if $DEBUG end # if vp.dpms end # do puts "Searching for external DSM definitions." if $DEBUG ctx.dpms.each do |key, val| if (vp.dsms.has_key?("#{key}")) ctx.dpms[key] = vp.dsms[key] puts "Found match: #{key}" if $DEBUG end # if vp.dsms end # do puts "Searching for external PPM definitions." if $DEBUG ctx.ppms.each do |key, val| if (vp.ppms.has_key?(key)) ctx.ppms[key] = vp.ppms[key] puts "Found match: #{key}" if $DEBUG end # if vp.ppms end # do end |
#printMetrics(ctx) ⇒ Object
————————————————————————————————————-# printMetrics - Print context metrics
ctx - Context to generate metrics from
————————————————————————————————————#
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/xmlutils/gdldocbuilder.rb', line 124 def printMetrics(ctx) puts " DPM count: #{ctx.dpms.size.to_s} (includes DSMs)" puts " PPM count: #{ctx.ppms.size.to_s}" puts " Lookup count: #{ctx.lookups.size.to_s}" puts " Message count: #{ctx.messages.size.to_s} (includes conditions)" puts " Rule count: #{ctx.rules.size.to_s}" puts " Ruleset count: #{ctx.rulesets.size.to_s}" end |
#statusMsg(msg) ⇒ Object
————————————————————————————————————-# statusMsg - output a status message
msg - Message to output
————————————————————————————————————#
107 108 109 110 111 112 113 |
# File 'lib/xmlutils/gdldocbuilder.rb', line 107 def statusMsg(msg) puts puts "-} #{msg}" puts end |