Class: AbideDevUtils::CEM::Generate::Reference::MarkdownGenerator
- Inherits:
-
Object
- Object
- AbideDevUtils::CEM::Generate::Reference::MarkdownGenerator
- Defined in:
- lib/abide_dev_utils/cem/generate/reference.rb
Overview
Generates a markdown reference doc
Instance Method Summary collapse
- #generate(doc_title = 'Reference') ⇒ Object
-
#initialize(benchmarks, module_name, file: 'REFERENCE.md') ⇒ MarkdownGenerator
constructor
A new instance of MarkdownGenerator.
Constructor Details
#initialize(benchmarks, module_name, file: 'REFERENCE.md') ⇒ MarkdownGenerator
Returns a new instance of MarkdownGenerator.
61 62 63 64 65 66 |
# File 'lib/abide_dev_utils/cem/generate/reference.rb', line 61 def initialize(benchmarks, module_name, file: 'REFERENCE.md') @benchmarks = benchmarks @module_name = module_name @file = file @md = AbideDevUtils::Markdown.new(@file) end |
Instance Method Details
#generate(doc_title = 'Reference') ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/abide_dev_utils/cem/generate/reference.rb', line 68 def generate(doc_title = 'Reference') md.add_title(doc_title) benchmarks.each do |benchmark| = AbideDevUtils::Output.progress(title: "Generating Markdown for #{benchmark.title_key}", total: benchmark.controls.length) md.add_h1(benchmark.title_key) benchmark.controls.each do |control| next if ['cem_options', 'cem_protected', 'dependent'].include? control.id next if benchmark.framework == 'stig' && control.id_map_type != 'vulnid' control_md = ControlMarkdown.new(control, @md, @module_name, benchmark.framework) control_md.generate! .increment rescue StandardError => e raise "Failed to generate markdown for control #{control.id}. Original message: #{e.}" end end AbideDevUtils::Output.simple("Saving markdown to #{@file}") md.to_file end |