class Vipergen::TemplateManager
Public Class Methods
template_description(template_path)
click to toggle source
Returns the description of a given template @param template String with the template path whose description is going to be returned @return String with the template description
# File lib/vipergen/templatemanager.rb, line 43 def self.template_description(template_path) template_description = "" # Reading yaml template_content = YAML.load_file(File.join(template_path,'viperspec.yml')) # Generating string template_description+= "| #{template_name_from_path(template_path)} by #{template_content["author"]} |: #{template_content["template_description"]}" end
template_name_from_path(template_path)
click to toggle source
Returns the template name from a given template_path @return String with the template name
# File lib/vipergen/templatemanager.rb, line 25 def self.template_name_from_path(template_path) return template_path.split("/").last end
templates()
click to toggle source
Get the templates names @return Array with templates names (got from the folder)
# File lib/vipergen/templatemanager.rb, line 19 def self.templates() templates_paths.map{|template_path| template_name_from_path(template_path)} end
templates_description()
click to toggle source
Returns the description of all the templates available @return String with the entire description
# File lib/vipergen/templatemanager.rb, line 31 def self.templates_description() description = "\nAvailable templates \n" description += "------------------- \n" self.templates_paths.each do |template_path| description += "> #{template_description(template_path)} \n" end return description end
templates_dir()
click to toggle source
Returns the templates dir
# File lib/vipergen/templatemanager.rb, line 6 def self.templates_dir t = "#{File.expand_path File.dirname(__FILE__)}/../templates" end
templates_paths()
click to toggle source
Get the available templates paths @return Array with available templates paths
# File lib/vipergen/templatemanager.rb, line 12 def self.templates_paths() template_dir = Vipergen::TemplateManager.templates_dir return Vipergen::DirUtils.directories_in(template_dir) end