class Retrospec::Puppet::Generators::DataTypeGenerator

Public Class Methods

generate_spec_files(module_path, config_data) click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/data_type_generator.rb, line 33
def self.generate_spec_files(module_path, config_data)
  manifest_files(module_path).map do |file|
    datatype = new(module_path, config_data.merge({:manifest_file => file}))
    next unless datatype.resource_type == ::Puppet::Pops::Model::TypeAlias
    datatype.generate_spec_file
  end.flatten
end
manifest_files(module_path) click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/data_type_generator.rb, line 16
def self.manifest_files(module_path)
  Dir.glob(File.join(module_path, 'types', '**', '*.pp'))
end
new(module_path, spec_object = {}) click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/data_type_generator.rb, line 10
def initialize(module_path, spec_object = {})
  super
  @singular_name = 'type_alias'
  @plural_name = 'type_aliases'
end

Public Instance Methods

load_context_data() click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/data_type_generator.rb, line 24
def load_context_data
  context.content = generate_content
  context.parameters = parameters
  context.type_name = type_name
  context.resource_type = resource_type
  context.resource_type_name = resource_type_name
  context
end
spec_template_file() click to toggle source
# File lib/retrospec/plugins/v1/plugin/generators/data_type_generator.rb, line 20
def spec_template_file
  'datatype_spec.rb.retrospec.erb'
end
template_dir() click to toggle source

returns the path to the templates first looks inside the external templates directory for specific file then looks inside the gem path templates directory, which is really only useful when developing new templates.

# File lib/retrospec/plugins/v1/plugin/generators/data_type_generator.rb, line 45
def template_dir
  if config_data[:template_dir]
    external_templates = Dir.glob(File.expand_path(File.join(config_data[:template_dir], 'type_aliases', '*.erb')))
  end
  if external_templates and external_templates.count > 0
    File.join(config_data[:template_dir], 'type_aliases')
  else
    File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'templates', 'type_aliases'))
  end
end