Class: SNMP::Open::Parser
- Inherits:
-
Object
- Object
- SNMP::Open::Parser
- Includes:
- Constants
- Defined in:
- lib/snmp/open/parser.rb,
lib/snmp/open/parser/constants.rb,
lib/snmp/open/parser/value_parser.rb
Overview
convert SNMP command output into arrays
Defined Under Namespace
Modules: Constants, Static Classes: ValueParser
Constant Summary collapse
- OID_RE =
Regexp.union(/\S+-MIB::\S+/, /[0-9.]+/)
- EMPTY_STRING_RE =
/^(#{OID_RE}) # capture group 1: OID \s+=\s+ (Opaque|STRING) # capture group 2: Type :\s*\n # value is always empty string /x.freeze
- STRING_RE =
/^(#{OID_RE}) # capture group 1: OID \s+=\s+ (Opaque|STRING):\s+ # capture group 2: Type ( # capture group 3: Value (?!") # this pattern is for finding strings in need of # quoting, so reject any strings that are already # quoted [^\n]* # first line of value (\n # newline before each additional line of value (?! #{OID_RE} # additional lines of value are identified by not \s+=\s+ # starting with "<OID> =" ) [^\n]+ # additional lines of value )* )\n /x.freeze
Constants included from Constants
Constants::NOMOREVARIABLES_STR, Constants::NOSUCHINSTANCE_STR, Constants::NOSUCHOBJECT_STR
Instance Method Summary collapse
-
#initialize(oids) ⇒ Parser
constructor
A new instance of Parser.
- #parse(texts) ⇒ Object
Constructor Details
#initialize(oids) ⇒ Parser
Returns a new instance of Parser.
49 50 51 |
# File 'lib/snmp/open/parser.rb', line 49 def initialize(oids) @oids = oids end |
Instance Method Details
#parse(texts) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/snmp/open/parser.rb', line 53 def parse(texts) columns = texts.map do |text| clean = clean_input_text(text) tokenized = clean.shellsplit parse_tokens(tokenized) end table(columns) end |