Class: Nexpose::DBExport

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/report.rb

Overview

Configuration structure for database exporting of reports.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ DBExport

Returns a new instance of DBExport.



553
554
555
556
# File 'lib/nexpose/report.rb', line 553

def initialize(type)
  @type = type
  @parameters = {}
end

Instance Attribute Details

#credentialsObject

Credentials needed to export to the specified database.



549
550
551
# File 'lib/nexpose/report.rb', line 549

def credentials
  @credentials
end

#parametersObject

Map of parameters for this DB export configuration.



551
552
553
# File 'lib/nexpose/report.rb', line 551

def parameters
  @parameters
end

#typeObject

The DB type to export to.



547
548
549
# File 'lib/nexpose/report.rb', line 547

def type
  @type
end

Class Method Details

.parse(xml) ⇒ Object



567
568
569
570
571
572
573
574
575
576
577
# File 'lib/nexpose/report.rb', line 567

def self.parse(xml)
  xml.elements.each('//DBExport') do |dbexport|
    config = DBExport.new(dbexport.attributes['type'])
    config.credentials = ExportCredential.parse(xml)
    xml.elements.each('//param') do |param|
      config.parameters[param.attributes['name']] = param.text
    end
    return config
  end
  nil
end

Instance Method Details

#to_xmlObject



558
559
560
561
562
563
564
565
# File 'lib/nexpose/report.rb', line 558

def to_xml
  xml = %(<DBExport type="#{@type}">)
  xml << @credentials.to_xml if @credentials
  @parameters.each_pair do |name, value|
    xml << %(<param name="#{name}">#{value}</param>)
  end
  xml << '</DBExport>'
end