From f02847608d9dbde44947588286c8c0cc01237a87 Mon Sep 17 00:00:00 2001 From: Alex Legler Date: Fri, 25 Dec 2015 17:16:14 +0100 Subject: Ruby style settings and fixes --- lib/glsav1.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/glsav1.rb') diff --git a/lib/glsav1.rb b/lib/glsav1.rb index 22ec1f1..d2c1692 100644 --- a/lib/glsav1.rb +++ b/lib/glsav1.rb @@ -3,7 +3,7 @@ require 'date' # A version 1 GLSA class GLSAv1 attr_reader :id, :title, :synopsis, :product, :date, :revised, :revision, :bugs, :access, :packages, - :background, :description, :severity, :impact, :workaround, :resolution, :references + :background, :description, :severity, :impact, :workaround, :resolution, :references def parse(xml) @id = xml.root['id'] @@ -15,15 +15,15 @@ class GLSAv1 @revision = xml.xpath('/glsa/revised/text()').first.content.split(': ') @revised = DateTime.parse(@revised) - @bugs = xml.xpath('/glsa/bug/text()').map {|bug_node| bug_node.content.to_i } + @bugs = xml.xpath('/glsa/bug/text()').map { |bug_node| bug_node.content.to_i } @access = xml.xpath('/glsa/access/text()').first.content @packages = {} xml.xpath('/glsa/affected/package').each do |package| @packages[package['name'] + ':' + package['arch']] = { auto: package['auto'] == 'yes', - unaffected: package.xpath('./unaffected').map {|ver| [ver['range'], ver.content] }, - vulnerable: package.xpath('./vulnerable').map {|ver| [ver['range'], ver.content] } + unaffected: package.xpath('./unaffected').map { |ver| [ver['range'], ver.content] }, + vulnerable: package.xpath('./vulnerable').map { |ver| [ver['range'], ver.content] } } end @@ -33,12 +33,13 @@ class GLSAv1 @impact = xml_content xml, '/glsa/impact' @workaround = xml_content xml, '/glsa/workaround' @resolution = xml_content xml, '/glsa/resolution' - @references = xml.xpath('/glsa/references/uri').map {|uri| [uri.content, uri['link']] } + @references = xml.xpath('/glsa/references/uri').map { |uri| [uri.content, uri['link']] } self end private + def xml_content(xml, xpath) xml.xpath(xpath).first.children.to_xml.strip rescue @@ -50,4 +51,4 @@ class GLSAv1 rescue '' end -end \ No newline at end of file +end -- cgit v1.2.3-65-gdbad