Class: Retrospec::Puppet::Generators::NodeGenerator

Inherits:
ResourceBaseGenerator show all
Defined in:
lib/retrospec/plugins/v1/plugin/generators/node_generator.rb

Instance Attribute Summary

Attributes inherited from BaseGenerator

#context, #generator_template_dir_name, #plural_name, #singular_name, #template_dir

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ResourceBaseGenerator

#ast, #dumper, #find_all_resources, #generate_content, #generate_file_name, #generate_spec_file, #item_path, #item_spec_path, #lib_path, #load_context_data, #manifest_body, #manifest_file, manifest_files, #parameters, #plural_name, #resource_type, #resource_type_name, #resources, #run, run_cli, #singular_name, #spec_path, #type_name

Methods inherited from BaseGenerator

#generate_lib_files, #generate_spec_files, #get_binding, #item_name, #item_path, #item_spec_path, #lib_path, #logger, #run, run_cli, #spec_path

Constructor Details

#initialize(module_path, spec_object = {}) ⇒ NodeGenerator

retrospec will initilalize this class so its up to you to set any additional variables you need to get the job done.



12
13
14
15
16
# File 'lib/retrospec/plugins/v1/plugin/generators/node_generator.rb', line 12

def initialize(module_path, spec_object = {})
  super
  @singular_name = 'node'
  @plural_name = 'nodes'
end

Class Method Details

.generate_spec_files(module_path, config_data) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/retrospec/plugins/v1/plugin/generators/node_generator.rb', line 22

def self.generate_spec_files(module_path, config_data)
  files = []
  manifest_files(module_path).each do |file|
    nodedef = new(module_path, config_data.merge({:manifest_file => file}))
    next unless nodedef.resource_type == ::Puppet::Pops::Model::NodeDefinition
    files << nodedef.generate_spec_file
  end
  files
end

Instance Method Details

#spec_template_fileObject



18
19
20
# File 'lib/retrospec/plugins/v1/plugin/generators/node_generator.rb', line 18

def spec_template_file
  'node_spec.rb.retrospec.erb'
end