Class: Vipergen::TemplateManager
- Inherits:
-
Object
- Object
- Vipergen::TemplateManager
- Defined in:
- lib/vipergen/templatemanager.rb
Class Method Summary collapse
-
.template_description(template_path) ⇒ Object
Returns the description of a given template.
-
.template_name_from_path(template_path) ⇒ Object
Returns the template name from a given template_path.
-
.templates ⇒ Object
Get the templates names.
-
.templates_description ⇒ Object
Returns the description of all the templates available.
-
.templates_dir ⇒ Object
Returns the templates dir.
-
.templates_paths ⇒ Object
Get the available templates paths.
Class Method Details
.template_description(template_path) ⇒ Object
Returns the description of a given template
43 44 45 46 47 48 49 50 51 |
# 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) ⇒ Object
Returns the template name from a given template_path
25 26 27 |
# File 'lib/vipergen/templatemanager.rb', line 25 def self.template_name_from_path(template_path) return template_path.split("/").last end |
.templates ⇒ Object
Get the templates names
19 20 21 |
# File 'lib/vipergen/templatemanager.rb', line 19 def self.templates() templates_paths.map{|template_path| template_name_from_path(template_path)} end |
.templates_description ⇒ Object
Returns the description of all the templates available
31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
Returns the templates dir
6 7 8 |
# File 'lib/vipergen/templatemanager.rb', line 6 def self.templates_dir t = "#{File. File.dirname(__FILE__)}/../templates" end |
.templates_paths ⇒ Object
Get the available templates paths
12 13 14 15 |
# 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 |