lib/pdk/generators/puppet_object.rb
def with_templates
        templates.each do |template|
          if template[:url].nil?
            PDK.logger.debug(_('No %{dir_type} template specified; trying next template directory.') % { dir_type: template[:type] })
            next
          end

          PDK::Module::TemplateDir.new(template[:url]) do |template_dir|
            template_paths = template_dir.object_template_for(object_type)

            if template_paths
              config_hash = template_dir.object_config
              yield template_paths, config_hash
              # TODO: refactor to a search-and-execute form instead
              return # work is done # rubocop:disable Lint/NonLocalExitFromIterator
            elsif template[:allow_fallback]
              PDK.logger.debug(_('Unable to find a %{type} template in %{url}, trying next template directory') % { type: object_type, url: template[:url] })
            else
              raise PDK::CLI::FatalError, _('Unable to find the %{type} template in %{url}.') % { type: object_type, url: template[:url] }
            end
          end
        end
      end
# Search the possible template directories in order of preference to find
# a template that can be used to render a new object of the specified
# type.
#
# @yieldparam template_paths [Hash{Symbol => String}] :object contains
#   the path on disk to the template file for the object, :spec contains
#   the path on disk to the template file for the tests for the object
#   (if it exists).
# @yieldparam config_hash [Hash{Object => Object}] the contents of the
#   :global key in the config_defaults.yml file.
#
# @raise [PDK::CLI::FatalError] if no suitable template could be found.
#
# @api private
Search the possible template directories in order of preference to find
a template that can be used to render a new object of the specified
type.
Search the possible template directories in order of preference to find a template that can be used to render a new object of the specified type .
def with_templates
        templates.each do |template|
          if template[:url].nil?
            PDK.logger.debug(_('No %{dir_type} template specified; trying next template directory.') % { dir_type: template[:type] })
            next
          end
          PDK::Module::TemplateDir.new(template[:url]) do |template_dir|
            template_paths = template_dir.object_template_for(object_type)
            if template_paths
              config_hash = template_dir.object_config
              yield template_paths, config_hash
              return 
            elsif template[:allow_fallback]
              PDK.logger.debug(_('Unable to find a %{type} template in %{url}, trying next template directory') % { type: object_type, url: template[:url] })
            else
              raise PDK::CLI::FatalError, _('Unable to find the %{type} template in %{url}.') % { type: object_type, url: template[:url] }
            end
          end
        end
      end
def with_templates templates . each do | template | if template [ :url ] . nil? PDK . logger . debug ( _ ( 'No %{dir_type} template specified; trying next template directory.' ) % { dir_type : template [ :type ] } ) next end PDK :: Module :: TemplateDir . new ( template [ :url ] ) do | template_dir | template_paths = template_dir . object_template_for ( object_type ) if template_paths config_hash = template_dir . object_config yield template_paths , config_hash return elsif template [ :allow_fallback ] PDK . logger . debug ( _ ( 'Unable to find a %{type} template in %{url}, trying next template directory' ) % { type : object_type , url : template [ :url ] } ) else raise PDK :: CLI :: FatalError , _ ( 'Unable to find the %{type} template in %{url}.' ) % { type : object_type , url : template [ :url ] } end end end end
Search the possible template directories in order of preference to find
a template that can be used to render a new object of the specified
type.
Search the possible template directories in order of preference to find a template that can be used to render a new object of the specified type .
# TODO: refactor to a search-and-execute form instead # work is done # rubocop:disable Lint/NonLocalExitFromIterator
[PDK::CLI::FatalError] if no suitable template could be found.
[ PDK :: CLI :: FatalError ] if no suitable template could be found .
template_paths
:object contains the path on disk to the template file for the object, :spec contains the path on disk to the template file for the tests for the object (if it exists).
: object contains the path on disk to the template file for the object : spec contains the path on disk to the template file for the tests for the object ( if it exists ) .
config_hash
the contents of the :global key in the config_defaults.yml file.
the contents of the : global key in the config_defaults . yml file .
api
None