Class: Viperaptor::CatalogTemplateListHelper
- Inherits:
-
Object
- Object
- Viperaptor::CatalogTemplateListHelper
- Defined in:
- lib/viperaptor/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
-
#obtain_all_templates_from_a_catalog(catalog_path) ⇒ Array
Finds out all of the templates located in a catalog.
- #template_path(catalog_path, template_name) ⇒ Object
Instance Method Details
#obtain_all_templates_from_a_catalog(catalog_path) ⇒ Array
Finds out all of the templates located in a catalog
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/viperaptor/template/helpers/catalog_template_list_helper.rb', line 11 def obtain_all_templates_from_a_catalog(catalog_path) return [] unless catalog_path.exist? contains_specs = catalog_path.children.count { |c| c.extname == RAMBASPEC_EXTENSION } > 0 skip_testable = ENV['RACK_ENV'] != 'test' if contains_specs if !skip_testable || catalog_path.split.last.to_s.start_with?("test-") return [] end return catalog_path.children .map { |child| child.split.last.to_s } .select { |i| /^[a-z0-9_]+\.rambaspec$/.match(i) } .map { |i| i.gsub RAMBASPEC_EXTENSION, '' } else return catalog_path.children .select {|child| child.directory? && child.split.last.to_s[0] != '.' } .select {|child| !skip_testable || !child.split.last.to_s.start_with?("test-") } .select {|child| child.join(child.split.last.to_s.gsub('/','') + RAMBASPEC_EXTENSION).exist? } .map { |child| child.split.last.to_s } end end |
#template_path(catalog_path, template_name) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/viperaptor/template/helpers/catalog_template_list_helper.rb', line 41 def template_path(catalog_path, template_name) contains_specs = catalog_path.children.count { |c| c.extname == RAMBASPEC_EXTENSION } > 0 if contains_specs return catalog_path else return catalog_path.join(template_name) end end |