Class: Retrospec::Puppet::Generators::DefinitionGenerator

Inherits:
ResourceBaseGenerator show all
Defined in:
lib/retrospec/plugins/v1/plugin/generators/definition_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_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_file_name, #generate_lib_files, #generate_path, #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 = {}) ⇒ DefinitionGenerator

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/definition_generator.rb', line 12

def initialize(module_path, spec_object = {})
  super
  @singular_name = 'define'
  @plural_name = 'defines'
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/definition_generator.rb', line 22

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

Instance Method Details

#spec_template_fileObject



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

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