Class: PDK::Generate::Task
- Inherits:
-
PuppetObject
- Object
- PuppetObject
- PDK::Generate::Task
- Defined in:
- lib/pdk/generate/task.rb
Instance Attribute Summary
Attributes inherited from PuppetObject
#context, #object_name, #options
Instance Method Summary collapse
-
#check_preconditions ⇒ Object
Checks that the task has not already been defined with a different extension.
- #friendly_name ⇒ Object
- #non_template_files ⇒ Object
- #template_data ⇒ Object
- #template_files ⇒ Object
Methods inherited from PuppetObject
#can_run?, #initialize, #module_name, #run, #spec_only?, #stage_change, #stage_changes, #templates, #update_manager_instance, #with_templates
Constructor Details
This class inherits a constructor from PDK::Generate::PuppetObject
Instance Method Details
#check_preconditions ⇒ Object
Checks that the task has not already been defined with a different extension.
task exist in the <module>/tasks/ directory
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pdk/generate/task.rb', line 29 def check_preconditions super error = "A task named '%{name}' already exists in this module; defined in %{file}" allowed_extensions = ['.md', '.conf'] PDK::Util::Filesystem.glob(File.join(context.root_path, 'tasks', "#{task_name}.*")).each do |file| next if allowed_extensions.include?(File.extname(file)) raise PDK::CLI::ExitWithError, format(error, name: task_name, file: file) end end |
#friendly_name ⇒ Object
6 7 8 |
# File 'lib/pdk/generate/task.rb', line 6 def friendly_name 'Task' end |
#non_template_files ⇒ Object
42 43 44 45 |
# File 'lib/pdk/generate/task.rb', line 42 def non_template_files = File.join('tasks', "#{task_name}.json") { => JSON.pretty_generate() } end |
#template_data ⇒ Object
18 19 20 21 22 |
# File 'lib/pdk/generate/task.rb', line 18 def template_data { name: object_name } end |
#template_files ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/pdk/generate/task.rb', line 10 def template_files return {} if spec_only? { 'task.erb' => File.join('tasks', "#{task_name}.sh") } end |