Class: Retrospec::Puppet::SpecObject
- Inherits:
-
Retrospec::Plugins::V1::ContextObject
- Object
- Retrospec::Plugins::V1::ContextObject
- Retrospec::Puppet::SpecObject
- Defined in:
- lib/retrospec/plugins/v1/plugin/spec_object.rb
Overview
this object is passed to the templates for erb template rendering you can use data contained in this object in your templates
Instance Attribute Summary collapse
-
#all_hiera_data ⇒ Hash
readonly
does not search for manual lookups using the hiera or lookup function quits and the user wants to run again, but if some external tool keeps this in memory the data would never be refreshed.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#enable_beaker_tests ⇒ Object
Returns the value of attribute enable_beaker_tests.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#module_name ⇒ String
readonly
-
the name of the module.
-
-
#module_path ⇒ Object
readonly
Returns the value of attribute module_path.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#type ⇒ Object
Returns the value of attribute type.
-
#types ⇒ Array
this is a list of defined and class types.
Instance Method Summary collapse
-
#class_hiera_data(classname) ⇒ Hash
does not search for manual lookups using the hiera or lookup function.
-
#enable_beaker_tests? ⇒ Boolean
-
true if the user wants to enable beaker tests.
-
- #fact_name ⇒ Object
-
#host_classes ⇒ Array
-
an array of all the hostclasses.
-
-
#initialize(mod_path, instance_data, config_data) ⇒ SpecObject
constructor
A new instance of SpecObject.
-
#variable_value(variable_name) ⇒ String
allows the user to use the variable store to resolve the variable if it exists looks up the varible name in the variable store.
Constructor Details
#initialize(mod_path, instance_data, config_data) ⇒ SpecObject
Returns a new instance of SpecObject.
13 14 15 16 17 18 |
# 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 |
Instance Attribute Details
#all_hiera_data ⇒ Hash (readonly)
this stays in memory, which should not cause a problem when the program
does not search for manual lookups using the hiera or lookup function quits and the user wants to run again, but if some external tool keeps this in memory the data would never be refreshed
56 57 58 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 56 def all_hiera_data @all_hiera_data end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 7 def config @config end |
#enable_beaker_tests ⇒ Object
Returns the value of attribute enable_beaker_tests.
8 9 10 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 8 def enable_beaker_tests @enable_beaker_tests end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
7 8 9 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 7 def instance @instance end |
#module_name ⇒ String (readonly)
Returns - the name of the module.
21 22 23 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 21 def module_name @module_name end |
#module_path ⇒ Object (readonly)
Returns the value of attribute module_path.
7 8 9 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 7 def module_path @module_path end |
#parameters ⇒ Object
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 8 def parameters @parameters end |
#resources ⇒ Object
Returns the value of attribute resources.
8 9 10 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 8 def resources @resources end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 8 def type @type end |
#types ⇒ Array
this is a list of defined and class types
27 28 29 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 27 def types @types end |
Instance Method Details
#class_hiera_data(classname) ⇒ Hash
does not search for manual lookups using the hiera or lookup function
34 35 36 37 38 39 40 41 42 43 |
# 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? ⇒ Boolean
Returns - true if the user wants to enable beaker tests.
68 69 70 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 68 def enable_beaker_tests? config[:enable_beaker_tests] end |
#fact_name ⇒ Object
80 81 82 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 80 def fact_name instance[:name] end |
#host_classes ⇒ Array
Returns - an array of all the hostclasses.
46 47 48 |
# 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) ⇒ String
allows the user to use the variable store to resolve the variable if it exists looks up the varible name in the variable store
76 77 78 |
# File 'lib/retrospec/plugins/v1/plugin/spec_object.rb', line 76 def variable_value(variable_name) VariableStore.resolve(variable_name) end |