Class: Inspec::Profile::AstHelper::DescCollector
- Inherits:
-
CollectorBase
- Object
- Parser::AST::Processor
- CollectorBase
- Inspec::Profile::AstHelper::DescCollector
- Defined in:
- lib/inspec/utils/profile_ast_helpers.rb
Instance Attribute Summary
Attributes inherited from CollectorBase
Instance Method Summary collapse
Methods inherited from CollectorBase
Constructor Details
This class inherits a constructor from Inspec::Profile::AstHelper::CollectorBase
Instance Method Details
#on_send(node) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/inspec/utils/profile_ast_helpers.rb', line 94 def on_send(node) if RuboCop::AST::NodePattern.new("(send nil? :desc ...)").match(node) memo[:descriptions] ||= {} if node.children[2] && node.children[3] # NOTE: This assumes the description is as below # desc 'label', 'An optional description with a label' # Pair a part of the description with a label memo[:descriptions] = memo[:descriptions].merge(node.children[2].value => node.children[3].value) else memo[:desc] = node.children[2].value memo[:descriptions] = memo[:descriptions].merge(default: node.children[2].value) end end end |