Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added equality comparison to report filters and modified single quote XM... #42

Merged
merged 1 commit into from
Dec 11, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions lib/nexpose/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,17 @@ def add_filter(type, id)
end

def to_xml
xml = %(<AdhocReportConfig format='#{@format}' template-id='#{@template_id}')
xml << %( owner='#{@owner}') if @owner
xml << %( timezone='#{@time_zone}') if @time_zone
xml << %( language='#{@language}') if @language
xml = %(<AdhocReportConfig format="#{@format}" template-id="#{@template_id}")
xml << %( owner="#{@owner}") if @owner
xml << %( timezone="#{@time_zone}") if @time_zone
xml << %( language="#{@language}") if @language
xml << '>'

xml << '<Filters>'
@filters.each { |filter| xml << filter.to_xml }
xml << '</Filters>'

xml << %(<Baseline compareTo='#{@baseline}' />) if @baseline

xml << %(<Baseline compareTo="#{@baseline}"/>) if @baseline
xml << '</AdhocReportConfig>'
end

Expand All @@ -231,7 +230,7 @@ def to_xml
# @return Report in text format except for PDF, which returns binary data.
#
def generate(connection, timeout = 300)
xml = %(<ReportAdhocGenerateRequest session-id='#{connection.session_id}'>)
xml = %(<ReportAdhocGenerateRequest session-id="#{connection.session_id}">)
xml << to_xml
xml << '</ReportAdhocGenerateRequest>'
response = connection.execute(xml, '1.1', timeout: timeout)
Expand Down Expand Up @@ -317,7 +316,7 @@ def self.build(connection, site_id, site_name, type, format, generate_now = fals

# Save the configuration of this report definition.
def save(connection, generate_now = false)
xml = %(<ReportSaveRequest session-id='#{connection.session_id}' generate-now='#{generate_now ? 1 : 0}'>)
xml = %(<ReportSaveRequest session-id="#{connection.session_id}" generate-now="#{generate_now ? 1 : 0}">)
xml << to_xml
xml << '</ReportSaveRequest>'
response = connection.execute(xml)
Expand All @@ -341,10 +340,10 @@ def delete(connection)
include Sanitize

def to_xml
xml = %(<ReportConfig format='#{@format}' id='#{@id}' name='#{replace_entities(@name)}' template-id='#{@template_id}')
xml << %( owner='#{@owner}') if @owner
xml << %( timezone='#{@time_zone}') if @time_zone
xml << %( language='#{@language}') if @language
xml = %(<ReportConfig format="#{@format}" id="#{@id}" name="#{replace_entities(@name)}" template-id="#{@template_id}")
xml << %( owner="#{@owner}") if @owner
xml << %( timezone="#{@time_zone}") if @time_zone
xml << %( language="#{@language}") if @language
xml << '>'
xml << %(<description>#{@description}</description>) if @description

Expand All @@ -353,10 +352,10 @@ def to_xml
xml << '</Filters>'

xml << '<Users>'
@users.each { |user| xml << %(<user id='#{user}' />) }
@users.each { |user| xml << %(<user id="#{user}"/>) }
xml << '</Users>'

xml << %(<Baseline compareTo='#{@baseline}' />) if @baseline
xml << %(<Baseline compareTo="#{@baseline}"/>) if @baseline
xml << @frequency.to_xml if @frequency
xml << @delivery.to_xml if @delivery
xml << @db_export.to_xml if @db_export
Expand Down Expand Up @@ -427,7 +426,14 @@ def initialize(type, id)
end

def to_xml
%(<filter id='#{replace_entities(@id)}' type='#{@type}' />)
%(<filter id="#{replace_entities(@id)}" type="#{@type}" />)
end

def ==(object)
object.equal?(self) ||
(object.instance_of?(self.class) &&
object.type == @type &&
object.id == @id)
end

def self.parse(xml)
Expand Down Expand Up @@ -458,7 +464,7 @@ def initialize(after_scan, scheduled, schedule = nil)
end

def to_xml
xml = %(<Generate after-scan='#{@after_scan ? 1 : 0}' schedule='#{@scheduled ? 1 : 0}'>)
xml = %(<Generate after-scan="#{@after_scan ? 1 : 0}" schedule="#{@scheduled ? 1 : 0}">)
xml << @schedule.to_xml if @schedule
xml << '</Generate>'
end
Expand Down Expand Up @@ -500,7 +506,7 @@ def initialize(store_on_server, location = nil, email = nil)

def to_xml
xml = '<Delivery>'
xml << %(<Storage storeOnServer='#{@store_on_server ? 1 : 0}'>)
xml << %(<Storage storeOnServer="#{@store_on_server ? 1 : 0}">)
xml << %(<location>#{@location}</location>) if @location
xml << '</Storage>'
xml << @email.to_xml if @email
Expand Down Expand Up @@ -543,10 +549,10 @@ def initialize(type)
end

def to_xml
xml = %(<DBExport type='#{@type}'>)
xml = %(<DBExport type="#{@type}">)
xml << @credentials.to_xml if @credentials
@parameters.each_pair do |name, value|
xml << %(<param name='#{name}'>#{value}</param>)
xml << %(<param name="#{name}">#{value}</param>)
end
xml << '</DBExport>'
end
Expand Down Expand Up @@ -585,9 +591,9 @@ def initialize(credential)

def to_xml
xml = '<credentials'
xml << %( userid='#{@user_id}') if @user_id
xml << %( password='#{@password}') if @password
xml << %( realm='#{@realm}') if @realm
xml << %( userid="#{@user_id}") if @user_id
xml << %( password="#{@password}") if @password
xml << %( realm="#{@realm}") if @realm
xml << '>'
xml << @credential if @credential
xml << '</credentials>'
Expand Down