-
Notifications
You must be signed in to change notification settings - Fork 14
Parse fixes #26
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
Parse fixes #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # frozen_string_literal: true | ||
| require 'openscap_parser/xml_node' | ||
| require 'openscap_parser/subs' | ||
|
|
||
| module OpenscapParser | ||
| class Fix < XmlNode | ||
| include OpenscapParser::Subs | ||
|
|
||
| def id | ||
| @id ||= @parsed_xml['id'] | ||
| end | ||
|
|
||
| def system | ||
| @system ||= @parsed_xml['system'] | ||
| end | ||
|
|
||
| def complexity | ||
| @complexity ||= @parsed_xml['complexity'] | ||
| end | ||
|
|
||
| def disruption | ||
| @disruption ||= @parsed_xml['disruption'] | ||
| end | ||
|
|
||
| def strategy | ||
| @strategy ||= @parsed_xml['strategy'] | ||
| end | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put this on the |
||
|
|
||
| def to_h | ||
| { | ||
| :id => id, | ||
| :system => system, | ||
| :complexity => complexity, | ||
| :disruption => disruption, | ||
| :strategy => strategy, | ||
| :text => text, | ||
| :subs => subs.map(&:to_h) | ||
| } | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'openscap_parser/fix' | ||
|
|
||
| module OpenscapParser | ||
| module Fixes | ||
| def self.included(base) | ||
| base.class_eval do | ||
| def fixes | ||
| @fixes ||= fix_nodes.map do |fix_node| | ||
| OpenscapParser::Fix.new(parsed_xml: fix_node) | ||
| end | ||
| end | ||
|
|
||
| def fix_nodes(xpath = ".//fix") | ||
| xpath_nodes(xpath) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # frozen_string_literal: true | ||
| require 'openscap_parser/xml_node' | ||
|
|
||
| module OpenscapParser | ||
| class Sub < XmlNode | ||
| def id | ||
| @id ||= @parsed_xml['idref'] | ||
| end | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add
|
||
| def use | ||
| @use ||= @parsed_xml['use'] | ||
| end | ||
|
|
||
| def to_h | ||
| { :id => id, :text => text, :use => use } | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'openscap_parser/sub' | ||
|
|
||
| module OpenscapParser | ||
| module Subs | ||
| def self.included(base) | ||
| base.class_eval do | ||
| def subs | ||
| return [] unless sub_nodes | ||
| @subs ||= sub_nodes.map do |xml| | ||
| Sub.new(parsed_xml: xml) | ||
| end | ||
| end | ||
|
|
||
| def sub_nodes(xpath = './/sub') | ||
| @sub_nodes ||= xpath_nodes(xpath) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include
disruptionandstrategy?