Class: FolderTemplate::TemplateRegistry
- Inherits:
-
Object
- Object
- FolderTemplate::TemplateRegistry
- Defined in:
- lib/folder_template/template_registry.rb
Instance Attribute Summary collapse
-
#template_locations ⇒ Object
readonly
Returns the value of attribute template_locations.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ TemplateRegistry
constructor
A new instance of TemplateRegistry.
- #path_for_template(template_name) ⇒ Object
- #scan_location(base_path) ⇒ Object
Constructor Details
#initialize ⇒ TemplateRegistry
Returns a new instance of TemplateRegistry.
17 18 19 |
# File 'lib/folder_template/template_registry.rb', line 17 def initialize @template_locations = {} end |
Instance Attribute Details
#template_locations ⇒ Object (readonly)
Returns the value of attribute template_locations.
15 16 17 |
# File 'lib/folder_template/template_registry.rb', line 15 def template_locations @template_locations end |
Class Method Details
.registry_with_default_locations ⇒ Object
21 22 23 24 25 26 |
# File 'lib/folder_template/template_registry.rb', line 21 def self.registry_with_default_locations() r = TemplateRegistry.new r.scan_location( File.join( BASE_PATH, "templates" ) ) r.scan_location( File.( "~/.folder_template" ) ) r end |
Instance Method Details
#path_for_template(template_name) ⇒ Object
35 36 37 38 |
# File 'lib/folder_template/template_registry.rb', line 35 def path_for_template( template_name ) path_list = @template_locations[template_name] path_list.first if path_list end |
#scan_location(base_path) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/folder_template/template_registry.rb', line 28 def scan_location( base_path ) _list_template_folders( base_path ).each do |path| _register_template_path( path ) end self end |