class Retrospec::Puppet::SpecObject

this object is passed to the templates for erb template rendering you can use data contained in this object in your templates

Attributes

all_hiera_data[R]
config[R]
enable_beaker_tests[RW]
instance[R]
module_name[R]
module_path[R]
parameters[RW]
resources[RW]
type[RW]
types[RW]

Public Class Methods

new(mod_path, instance_data, config_data) click to toggle source

@param mod_path [String] - the path to the module @param instance_data [Hash] @param config_data [Hash] - retrospec config data from config file and cli

# File lib/retrospec/plugins/v1/plugin/spec_object.rb, line 13
def initialize(mod_path, instance_data, config_data)
  @instance = instance_data
  @config = config_data
  @module_path = mod_path
  all_hiera_data
end

Public Instance Methods

class_hiera_data(classname) click to toggle source

@return [Hash] - return a hash of all the params found in provided hostclass only @param [String] - the name of the hostclass does not search for manual lookups using the hiera or lookup function

# File lib/retrospec/plugins/v1/plugin/spec_object.rb, line 34
def class_hiera_data(classname)
  data = {}
  found_type = host_classes.find { |t| t.name == classname }
  return data unless found_type
  found_type.arguments.each do |k, _v|
    key = "#{found_type.name}::#{k}"
    data[key] = nil
  end
  data
end
enable_beaker_tests?() click to toggle source

@return [Boolean] - true if the user wants to enable beaker tests

# File lib/retrospec/plugins/v1/plugin/spec_object.rb, line 68
def enable_beaker_tests?
  config[:enable_beaker_tests]
end
fact_name() click to toggle source
# File lib/retrospec/plugins/v1/plugin/spec_object.rb, line 80
def fact_name
  instance[:name]
end
host_classes() click to toggle source

@return [Array] - an array of all the hostclasses

# File lib/retrospec/plugins/v1/plugin/spec_object.rb, line 46
def host_classes
  types.find_all { |t| t.type == :hostclass }
end
variable_value(variable_name) click to toggle source

allows the user to use the variable store to resolve the variable if it exists looks up the varible name in the variable store @param [String] - the name of the variable @return [String] - the value of the variable if found other returns variable

# File lib/retrospec/plugins/v1/plugin/spec_object.rb, line 76
def variable_value(variable_name)
  VariableStore.resolve(variable_name)
end