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.



521
522
523
524
# File 'lib/nexpose/report.rb', line 521

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

Instance Attribute Details

#credentialsObject

Credentials needed to export to the specified database.



517
518
519
# File 'lib/nexpose/report.rb', line 517

def credentials
  @credentials
end

#parametersObject

Map of parameters for this DB export configuration.



519
520
521
# File 'lib/nexpose/report.rb', line 519

def parameters
  @parameters
end

#typeObject

The DB type to export to.



515
516
517
# File 'lib/nexpose/report.rb', line 515

def type
  @type
end

Class Method Details

.parse(xml) ⇒ Object



535
536
537
538
539
540
541
542
543
544
545
# File 'lib/nexpose/report.rb', line 535

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



526
527
528
529
530
531
532
533
# File 'lib/nexpose/report.rb', line 526

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