Class: ContextParser
- Inherits:
-
Object
- Object
- ContextParser
- Defined in:
- lib/xmlutils/contextparser.rb
Overview
class ContextParser
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Instance Method Summary collapse
-
#dumpResults ⇒ Object
————————————————————————————————————-# dumpResults - Dump collected context info to STDOUT.
-
#initialize(ctx) ⇒ ContextParser
constructor
A new instance of ContextParser.
-
#parse(fname) ⇒ Object
————————————————————————————————————-# parse - Parse guideline XML.
-
#setFlag(flg) ⇒ Object
————————————————————————————————————-# setFlag - Set configuration flags.
- #verbose? ⇒ Boolean
Constructor Details
#initialize(ctx) ⇒ ContextParser
Returns a new instance of ContextParser.
27 28 29 30 31 |
# File 'lib/xmlutils/contextparser.rb', line 27 def initialize(ctx) @context = ctx @verbose = false end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
25 26 27 |
# File 'lib/xmlutils/contextparser.rb', line 25 def context @context end |
Instance Method Details
#dumpResults ⇒ Object
————————————————————————————————————-# dumpResults - Dump collected context info to STDOUT
————————————————————————————————————#
102 103 104 105 106 107 108 |
# File 'lib/xmlutils/contextparser.rb', line 102 def dumpResults() @listener.context.dumpDpms() @listener.context.dumpPpms() @listener.context.dumpLookups() @listener.context.dumpRules() @listener.context.dumpRulesets() end |
#parse(fname) ⇒ Object
————————————————————————————————————-# parse - Parse guideline XML
fname - Filename of XML file to parse
————————————————————————————————————#
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/xmlutils/contextparser.rb', line 74 def parse(fname) puts "Parsing file." unless (!verbose?) ctxListener = ContextListener.new(@context) ctxListener.verbose = @verbose parser = Parsers::StreamParser.new(File.new(fname), ctxListener) parser.parse puts "Parsing guideline." unless (!verbose?) gdlListener = GdlListener.new(@context) # Gets rule and ruleset names and aliases. gdlListener.verbose = @verbose parser = Parsers::StreamParser.new(File.new(fname), gdlListener) parser.parse puts "Parsing rule XML." unless (!verbose?) ruleListener = RuleListener.new(@context) ruleListener.verbose = @verbose parser = Parsers::StreamParser.new(File.new(fname), ruleListener) parser.parse end |
#setFlag(flg) ⇒ Object
————————————————————————————————————-# setFlag - Set configuration flags
flg - Array of options or single string option. Currently, only -v: verbose is available
————————————————————————————————————#
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/xmlutils/contextparser.rb', line 48 def setFlag(flg) if (flg.class == Array) flg.each do |f| case f when '-v' @verbose = true end end # flg.each return end # if flg case flg when '-v' @verbose = true end end |
#verbose? ⇒ Boolean
35 36 37 |
# File 'lib/xmlutils/contextparser.rb', line 35 def verbose?() return @verbose end |