Class: Generamba::CatalogTemplateListHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/template/helpers/catalog_template_list_helper.rb

Overview

Provides the functionality to list all of the templates, available in the catalog

Instance Method Summary collapse

Instance Method Details

#obtain_all_templates_from_a_catalog(catalog_path) ⇒ Array

Finds out all of the templates located in a catalog

Parameters:

  • catalog_path (Pathname)

    The path to a template catalog

Returns:

  • (Array)

    An array with template names



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generamba/template/helpers/catalog_template_list_helper.rb', line 11

def obtain_all_templates_from_a_catalog(catalog_path)
  template_names = []
  catalog_path.children.select { |child|
    File.directory?(child) && child.split.last.to_s[0] != '.'
  }.map { |template_path|
    template_path.split.last.to_s
  }.each { |template_name|
    template_names.push(template_name)
  }
  return template_names
end