class Risu::Parsers::Nexpose::NexposeDocument
Public Class Methods
new(document)
click to toggle source
Creates a instance of the NexposeDocument
class
# File lib/risu/parsers/nexpose/nexpose_document.rb, line 31 def initialize document @document = document end
Public Instance Methods
fix_ips()
click to toggle source
Fixes the ip field if nil and replaces it with the name if its an ip
# File lib/risu/parsers/nexpose/nexpose_document.rb, line 65 def fix_ips @hosts = Host.all @hosts.each do |host| if host.ip == nil begin ip = IPAddr.new host.name host.ip = ip.to_string host.save rescue ArgumentError next end end end end
parse()
click to toggle source
Invokes the SAX parser on the XML document
# File lib/risu/parsers/nexpose/nexpose_document.rb, line 58 def parse @parser = LibXML::XML::SaxParser.file @document @parser.callbacks = SimpleNexpose.new @parser.parse end
valid?()
click to toggle source
Checks the validness of a Nexpose
@return [Boolean] True if valid, False if invalid
# File lib/risu/parsers/nexpose/nexpose_document.rb, line 38 def valid? if File.exist?(@document) @parser = LibXML::XML::Parser.file @document doc = @parser.parse if doc.root.name == nil return false end if doc.root.name == "NeXposeSimpleXML" return true else return false end else return false end end