Class: PDK::Generate::PuppetClass
- Inherits:
-
PuppetObject
- Object
- PuppetObject
- PDK::Generate::PuppetClass
- Defined in:
- lib/pdk/generate/puppet_class.rb
Constant Summary collapse
- PUPPET_STRINGS_TYPE =
'puppet_classes'.freeze
Instance Attribute Summary
Attributes inherited from PuppetObject
#context, #object_name, #options
Instance Method Summary collapse
- #friendly_name ⇒ Object
-
#initialize(*_args) ⇒ PuppetClass
constructor
A new instance of PuppetClass.
- #template_data ⇒ Object
- #template_files ⇒ Object
Methods inherited from PuppetObject
#can_run?, #check_preconditions, #module_name, #non_template_files, #run, #spec_only?, #stage_change, #stage_changes, #templates, #update_manager_instance, #with_templates
Constructor Details
#initialize(*_args) ⇒ PuppetClass
Returns a new instance of PuppetClass.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pdk/generate/puppet_class.rb', line 8 def initialize(*_args) super object_name_parts = @object_name.split('::') @object_name = if object_name_parts.first == module_name object_name else [module_name, object_name].join('::') end end |
Instance Method Details
#friendly_name ⇒ Object
19 20 21 |
# File 'lib/pdk/generate/puppet_class.rb', line 19 def friendly_name 'Puppet Class'.freeze end |
#template_data ⇒ Object
38 39 40 |
# File 'lib/pdk/generate/puppet_class.rb', line 38 def template_data { name: object_name } end |
#template_files ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pdk/generate/puppet_class.rb', line 23 def template_files # Calculate the class tests name class_name_parts = object_name.split('::') # Drop the module name if the object name contains multiple parts class_name_parts.delete_at(0) if class_name_parts.length > 1 files = { 'class_spec.erb' => "#{File.join('spec', 'classes', *class_name_parts)}_spec.rb" } return files if spec_only? class_name_parts = object_name.split('::')[1..] class_name_parts << 'init' if class_name_parts.empty? files['class.erb'] = "#{File.join('manifests', *class_name_parts)}.pp" files end |