Module: AbideDevUtils::CEM::Generate::Reference

Defined in:
lib/abide_dev_utils/cem/generate/reference.rb

Overview

Holds objects and methods for generating a reference doc

Defined Under Namespace

Classes: ConfigExampleError, ControlMarkdown, MarkdownGenerator, Strings, TypeExprValueFormatter

Constant Summary collapse

MAPPING_PATH_KEY =
'Mapping Data'
RESOURCE_DATA_PATH_KEY =
'Resource Data'

Class Method Summary collapse

Class Method Details

.config_example(control, params_array) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/abide_dev_utils/cem/generate/reference.rb', line 46

def self.config_example(control, params_array)
  out_str = ['cem_windows::config:', '  control_configs:', "    \"#{control}\":"]
  indent = '      '
  params_array.each do |param_hash|
    val = case param_hash[:type]
          when 'String'
            "'#{param_hash[:default]}'"
          else
            param_hash[:default]
          end

    out_str << "#{indent}#{param_hash[:name]}: #{val}"
  end
  out_str.join("\n")
end

.generate(data = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/abide_dev_utils/cem/generate/reference.rb', line 22

def self.generate(data = {})
  pupmod = AbideDevUtils::Ppt::PuppetModule.new
  doc_title = case pupmod.name
              when 'puppetlabs-cem_linux'
                'CEM Linux Reference'
              when 'puppetlabs-cem_windows'
                'CEM Windows Reference'
              else
                'Reference'
              end
  benchmarks = AbideDevUtils::CEM::Benchmark.benchmarks_from_puppet_module(pupmod)
  case data.fetch(:format, 'markdown')
  when 'markdown'
    file = data[:out_file] || 'REFERENCE.md'
    MarkdownGenerator.new(benchmarks, pupmod.name, file: file, opts: data).generate(doc_title)
  else
    raise "Format #{data[:format]} is unsupported! Only `markdown` format supported"
  end
end

.generate_markdownObject



42
43
44
# File 'lib/abide_dev_utils/cem/generate/reference.rb', line 42

def self.generate_markdown
  AbideDevUtils::Markdown.new('REFERENCE.md').generate
end