Module: AbideDevUtils::Sce::Generate::Reference

Defined in:
lib/abide_dev_utils/sce/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



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/abide_dev_utils/sce/generate/reference.rb', line 52

def self.config_example(control, params_array)
  out_str = ['sce_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 = {}) ⇒ Array<Array<StandardError>>

Returns a 2d array with two items. The first item is an array containing StandardError-derived objects that are considered halting errors in reference generation. The second item is an array of StandardError-derived objects that are considered non-halting (warning) errors.

Returns:

  • (Array<Array<StandardError>>)

    Returns a 2d array with two items. The first item is an array containing StandardError-derived objects that are considered halting errors in reference generation. The second item is an array of StandardError-derived objects that are considered non-halting (warning) errors.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/abide_dev_utils/sce/generate/reference.rb', line 26

def self.generate(data = {})
  pupmod_path = data[:module_dir] || Dir.pwd
  bm_loader = BenchmarkLoader::PupMod.new(pupmod_path, ignore_framework_mismatch: true)
  doc_title = case bm_loader.pupmod.name
              when 'puppetlabs-sce_linux'
                'SCE for Linux Reference'
              when 'puppetlabs-sce_windows'
                'SCE for Windows Reference'
              else
                'Reference'
              end
  benchmarks = bm_loader.load
  case data.fetch(:format, 'markdown')
  when 'markdown'
    file = data[:out_file] || 'REFERENCE.md'
    MarkdownGenerator.new(benchmarks, bm_loader.pupmod.name, file: file, opts: data).generate(doc_title)
  else
    raise "Format #{data[:format]} is unsupported! Only `markdown` format supported"
  end
  [bm_loader.load_errors, bm_loader.load_warnings]
end

.generate_markdownObject



48
49
50
# File 'lib/abide_dev_utils/sce/generate/reference.rb', line 48

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