Skip to content

Commit

Permalink
[webui] Extract parts of method into own method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Rolfe committed Oct 27, 2017
1 parent 53ce663 commit a35c80d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api/app/models/kiwi/image/xml_builder.rb
Expand Up @@ -25,21 +25,22 @@ def update_description(document)

if document.xpath('image/description[@type="system"]').first
%w[author contact specification].each do |element_name|
update_description_element(document, element_name)
description_xml_element = find_or_create_description_xml_element(document, element_name)
document.xpath('image/description[@type="system"]').first.add_child(description_xml_element)
end
else
document.at_css('image').first_element_child.before(@image.description.to_xml)
end
document
end

def update_description_element(document, element_name)
def find_or_create_description_xml_element(document, element_name)
element_xml = document.xpath("image/description[@type='system']/#{element_name}").first
unless element_xml
element_xml = Nokogiri::XML::Node.new(element_name, document)
document.xpath('image/description[@type="system"]').first.add_child(element_xml)
end
element_xml.content = @image.description.send(element_name)
element_xml
end

def update_packages(document)
Expand Down

0 comments on commit a35c80d

Please sign in to comment.